Kuberetes Master + Minion on Ubuntu box

It’s been a while since I’ve touched k8s and heard recently deployment got a lot easier then what I had been working with for the past few years with Apcera… so I had a go. I had two clusters up and running within the space of an afternoon, probably goes much faster with familiarity, but setting up on some hosts in my own lab versus playing with AWS or GCE. The setup on Ubuntu was relatively easy, but I’m currently working on a CentOS version of this process and it’s got some tweaks and permissions to set or unset.

I remember spending 3-5 minutes trying to explain the ‘cera platform to friends, family, etc… I think the same short statement applies to Kubernetes: The purpose of Kubernetes is to make it easier to organize and schedule your application across a fleet of machines. At a high level it is an operating system for your cluster.

Kubernetes Master Node on Ubuntu Install from scratch: 

First install ubuntu 16.04, and do a little prep work up front, do apt-get update/upgrade and make sure you’re current.

Note, in ubuntu you need to unlock root password to proceed with some of these activities:

 sudo passwd -u root 

Also, You may need to turn off swap as it usually is on by default:

swapoff -a

Start by first installing docker:

apt install -y docker.io

Add the GPG apt key for the source

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add

Add the repo to the list of apt sources

cat << EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF

Then update

apt-update

Make sure kubelet and docker daemon use systemd natively

cat << EOF >/etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver=systemd"]
}
EOF

Then we need to install the Kubernetes components

apt install -y kubelet kubeadm kubectl

Init the orchestrator, and using flannel we call out the cider block for the network pod

See: https://github.com/coreos/flannel#flannel

kubeadm init --pod-network-cidr=10.244.0.0/16

Some information will be key to collect as you will have a few copy/psate lines to create a user then deploy a “pod” network to your cluster, and a token call to kubeadm —join which will set subsequent nodes up for your cluster == workers.
In this current case we have form the common line output:

Your Kubernetes master has initialized successfully!
To start using your cluster, you need to run the following as a regular user:
  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config
You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/
You can now join any number of machines by running the following on each node
as root:
  kubeadm join --token <<tokenID.token>> 192.168.1.66:6443 --discovery-token-ca-cert-hash sha256:<<TOKEN>>

Start Flannel CNI on the master node

sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml

Check status

kubectl get pods —all-namespaces

Creating worker nodes on Ubuntu from Scratch

apt install -y docker.io
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add
cat << EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-update

Make sure kubelet and docker daemon use systemd natively

cat << EOF >/etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver=systemd"]
}
EOF

Add the GPG key for the source

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add
apt install -y kubelet kubeadm kubectl

Paste in kubeadmin —join to worker(s)