Skip to content

Commit 576627e

Browse files
committed
Feature: support SLB to expose service
1 parent 036e871 commit 576627e

File tree

9 files changed

+35
-13
lines changed

9 files changed

+35
-13
lines changed

charts/raven-agent/values.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ securityContext:
3232
privileged: true
3333

3434
nodeSelector:
35-
beta.kubernetes.io/arch: amd64
36-
beta.kubernetes.io/os: linux
35+
kubernetes.io/arch: amd64
36+
kubernetes.io/os: linux
3737

3838
tolerations: [{"operator": "Exists"}]
3939

config/raven-agent/agent/patches.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ spec:
1616
values:
1717
- virtual-kubelet
1818
nodeSelector:
19-
beta.kubernetes.io/arch: amd64
20-
beta.kubernetes.io/os: linux
19+
kubernetes.io/arch: amd64
20+
kubernetes.io/os: linux
2121
tolerations:
2222
- operator: Exists

docs/raven-agent-tutorial.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,28 @@ NOTE: Make sure there are no node IP conflicts in the cluster.
197197
By default, raven uses IPSec as VPN backend, we also provide [WireGuard](https://www.wireguard.com/) as an alternative. You can switch to WireGuard backend by the following steps:
198198

199199
- Raven requires the WireGuard kernel module to be loaded on gateway nodes in the cluster. Starting at Linux 5.6, the kernel includes WireGuard in-tree; Linux distributions with older kernels will need to install WireGuard. For most Linux distributions, this can be done using the system package manager. For more information, see [Install WireGuard](https://www.wireguard.com/install/).
200-
- The gateway nodes will require an open UDP port in order to communicate. By default, WireGuard uses UDP port 51820.
200+
- The gateway nodes will require an open UDP port in order to communicate. By default, we use UDP port 4500.
201201
- Run the following commands:
202202

203203
```bash
204204
cd raven
205205
make undeploy
206206
VPN_DRIVER=wireguard make deploy
207207
```
208+
209+
## (Optional 3) Use LoadBalancer to expose cloud gateway VPN service
210+
211+
By default, raven use EIP/Public IP to expose cloud gateway VPN service, we also provide LoadBalancer as an alternative. You can set `exposeType: LoadBalancer` in Gateway CR to enable it.
212+
213+
```bash
214+
$ cat <<EOF | kubectl apply -f -
215+
apiVersion: raven.openyurt.io/v1alpha1
216+
kind: Gateway
217+
metadata:
218+
name: gw-cloud
219+
spec:
220+
exposeType: LoadBalancer
221+
endpoints:
222+
- nodeName: master
223+
underNAT: false
224+
```

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.16
44

55
require (
66
github.com/EvilSuperstars/go-cidrman v0.0.0-20190607145828-28e79e32899a
7-
github.com/openyurtio/raven-controller-manager v0.1.1-0.20220712045115-14910b0bce36
7+
github.com/openyurtio/raven-controller-manager v0.3.1-0.20230220020223-39cb99a72df9
88
github.com/pkg/errors v0.9.1
99
github.com/spf13/cobra v1.6.1
1010
github.com/spf13/pflag v1.0.5

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,8 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
411411
github.com/onsi/gomega v1.17.0 h1:9Luw4uT5HTjHTN8+aNcSThgH1vdXnmdJ8xIfZ4wyTRE=
412412
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
413413
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
414-
github.com/openyurtio/raven-controller-manager v0.1.1-0.20220712045115-14910b0bce36 h1:HW8NZch3pBHxzYknwga5Wcf3LvcZ7Z5AxHdb0SWQFD4=
415-
github.com/openyurtio/raven-controller-manager v0.1.1-0.20220712045115-14910b0bce36/go.mod h1:QkKI16Qr4wECtjA6e9QV4bNUmQj4zPEJNbz0tYvqdA0=
414+
github.com/openyurtio/raven-controller-manager v0.3.1-0.20230220020223-39cb99a72df9 h1:SY2xf14YoPKbZfjyHPzaV/gn710Z1s/MKVxQ6lA790Y=
415+
github.com/openyurtio/raven-controller-manager v0.3.1-0.20230220020223-39cb99a72df9/go.mod h1:op6Yh+6WYNF6EdIMyiK+yHxjOhxmAgfDHhHizZakgXM=
416416
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
417417
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
418418
github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=

pkg/k8s/engine_controller.go

+2
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,12 @@ func (c *EngineController) configGatewayPublicIP(gateway *v1alpha1.Gateway) erro
272272
if gateway.Status.ActiveEndpoint.NodeName != c.nodeName {
273273
return nil
274274
}
275+
275276
publicIP, err := utils.GetPublicIP()
276277
if err != nil {
277278
return err
278279
}
280+
279281
// retry to update public ip of localGateway
280282
err = retry.RetryOnConflict(retry.DefaultBackoff, func() error {
281283
// get localGateway from api server

pkg/networkengine/vpndriver/driver_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/openyurtio/raven-controller-manager/pkg/ravencontroller/apis/raven/v1alpha1"
8+
89
"github.com/openyurtio/raven/cmd/agent/app/config"
910
"github.com/openyurtio/raven/pkg/types"
1011
)

pkg/networkengine/vpndriver/wireguard/wireguard.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ const (
5252
// PublicKey is name (key) of publicKey entry in back-end map.
5353
PublicKey = "publicKey"
5454
// KeepAliveInterval to use for wg peers.
55-
KeepAliveInterval = 10 * time.Second
55+
KeepAliveInterval = 5 * time.Second
5656

5757
// DeviceName specifies name of WireGuard network device.
5858
DeviceName = "raven-wg0"
5959
// ListenPort specifies port of WireGuard listened.
60-
ListenPort = 51820
60+
ListenPort = 4500
6161
)
6262

6363
var findCentralGw = vpndriver.FindCentralGwFn
@@ -417,7 +417,8 @@ func (w *wireguard) configGatewayPublicKey(gwName string, nodeName string) error
417417
// calWgRules calculates and returns the desired WireGuard rules on gateway node.
418418
// Rules on gateway will give raven route table a higher priority than main table in order to bypass the CNI routing rules.
419419
// The rules format are equivalent to the following `ip rule` command:
420-
// ip rule add from all lookup {wgRouteTableID} prio {wgRulePriority}
420+
//
421+
// ip rule add from all lookup {wgRouteTableID} prio {wgRulePriority}
421422
func (w *wireguard) calWgRules() map[string]*netlink.Rule {
422423
rules := make(map[string]*netlink.Rule)
423424
rule := networkutil.NewRavenRule(wgRulePriority, wgRouteTableID)
@@ -428,7 +429,8 @@ func (w *wireguard) calWgRules() map[string]*netlink.Rule {
428429
// calWgRoutes calculates and returns the desired WireGuard routes on gateway node.
429430
// Routes on gateway node will use a separate route table(wg route table),
430431
// The routes entries format are equivalent to the following `ip route` command:
431-
// ip route add {remote_subnet} dev raven-wg0 table {wgRouteTableID}
432+
//
433+
// ip route add {remote_subnet} dev raven-wg0 table {wgRouteTableID}
432434
func (w *wireguard) calWgRoutes(network *types.Network) map[string]*netlink.Route {
433435
routes := make(map[string]*netlink.Route)
434436
for _, v := range network.RemoteEndpoints {

pluto

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ set -e
2626
/usr/sbin/ipsec --checknss
2727

2828
# Start the daemon itself with any additional arguments passed in
29-
exec /usr/libexec/ipsec/pluto --leak-detective --config /etc/ipsec.conf --nofork "$@"
29+
exec /usr/libexec/ipsec/pluto --leak-detective --config /etc/ipsec.conf --keep-alive 5 --nofork "$@"

0 commit comments

Comments
 (0)