I have started understanding Kubernetes aka k8s as part of my work recently and went through some learning. I will share some high level notes which I have made while reading through different content and also the links to resources for a quick getting started.
- Good to have a high level understanding of containers (Docker etc)
- Kubernetes tutorial – this is the first link I went through to get a very high level overview of what Kubernetes is and how do we go about using different commands on the k8s cluster.
- Scalable Microservices with Kubernetes – this is a very good course on Udacity which gives very good overview. This same course is referenced from the above tutorial.
- Using Visual Studio Team Service to deploy applications to Azure Container Service – This blog talks about using VSTS Release Management solution to automate deployments to K8S
- In simple terms you can consider k8s as a platform for containers cluster management.
- A k8s cluster has a master node – which manages the cluster and a set of other nodes – which are workers that run the applications. For a production traffic scenario, k8s cluster should have atleast 3 nodes
- Key terms in k8s – Deployment, Pods, Volumes, Services, kubelet, ConfigMaps/Secrets etc
- minikube is a light weight k8s implementation that creates a VM on local machine and deploys a simple cluster with one node.
- While following the Hello Minukube section on windows, you can run “minikube docker-env” instead of “eval $(minikube docker-env)“. Once the “minikube docker-env” command is executed it prints a message with the subsequent command (a for loop) to be run to set certain variables, ensure to run that step
- kubectl commands are used for all the cluster management
Lets understand the key terms:
- is a declarative way to say what goes where in the cluster
- use ReplicaSets to maintain enough number of Pods as the desired config state
- used to enforce the desired state as provided by the user
- if a node goes down, deployment takes care of creating a new pod and place it into the available nodes
- create a ReplicaSet to handle pod creation/deletion/updation
- own and manage ReplicaSets
- Logical Applications
- each pod has one more containers. When you have apps that have hard dependency on one another, you package them to the same pod
- Shares volumes. Volumes live as long as the pod lives
- has a shared namespace – help in containers to communicate with each other
- each pod has one IP address
- containers in a pod can communicate with each other using inter-process communication (IPC). Containers in different pods have different IPs, hence can’t communicate using IPC
- Why Pods?
- you can consider them as shared storage
- each node has a kubelet
- manages the pod and containers running on it
- its an agent which helps the nodes to talk to master
- defines logical set of pods and policy by which to access them
- provide persistent endpoints for pods
- enable loose coupling between pods
- are defined using YAML/JSON
- set of pods targeted by a service is determined by label selector
- pod’s IPs are not exposed out of cluster without service
- services have a integrated load balancer to distribute network traffic to all pods
- you can expose you pods/containers using “kubectl expose” command
- While creating the service following the “Hello Minikube” Section, set the type as NodePort in case the LoadBalancer type doesn’t work.
Kubernetes is very actively worked on and many things are rapidly changing. There is an interesting talk from Deis (PaaS on Kubernetes), in which it is mentioned that in CNCF “Kubernetes has been offered as a seed technology” – this also signifies that k8s is a good technology to invest your time to learn.