Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

[WIP] network: Add script to install weave net #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ The setup follows https://github.com/kelseyhightower/kubernetes-the-hard-way
with the following exceptions:

* `cri-o` is used as a container runtime, not `cri-containerd`
* The `pod-cidr` is `10.2${i}.0.0/16`, routes are provisioned from
`scripts/vagrant-setup-routes.bash` automatically
* For `crio`, an explicit `--stream-address` must be set, as the address
of the default interface isn't routable (see e.g. [`config/worker-0-crio.service`](config/worker-0-crio.service))
* `192.168.199.40` is the IP of the loadbalancer (haproxy) for HA controllers
Expand All @@ -27,9 +25,6 @@ To learn Kubernetes from the bottom up, it's recommended to go through
KTHW manually. `vagrant up` gives you three controller and three worker
nodes to do that.

The `pod-cidr` is `10.2${i}.0.0/16`, for which the Vagrant nodes have
configured routes (see `route -n`).

The following KTHW parts can/should be skipped:

* Everything in regard to the frontend loadbalancer
Expand Down Expand Up @@ -155,6 +150,23 @@ kubectl get nodes
[...]
```

Install overlay network so pods on different nodes can connect with each other,
by running following command:

```bash
./scripts/setup-networking
```

Now verify that the weave pods are all up and running, using following command:

```console
$ kubectl -n kube-system get pods -l name=weave-net
NAME READY STATUS RESTARTS AGE
weave-net-24wdp 2/2 Running 0 8m
weave-net-bnxl6 2/2 Running 0 8m
weave-net-jh9nx 2/2 Running 0 8m
```

## Using the cluster

### Setup DNS add-on
Expand Down
3 changes: 0 additions & 3 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,12 @@ Vagrant.configure("2") do |config|
c.vm.hostname = "worker-#{n}"
c.vm.network "private_network", ip: "192.168.199.2#{n}"

c.vm.provision :shell, :path => "scripts/vagrant-setup-routes.bash"
c.vm.provision :shell, :path => "scripts/vagrant-setup-hosts-file.bash"
end
end

config.vm.define "traefik-0", autostart: false do |c|
c.vm.hostname = "traefik-0"
c.vm.network "private_network", ip: "192.168.199.30"

c.vm.provision :shell, :path => "scripts/vagrant-setup-routes.bash"
end
end
15 changes: 0 additions & 15 deletions config/worker-0-10-bridge.conf

This file was deleted.

1 change: 0 additions & 1 deletion config/worker-0-kubelet-config
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ authorization:
clusterDomain: "cluster.local"
clusterDNS:
- "10.32.0.10"
podCIDR: "10.20.0.0/16"
resolvConf: "/run/systemd/resolve/resolv.conf"
runtimeRequestTimeout: "10m"
tlsCertFile: "/var/lib/kubelet/worker-0.pem"
Expand Down
15 changes: 0 additions & 15 deletions config/worker-1-10-bridge.conf

This file was deleted.

1 change: 0 additions & 1 deletion config/worker-1-kubelet-config
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ authorization:
clusterDomain: "cluster.local"
clusterDNS:
- "10.32.0.10"
podCIDR: "10.21.0.0/16"
resolvConf: "/run/systemd/resolve/resolv.conf"
runtimeRequestTimeout: "10m"
tlsCertFile: "/var/lib/kubelet/worker-1.pem"
Expand Down
15 changes: 0 additions & 15 deletions config/worker-2-10-bridge.conf

This file was deleted.

1 change: 0 additions & 1 deletion config/worker-2-kubelet-config
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ authorization:
clusterDomain: "cluster.local"
clusterDNS:
- "10.32.0.10"
podCIDR: "10.22.0.0/16"
resolvConf: "/run/systemd/resolve/resolv.conf"
runtimeRequestTimeout: "10m"
tlsCertFile: "/var/lib/kubelet/worker-2.pem"
Expand Down
25 changes: 0 additions & 25 deletions scripts/generate-cni-config

This file was deleted.

1 change: 0 additions & 1 deletion scripts/generate-kubelet-config-file
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ authorization:
clusterDomain: "cluster.local"
clusterDNS:
- "10.32.0.10"
podCIDR: "10.2${i}.0.0/16"
resolvConf: "/run/systemd/resolve/resolv.conf"
runtimeRequestTimeout: "10m"
tlsCertFile: "/var/lib/kubelet/worker-${i}.pem"
Expand Down
1 change: 1 addition & 0 deletions scripts/setup
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ vagrant up
./scripts/setup-kubelet-api-cluster-role
./scripts/setup-worker-services
./scripts/configure-kubectl-on-host
./scripts/setup-networking
echo -e "\033[1mFinished. Cluster should be healthy and soon in state ready:\033[0m"
kubectl get componentstatuses
kubectl get nodes
6 changes: 6 additions & 0 deletions scripts/setup-networking
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -euo pipefail

# As mentioned in https://www.weave.works/docs/net/latest/kubernetes/kube-addon/#install
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to set net.ipv4.ip_forward=1 to be able to reach nginx via host port from my host (as done in the smoke test), e.g. curl 192.168.199.20:30991. That's also mentioned in the install docs as a requirement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add scripts/setup-networking to the instructions in the README.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@schu done!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kubectl apply -f https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')
1 change: 0 additions & 1 deletion scripts/setup-worker-services
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ cp /vagrant/tools/{conmon,pause} /usr/local/libexec/crio/
cp /vagrant/tools/{crio.conf,seccomp.json} /etc/crio/
cp /vagrant/tools/policy.json /etc/containers/

cp "/vagrant/config/$(hostname)-10-bridge.conf" /etc/cni/net.d/10-bridge.conf
cp /vagrant/config/99-loopback.conf /etc/cni/net.d
cp "/vagrant/config/$(hostname)-crio.service" /etc/systemd/system/crio.service

Expand Down
3 changes: 3 additions & 0 deletions scripts/vagrant-setup-hosts-file.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ cat <<EOF | sudo tee -a /etc/hosts
192.168.199.21 worker-1
192.168.199.22 worker-2
EOF

# Make sure all the nodes do port forwarding
sudo sysctl -w net.ipv4.ip_forward=1
23 changes: 0 additions & 23 deletions scripts/vagrant-setup-routes.bash

This file was deleted.