Skip to content

Instantly share code, notes, and snippets.

@dracan
Last active May 10, 2019 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dracan/9c116a56ef08284d820064e9a208bca1 to your computer and use it in GitHub Desktop.
Save dracan/9c116a56ef08284d820064e9a208bca1 to your computer and use it in GitHub Desktop.
Install Kubernetes
#!/bin/bash
# Pre-pull the requisites Docker images needed to run a Kubernetes master
kubeadm config images pull -v3
# Init master node
kubeadm init --token-ttl=0 --pod-network-cidr=10.244.0.0/16 # This uses the Flannel pod network addon
# Setup local access to the cluster via the kubectl command
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
# Install the pod network-addon
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
#!/bin/sh
# Install Docker
curl -sSL get.docker.com | sh && \
sudo usermod pi -aG docker
# Disable swap (needs to be off for Kubernetes)
sudo dphys-swapfile swapoff && \
sudo dphys-swapfile uninstall && \
sudo update-rc.d dphys-swapfile remove
# Install Kubeadm
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
# Enable cgroups
echo Adding " cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory" to /boot/cmdline.txt
sudo cp /boot/cmdline.txt /boot/cmdline_backup.txt
orig="$(head -n1 /boot/cmdline.txt) cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory"
echo $orig | sudo tee /boot/cmdline.txt
# Required for the Flannel network-addon
sysctl net.bridge.bridge-nf-call-iptables=1
echo Please reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment