hoeghh / kubernetes_the_easy_way

Automating Kubernetes the hard way with Vagrant and scripts
MIT License
20 stars 11 forks source link

Add load balancers to weave net network #28

Closed hoeghh closed 6 years ago

hoeghh commented 6 years ago

The load balancer(s) are not connected to the pod network, so it/they can't serve any traffic at all. Lb is connected to the API server so it does configure itself with all frot and backends.

We need to manually install weave net on load balancer(s). Before that, nothing will be served by ingress.

hoeghh commented 6 years ago

screenshot_20180329-175644

hoeghh commented 6 years ago

Testet this solution, and it works:

# Weave net status
kubectl exec -n kube-system weave-net-ks9mv -c weave -- /home/weave/weave --local status 

        Version: 2.2.1 (up to date; next check at 2018/03/29 22:03:27)

        Service: router
       Protocol: weave 1..2
           Name: aa:36:6b:7a:5d:61(k8s-worker-2)
     Encryption: disabled
  PeerDiscovery: enabled
        Targets: 2
    Connections: 2 (1 established, 1 failed)
          Peers: 2 (with 2 established connections)
 TrustedSubnets: none

        Service: ipam
         Status: ready
          Range: 20.0.0.0/16
  DefaultSubnet: 20.0.0.0/16

# Environment
192.168.50.4 k8s-loadbalancer
192.168.50.20 k8s-master
192.168.50.11 k8s-etcd-1
192.168.50.12 k8s-etcd-2
192.168.50.21 k8s-master-1
192.168.50.22 k8s-master-2
192.168.50.31 k8s-worker-1
192.168.50.32 k8s-worker-2
192.168.50.5 k8s-loadbalancer-1
192.168.50.6 k8s-loadbalancer-2

kubectl get pods -o wide
NAME                      READY     STATUS    RESTARTS   AGE       IP           NODE
nwtool-6cd6f6795d-sb9kj   1/1       Running   0          2m        20.0.0.2     k8s-worker-1
nwtool-6cd6f6795d-vmcxn   1/1       Running   0          2m        20.0.128.1   k8s-worker-2

# On loadbalancer machine
## Installing Weave net
curl -L git.io/weave -o /usr/local/bin/weave
chmod a+x /usr/local/bin/weave

## Installing Docker on Load balancer
dnf install dnf-plugins-core -y
dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
dnf config-manager --set-disabled docker-ce-edge
dnf install docker-ce -y
service docker start

## Launching Weave net on Load balancer
/usr/local/bin/weave launch --ipalloc-init observer 192.168.50.31 --ipalloc-range 20.0.0.0/16
/usr/local/bin/weave expose

## Testing connection to pod from Load balancer
curl 20.0.0.2

# Debugging on the Load balancer
/usr/local/bin/weave status connections
/usr/local/bin/weave status
hoeghh commented 6 years ago

Use something like this, to get the list of ip's of worker nodes.

cat /etc/hosts | grep worker | tr '\n' ' '

hoeghh commented 6 years ago

Closing with f187ff27002575c03eb6ecbb03ddc38044f132dd