On the Master run the following commands. They will install the prereqs for Kubernetes
sudo su -
# Enable Docker
systemctl enable docker && systemctl start docker
# Install Networking Plugins
CNI_VERSION="v0.7.1"
mkdir -p /opt/cni/bin
curl -L "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-amd64-${CNI_VERSION}.tgz" | tar -C /opt/cni/bin -xz
# Install Container Runtime
CRI_VERSION="v1.11.1"
mkdir -p /opt/bin
curl -L "https://github.com/kubernetes-incubator/cri-tools/releases/download/${CRI_VERSION}/crictl-${CRI_VERSION}-linux-amd64.tar.gz" | tar -C /opt/bin -xz
# Install the Kubernetes components
RELEASE="$(curl -sSL https://dl.k8s.io/release/stable.txt)"
mkdir -p /opt/bin
cd /opt/bin
curl -L --remote-name-all https://storage.googleapis.com/kubernetes-release/release/${RELEASE}/bin/linux/amd64/{kubeadm,kubelet,kubectl}
chmod +x {kubeadm,kubelet,kubectl}
# Create a few directories needed for operation
/bin/mkdir -p /var/lib/rook /var/lib/kubelet/volumeplugins /etc/kubernetes/manifests
# Enable volumeplugins in Kubelet for Rook
echo "KUBELET_EXTRA_ARGS=--volume-plugin-dir=/var/lib/kubelet/volumeplugins" > /etc/default/kubelet
# Download and install the systemd configs
curl -sSL "https://raw.githubusercontent.com/kubernetes/kubernetes/${RELEASE}/build/debs/kubelet.service" | sed "s:/usr/bin:/opt/bin:g" > /etc/systemd/system/kubelet.service
mkdir -p /etc/systemd/system/kubelet.service.d
curl -sSL "https://raw.githubusercontent.com/kubernetes/kubernetes/${RELEASE}/build/debs/10-kubeadm.conf" | sed "s:/usr/bin:/opt/bin:g" > /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
# Enable systemd
systemctl enable kubelet.service
The following command finds the internal IP. The external ip will need to be populated in the kubeadm command.
priv_ip=$(ip -f inet -o addr show eth0|cut -d\ -f 7 | cut -d/ -f 1 | head -n 1)
/opt/bin/kubeadm init --apiserver-advertise-address=$priv_ip --pod-network-cidr=192.168.0.0/16 --feature-gates Auditing=true --apiserver-cert-extra-sans <external ip>
Make note of the kubeadm join command at the end of the installation as it is used on the workers.
Copy the kubeconfig to core user:
mkdir -p $HOME/.kube
sudo cp -f /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl apply -f https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/rbac-kdd.yaml
kubectl apply -f https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubernetes-datastore/calico-networking/1.7/calico.yaml
scp core@<external ip>:~/.kube/config ~/.kube/config-new
Alternatively if a kubeconfig already exists then the config can either be added to the yaml or be downloaded to another file (eg $HOME/.kube/config-new) and kubectl commands updated with --kubeconfig <newconf> (note: other tools like helm will need to be adjusted too)