Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save magikcypress/8c1dacc8e44fb198dc942ca1342730e3 to your computer and use it in GitHub Desktop.
Save magikcypress/8c1dacc8e44fb198dc942ca1342730e3 to your computer and use it in GitHub Desktop.
Install K8S raspberry
#!/bin/bash
# Install Kubernetes for Raspberry Pi cluster
echo "Kube Init";
sudo kubeadm init --pod-network-cidr 10.244.0.0/16 --token-ttl 0
sleep 200
echo "Create hidden directory of kube";
mkdir -p $HOME/.kube;
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config;
sudo chown $(id -u):$(id -g) $HOME/.kube/config;
# Wired Patch
sudo chmod 644 /etc/kubernetes/admin.conf;
kubectl version
echo "Install Flannel";
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml;
sudo sed --in-place 's/0.3.1/0.2.0/g' /etc/cni/net.d/10-flannel.conflist
sleep 200;
kubectl get pods --all-namespaces;
sleep 10;
# Install helm
echo "Install helm";
rm -fr $HOME/.helm;
mkdir $HOME/helm;
cd $HOME/helm;
curl -LO https://git.io/get_helm.sh;
chmod 700 get_helm.sh;
./get_helm.sh -v v3.0.2;
helm init;
kubectl create serviceaccount --namespace kube-system tiller;
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller;
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}';
helm init --service-account tiller --upgrade;
helm version
sleep 30;
kubectl get pods --all-namespaces;
# Install Minecraft Server
echo "Install Minecraft Server";
cd $HOME/install-kube
kubectl apply -f minecraft.pv.yaml
kubectl apply -f minecraft.pvc.yaml
cd docker-minecraft
#docker run -d \
# -e EULA=true \
# -p 25565:25565 \
# -v /home/$user/minecraft-server:/minecraft-data/ \
# --name minecraft \
# rpi-minecraft
cd ../helmchart-minecraft/k8s-minecraft/
helm install --set name=Minecraft overworld .
# Install Traefik
cd ..
kubectl label node black-pearl2 nginx-controller=traefik
kubectl label node black-pearl3 nginx-controller=traefik
kubectl apply -f traefik-rbac.yaml
kubectl apply -f traefik-daemonset.yaml
# Install hypriot
kubectl run hypriot --image=hypriot/rpi-busybox-httpd --replicas=3 --port=80
kubectl expose deployment hypriot --port 80
kubectl get endpoints hypriot
kubectl apply -f hypriot-ingress.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment