Skip to content

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

container_setup_scripts

Scripts to set up Docker and bootstrap a Kubernetes cluster on Ubuntu.

Run scripts as a standard (non-root) user. sudo is invoked internally where needed.

Docker

Install Docker Engine, CLI, containerd, Buildx, and Compose:

bash docker/install-docker.sh

verify the installation by running the hello-world image:

docker run --rm hello-world

Docker References

Kubernetes

Bootstrap a Kubernetes 1.35.0 cluster using kubeadm, containerd, and Calico v3.31.4.

The cluster uses 172.16.0.0/16 for pod addresses; choose a CIDR that does not overlap node, Service, VPN, or corporate networks before changing it.

1. Every node

Installs containerd, kubeadm, kubelet, and kubectl:

bash kubernetes/common-setup.sh

2. Control plane only

Initialises the cluster and installs Calico, then prints the worker join command:

bash kubernetes/control-plane-init.sh

3. Each worker node

After running common setup, join using the command printed in step 2:

sudo kubeadm join <control-plane-ip>:6443 --token <token> --discovery-token-ca-cert-hash sha256:<hash>

Then, from the control plane, label the node so it appears as a worker in kubectl get nodes:

kubectl label node <worker-machine-name> node-role.kubernetes.io/worker=worker

4. Verify the cluster

Check that all nodes are Ready and system pods are running:

kubectl get nodes
kubectl get pods -A

5. Smoke test — nginx

Deploy

kubectl apply -f kubernetes/nginx.yaml
kubectl rollout status deployment/nginx

Test

Once the rollout is complete, confirm the pod is running and hit nginx on port 30080 of any node:

kubectl get pods
curl http://<any-node-ip>:30080

You should receive the nginx welcome page HTML.

Tear down

kubectl delete -f kubernetes/nginx.yaml

6. Tear down the entire cluster

Run the worker-node steps first. Run the control-plane steps last. These commands remove the Kubernetes cluster state and Calico CNI state, but leave the installed packages and containerd in place so the cluster can be bootstrapped again.

Each worker node

From the control plane, optionally drain each worker before resetting it:

kubectl drain <worker-machine-name> --ignore-daemonsets --delete-emptydir-data

Then, on that worker node:

sudo kubeadm reset --force
sudo rm -rf /etc/cni/net.d
sudo ip link delete vxlan.calico 2>/dev/null || true
sudo ip link delete tunl0 2>/dev/null || true
for iface in $(ip -o link show | awk -F': ' '$2 ~ /^cali/ {sub(/@.*/, "", $2); print $2}'); do
	sudo ip link delete "$iface" 2>/dev/null || true
done

Control-plane node

After every worker has been reset, run the following on the control-plane node:

sudo kubeadm reset --force
sudo rm -rf /etc/cni/net.d
sudo ip link delete vxlan.calico 2>/dev/null || true
sudo ip link delete tunl0 2>/dev/null || true
for iface in $(ip -o link show | awk -F': ' '$2 ~ /^cali/ {sub(/@.*/, "", $2); print $2}'); do
	sudo ip link delete "$iface" 2>/dev/null || true
done
rm -rf "$HOME/.kube"

If this machine will no longer manage the cluster, remove the local Calico manifest downloaded by the bootstrap script as well:

rm -f custom-resources.yaml

kubeadm reset does not remove kubeconfig files, CNI configuration, or network interfaces. The extra cleanup is needed before recreating this Calico-based cluster, especially when changing the pod network CIDR.

Kubernetes References

TODOs

Other Components

Secure Local Registry

See registry/README.md.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages