What is Kubernetes

Kubernetes is a popular container orchestrator (an orchestrator’s job is to make many servers act like one). It runs on top of Docker (usually) as a set of APIs in containers.

Terminologies

  • Kubernetes: The whole orchestration system.
  • Kubectl: CLI to configure Kubernetes and manage apps.
  • Node: Single server in the Kubernetes cluster.
  • Kubelet: Kubernetes agent running on nodes, which talks to docker containers and communicates back to master.
  • Control Plane: Set of containers that manages the cluster.
  • Pod: One or more containers running together on one Node.
  • Controller: For creating/updating pods and other objects.
  • Service: network endpoint to connect to a pod.
  • Namespace: Filtered group of objects in cluster.

Pod is the basic unit of deployment in Kubernetes, Containers are always in pods. There are many types of controllers (e.g., Deployment, ReplicaSet, StatefulSet, DaemonSet, Job, CronJob, etc.)

Intro

Use kubectl run <DEPLOYMENT_NAME> --image <IMAGE_NAME> to create a deployment.

$ kubectl run my-nginx --image nginx
# deployment.apps/my-nginx created

$ kubectl get pods
# NAME                       READY   STATUS    RESTARTS   AGE
# my-nginx-948577f65-hg7wx   1/1     Running   0          33s

$ kubectl delete deployment my-nginx
# deployment.extensions "my-nginx" deleted

Containers live in a Pod, Pods live in a ReplicaSet, and a ReplicaSet lives in a Deployment.

$ kubectl run my-apache --image httpd
# deployment.apps/my-apache created

$ kubectl scale deploy/my-apache --replicas 2
# deployment.extensions/my-apache scaled
# Or: kubectl scale deployment my-apache --replicas 2

$ kubectl logs deployment/my-apache
# Found 2 pods, using pod/my-apache-6b4dc47d85-ckxr4
# log for one of the Pods...