Skip to content

Instantly share code, notes, and snippets.

@rahulkrishnanfs
Last active January 9, 2018 18:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rahulkrishnanfs/1a1acc4f11e78309b218d5abde7f5196 to your computer and use it in GitHub Desktop.
Save rahulkrishnanfs/1a1acc4f11e78309b218d5abde7f5196 to your computer and use it in GitHub Desktop.
kubernetes installation using kubeadm
OS Required: Ubuntu 16 - xenial
Master node creation
---------------------------
The first step of initialising the cluster is to launch the master node.
The master is responsible for running the control plane components, etcd and the API server.
Step 1: (optional)
sysctl net.bridge.bridge-nf-call-iptables=1
Step2:
apt-get update && apt-get install -y apt-transport-https
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-get update
apt-get install -y kubelet kubeadm kubectl
apt-get install docker.io
apt-get install docker
systemctl start docker.service
systemctl status docker.service # check the status of the docker service
Step3: Creating a master node by initializing using kubeadm
kubeadm init --pod-network-cidr=10.244.0.0/16
Step4: To start using your cluster, you need to run (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
Step5: copy the join token to a text editor
#### IMPORTANT ####
|-------------------------------------------------------------|
| Check the output and copy the kubeadm join |
|-------------------------------------------------------------|
###################
Creation of a worker node
---------------------------
Step 1:(optional)
sysctl net.bridge.bridge-nf-call-iptables=1
Step2:
apt-get update && apt-get install -y apt-transport-https
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-get update
apt-get install -y kubelet kubeadm kubectl
apt-get install docker.io
apt-get install docker
systemctl start docker.service
systemctl status docker.service # check the status of the docker service
Step3: kubeadm join --token <token> <master-ip>:<master-port> --discovery-token-ca-cert-hash sha256:<hash>
At this point, the Nodes may not be ready. This is because the Container Network Interface has not been deployed.
This will fix in the next step
Network Creation using Flannel
--------------------------------------
Step 1: Enter into master node
Ste2: Check the status of the node using the following commands
Kubectl get nodes # Nodes will be showing NotReady due to the abscence of network creation settings
Step3:
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.0/Documentation/kube-flannel.yml
Step4: Check the status of the node using the following commands
Kubectl get nodes # Now the status of the node will be changed to Ready
|-------------------------------------------------------------------------------|
| Your Cluster is ready ..... Happy coding and deployment :-)) |
|-------------------------------------------------------------------------------|
For any doubts reachout to me
Follow me on Twitter for further updates:
https://twitter.com/rahulkrishnanra
@rahulkrishnanfs
Copy link
Author

Reset the cluster

sudo kubeadm reset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment