ref https://github.com/codesqueak/k18srpi4
- Date: Oct 2019
- Operating System: Raspbian Buster
- Kernel: 4.19
Follow notes at:
read -p "Name your Raspberry Pi (eg k8smaster, k8snode1, ...): " RPINAME && \
sudo raspi-config nonint do_hostname $RPINAME && \
sudo apt update && sudo apt upgrade -y && sudo reboot
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy && \
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
iptables -V
returns iptables v1.8.2 (legacy)
- Disable Swap Required for Kubernetes on Raspberry Pi
- Optimise Memory If using Raspberry Pi Lite (Headless) you can reduce the memory split between the GPU and the rest of the system down to 16mb.
- Enable cgroups Append cgroup_enable=cpuset cgroup_enable=memory to the end of the line of /boot/cmdline.txt file.
sudo dphys-swapfile swapoff && \
sudo dphys-swapfile uninstall && \
sudo systemctl disable dphys-swapfile && \
echo "gpu_mem=16" | sudo tee -a /boot/config.txt && \
sudo sed -i 's/$/ ipv6.disable=1 cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1/' /boot/cmdline.txt
curl -sSL get.docker.com | sh && sudo usermod $USER -aG docker && sudo reboot
Copy the next complete block of commands and paste in to the Raspberry Pi Terminal.
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list && \
sudo apt-get update -q && \
sudo apt-get install -qy kubeadm && \
sudo reboot
Optional, but useful as you can see th images being pulled. If you don't do here the images will be pulled by Kubeadmin init.
kubeadm config images pull
Follow the next section to install the Kubernetes Master, else skip to Kuberntes Node Set Up
sudo kubeadm init --apiserver-advertise-address=192.168.100.1 --pod-network-cidr=10.244.0.0/16 --token-ttl 0
Notes:
- For flannel to work, you must pass --pod-network-cidr=10.244.0.0/16 to kubeadm init.
- Using a --token-ttl 0 is not recommended for production environments. It's fine and simplifies a development/test environment.
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Creating a single control-plane cluster with kubeadm
sudo sysctl net.bridge.bridge-nf-call-iptables=1 && \
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml
When the kubeadm init command completes you need to take a note of the token. You use this command to join a node to the kubernetes master.
sudo sysctl net.bridge.bridge-nf-call-iptables=1
sudo kubeadm join 192.168.2.1:6443 --token ......
sudo kubeadm reset && \
sudo systemctl daemon-reload && \
sudo systemctl restart kubelet.service
kubectl get pods --namespace=kube-system -o wide
kubectl get nodes
for i in range{1..1000}; do date; kubectl get pods --namespace=kube-system -o wide;sleep 5; done;
kubectl taint nodes --all node-role.kubernetes.io/master-
On your Kubernetes Master
Create a file called ” dashboard-admin.yaml “ with the following content:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kubernetes-dashboard
labels:
k8s-app: kubernetes-dashboard
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: kubernetes-dashboard
namespace: kube-system
then run
kubectl create -f dashboard-admin.yaml
ssh -f -N -L 8080:10.101.166.227:80 [email protected]
http://kamilslab.com/2016/12/17/how-to-set-up-ssh-keys-on-the-raspberry-pi/
ssh-copy-id username@remote_host
for i in {1..1000000}; do curl http://192.168.0.142:8002/api/values; echo $i; done
nslookup netcoreapi.default.svc.cluster.local
docker build -t netcoreapi .
docker tag netcoreapi glovebox/netcoreapi:v002
docker push glovebox/netcoreapi:v002
Interactive Tutorial - Updating Your App
kubectl set image deployments/netcoreapi-deployment netcoreapi=glovebox/netcoreapi:v002
https://hub.docker.com/r/hypriot/rpi-mysql/
https://blog.alexellis.io/test-drive-k3s-on-raspberry-pi/
https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2019-04-09/
https://www.syncfusion.com/ebooks/using-netcore-docker-and-kubernetes-succinctly
function.yml https://github.com/teamserverless/k8s-on-raspbian/blob/master/GUIDE.md
1 How to Setup Raspberry Pi NFS Server 2 Building an ARM Kubernetes Cluster 3 kubernetes-incubator/external-storage 4 Persistent Volumes