Skip to content

Instantly share code, notes, and snippets.

@nitrag nitrag/

Last active Mar 31, 2020
What would you like to do?
Ubuntu 18.04 - K8s install and join cluster
# Enable bridged traffic -
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
sysctl --system
# Enable IP Forward
echo "1" > /proc/sys/net/ipv4/ip_forward
# Disable Swap
swapoff -a
# Remove swap entry from /etc/fstab
# Install Docker
curl -fsSL | sh
# Change from using cGroup to daemon.
cat > /etc/docker/daemon.json <<EOF
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
"storage-driver": "overlay2"
mkdir -p /etc/systemd/system/docker.service.d
# Restart docker.
systemctl daemon-reload
systemctl restart docker
# Add k8s APT repo
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb kubernetes-xenial main
sudo apt-get update
# List k8s versions
curl -s | grep Version | awk '{print $2}'
# Install specific kubernetes version
sudo apt-get update -q && sudo apt-get install -qy kubelet=1.17.4-00 kubectl=1.17.4-00 kubeadm=1.17.4-00 --allow-downgrades
# On master, generate join command then run the output on the client node
kubeadm token generate
kubeadm token create <generated-token> --print-join-command
# TOKEN=$(kubeadm token generate); kubeadm token create $TOKEN --print-join-command
#### KUBECTL Client Setup
apiVersion: v1
- cluster:
certificate-authority-data: asdfasdfasdfasdfasdfasdfasdf
name: k8s-home
- context:
cluster: k8s-home
namespace: default
user: ryan
name: k8s-home-context
current-context: k8s-home-context
kind: Config
preferences: {}
- name: ryan
client-certificate: /.../.certs/ryan.crt
client-key: /.../.certs/ryan.key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.