Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent cluster1 VXLAN IPsec アーキテクチャ Broker cluster2
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent api server master etcd Broker Gatewayノードから APIアクセスできる 必要がある Gatewayノードから APIアクセスできる 必要がある Brokerは独立した クラスターでも よい cluster1 cluster2 cluster3
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent VXLAN IPsec Master node Worker node cluster1 cluster2
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent VXLAN IPsec Gatewayノード Gatewayノード “submariner.io/gateway =true” というラベルが付与さ れたノードはGatewayノードとな る “submariner.io/gateway =true” というラベルが付与さ れたノードはGatewayノードとな る cluster1 cluster2
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent VXLAN IPsec Active Passive Passive Active クラスター内に複数の Gateway ノードが存在する場合は、 Leader Electionの仕組みにより1台Active ノードが選定される クラスター内に複数の Gateway ノードが存在する場合は、 Leader Electionの仕組みにより1台Active ノードが選定される cluster1 cluster2
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent VXLAN IPsec ActiveなGatewayノード のsubmariner-gateway Pod間でIPsec接続 各WorkerノードはActive なGatewayノードと VXLAN接続 cluster1 cluster2
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent VXLAN IPsec cluster1 cluster2
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent cluster1 cluster2 Broker
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent cluster1 cluster2 Broker 公開したいServiceに関して、あら かじめServiceExportを作成してお く subctl export service ${service} ServiceExport ※ ServiceExport, ServiceImportオブジェクトは、実際は etcdに保存されます
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent cluster1 cluster2 Broker Lighthouse Agentが ServiceExportに対応する ServiceImportを作成し、Brokerに 送信する ServiceExport ServiceImport ServiceImport ※ ServiceExport, ServiceImportオブジェクトは、実際は etcdに保存されます
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent cluster1 cluster2 Broker Lighthouse Agentが、他クラス ターのServiceImport情報を Brokerから取得する ServiceExport ServiceImport ServiceImport ServiceImport ServiceImport ※ ServiceExport, ServiceImportオブジェクトは、実際は etcdに保存されます
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent cluster1 cluster2 192.168.241.11 192.168.241.21 192.168.242.21 192.168.242.12 client Pod: 10.241.0.4 (169.254.18.25) target pod: 10.242.2.3 (169.254.32.40) target svc: 10.142.73.136 (169.254.33.168) name: nginx, namespace: default GlobalNet: 169.254.0.0/19 GlobalNet: 169.254.32.0/19 curl nginx.default.svc.clusterset.local (Pod IP address) (Global IP for Pod)
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent cluster1 cluster2 公開されたcluster2のnginx Serviceにアクセスするため、 DNS 解決を試みる クラスター内のLighthouse DNS サーバがcluster2のnginx ServiceのGlobal IPを返す 公開ServiceのFQDN: nginx.default.svc.clusterset.local nginx.default.svc.clusterset.localのIPアドレス: 169.254.33.168 GlobalNet: 169.254.0.0/19 GlobalNet: 169.254.32.0/19
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent cluster1 cluster2 公開されたcluster2のnginx Serviceにアクセスするため、 DNS 解決を試みる クラスター内のLighthouse DNS サーバがcluster2のnginx ServiceのGlobal IPを返す 公開ServiceのFQDN: nginx.default.svc.clusterset.local nginx.default.svc.clusterset.localのIPアドレス: 169.254.33.168 GlobalNet: 169.254.0.0/19 GlobalNet: 169.254.32.0/19 $ kubectl -n kube-system get cm coredns -o yaml | head -n 15 apiVersion: v1 data: Corefile: | #lighthouse clusterset.local:53 { forward . 10.141.162.221 } supercluster.local:53 { forward . 10.141.162.221 } .:53 { errors health { lameduck 5s } $ kubectl -n submariner-operator get svc NAME TYPE CLUSTER-IP EXTERNAL-IP submariner-lighthouse-coredns ClusterIP 10.141.162.221 <none> submariner-operator-metrics ClusterIP 10.141.85.172 <none>
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent cluster1 cluster2 cluster2のGlobalNet宛ての通信 なので、VXLANトンネルを通って Gatewayノードへ curl 169.254.33.168 client Pod: 10.241.0.4 (169.254.18.25) target pod: 10.242.2.3 (169.254.32.40) target svc: 10.142.73.136 (169.254.33.168) GlobalNet: 169.254.0.0/19 GlobalNet: 169.254.32.0/19
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent cluster1 cluster2 cluster2のGlobalNet宛ての通信 なので、VXLANトンネルを通って Gatewayノードへ curl 169.254.33.168 client Pod: 10.241.0.4 (169.254.18.25) target pod: 10.242.2.3 (169.254.32.40) target svc: 10.142.73.136 (169.254.33.168) $ ip route show default via 192.168.241.1 dev eth0 10.241.0.0/16 dev weave proto kernel scope link src 10.241.0.1 169.254.0.0/16 dev eth0 scope link metric 1002 169.254.32.0/19 via 240.168.241.21 dev vx-submariner proto static 192.168.241.0/24 dev eth0 proto kernel scope link src 192.168.241.11 240.0.0.0/8 dev vx-submariner proto kernel scope link src 240.168.241.11 $ ip -d link show dev vx-submariner 15: vx-submariner: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqu DEFAULT group default link/ether 92:34:a2:38:15:ff brd ff:ff:ff:ff:ff:ff promiscuity 0 vxlan id 100 remote 192.168.241.21 srcport 0 0 dstport 4800 nolearni GlobalNet: 169.254.0.0/19 GlobalNet: 169.254.32.0/19 $ ip -4 addr show dev vx-submariner 13: vx-submariner: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN group default inet 240.168.241.21/8 brd 240.255.255.255 scope global vx-submariner valid_lft forever preferred_lft forever
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent cluster1 cluster2 ソースアドレスをPodのアドレス に対応するGlobal IPに変換し、 IPsecのXFRM Policyにした がってcluster2のGatewayノー ドへ curl 169.254.33.168 client Pod: 10.241.0.4 (169.254.18.25) target pod: 10.242.2.3 (169.254.32.40) target svc: 10.142.73.136 (169.254.33.168) GlobalNet: 169.254.0.0/19 GlobalNet: 169.254.32.0/19
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent cluster1 cluster2 IPsecのXFRM Policyにした がってcluster2のGatewayノー ドへ curl 169.254.33.168 client Pod: 10.241.0.4 (169.254.18.25) target pod: 10.242.2.3 (169.254.32.40) target svc: 10.142.73.136 (169.254.33.168) $ sudo ip xfrm policy <snip> src 169.254.0.0/19 dst 169.254.32.0/19 dir out priority 2087384 ptype main tmpl src 192.168.241.21 dst 192.168.242.21 proto esp reqid 16401 mode tunnel <snip> $ sudo ip xfrm state <snip> src 192.168.241.21 dst 192.168.242.21 proto esp spi 0x140a764a reqid 16401 mode tunnel replay-window 32 flag af-unspec aead rfc4106(gcm(aes)) 0x9f44344b333c80b5e9f62ff462cc380e981521f0cc2fb45e15017a562312a849be5f8235 128 anti-replay context: seq 0x0, oseq 0x12, bitmap 0x00000000 <snip> GlobalNet: 169.254.0.0/19 GlobalNet: 169.254.32.0/19 $ sudo iptables -S -t nat <snip> -A POSTROUTING -j SUBMARINER-POSTROUTING -A SUBMARINER-POSTROUTING -j SUBMARINER-GN-EGRESS -A SUBMARINER-GN-EGRESS -j SUBMARINER-GN-MARK -A SUBMARINER-GN-MARK -d 169.254.32.0/19 -j MARK --set-xmark 0xc0000/0xc0000 -A SUBMARINER-GN-EGRESS -s 10.241.0.4/32 -m mark --mark 0xc0000/0xc0000 -j SNAT --to-source 169.254.18.25 <snip>
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent cluster1 cluster2 curl 169.254.33.168 Gatewayノードのiptablesルー ルに従い、Serviceの ClusterIP→Podアドレスに DNATしてPodへ client Pod: 10.241.0.4 (169.254.18.25) target pod: 10.242.2.3 (169.254.32.40) target svc: 10.142.73.136 (169.254.33.168) GlobalNet: 169.254.0.0/19 GlobalNet: 169.254.32.0/19
Light House DNS Route Agent node1 client Light House DNS Route Agent gw2 Gate way Global Net Route Agent gw1 master1 etcd Gate way Global Net Route Agent node1 Light House Agent Light House DNS Route Agent node2 nginx Light House DNS Route Agent gw1 Global Net Gate way Route Agent gw2 kube dns api server master1 etcd Global Net Gate Way Route Agent cluster1 cluster2 戻りも同様 client Pod: 10.241.0.4 (169.254.18.25) target pod: 10.242.2.3 (169.254.32.40) target svc: 10.142.73.136 (169.254.33.168) GlobalNet: 169.254.0.0/19 GlobalNet: 169.254.32.0/19
cluster "kubernetes-admin@kubernetes": Discovered network details: Network plugin: weave-net Service CIDRs: [10.141.0.0/16] Cluster CIDRs: [10.241.0.0/16] Global CIDR: 169.254.0.0/19 CLUSTER ID ENDPOINT IP PUBLIC IP CABLE DRIVER TYPE site1 192.168.241.21 strongswan local site2 192.168.242.21 strongswan remote site1 192.168.241.22 strongswan local GATEWAY CLUSTER REMOTE IP CABLE DRIVER SUBNETS STATUS site2-gw1 site2 192.168.242.21 strongswan 169.254.32.0/19 connected NODE HA STATUS SUMMARY site1-gw1 active All connections (1) are established site1-gw2 passive There are no connections COMPONENT REPOSITORY VERSION submariner quay.io/submariner 0.6.1 submariner-operator quay.io/submariner 0.6.1 service-discovery quay.io/submariner 0.6.1
cluster "kubernetes-admin@kubernetes": Discovered network details: Network plugin: generic Service CIDRs: [10.142.0.0/16] Cluster CIDRs: [10.242.0.0/16] CLUSTER ID ENDPOINT IP PUBLIC IP CABLE DRIVER TYPE site2 192.168.242.21 strongswan local site1 192.168.241.21 strongswan remote site2 192.168.242.22 strongswan local GATEWAY CLUSTER REMOTE IP CABLE DRIVER SUBNETS STATUS site1-gw1 site1 192.168.241.21 strongswan 169.254.0.0/19 connected NODE HA STATUS SUMMARY site2-gw1 active All connections (1) are established site2-gw2 passive There are no connections COMPONENT REPOSITORY VERSION submariner quay.io/submariner 0.6.1 submariner-operator quay.io/submariner 0.6.1 service-discovery quay.io/submariner 0.6.1