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

Commit

Permalink
network: Add script to install weave net
Browse files Browse the repository at this point in the history
This commit removes the routes and adds a script to install
weave net as the overlay network for the cluster created this way.

Signed-off-by: Suraj Deshmukh <[email protected]>
  • Loading branch information
surajssd committed Nov 12, 2018
1 parent 43fa5b5 commit 683ca46
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 106 deletions.
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
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.

0 comments on commit 683ca46

Please sign in to comment.