What is Kubernetes?

An orchestration platform that places containers on a cluster of many machines (nodes), keeps their number, updates them and provides endpoints for them. Users declare a desired state with resources such as Deployments and Services, and controllers observe the actual state and bring it closer to the declaration (reconciliation). The smallest unit is the Pod; lost Pods are recreated automatically, and rolling updates and load-based autoscaling are supported. It is also abbreviated K8s.

Japanese name: Kubernetes

Kubernetes appears in 10 practice questions across 1 topic, including Cloud and Container Basics.

Field: Cloud and Container Basics

Main resources

A Pod is the smallest unit grouping containers, a ReplicaSet keeps the number of Pods, and a Deployment uses ReplicaSets to roll out new versions and roll back. A Service gives several Pods a stable name and address, and an Ingress routes HTTP requests from outside the cluster to Services by path or host name. ConfigMaps and Secrets pass configuration and confidential values separately from images, and namespaces divide a cluster by team or environment.

Declaration and reconciliation

Users declare a state such as "run three Pods of this version" in YAML or similar and register it with Kubernetes. Controllers repeatedly check the actual state, creating Pods that disappear and removing extra ones. Because the result rather than the steps is declared, applying the same definition any number of times settles in the same state, and the system recovers automatically from node failures.

Resource settings and probes

Each container specifies the CPU and memory it wants reserved (requests) and its upper limits (limits), and the scheduler chooses a node for each Pod based on requests. A readiness probe checks whether a container can accept requests and controls routing, and a liveness probe has a container that stopped responding restarted. A HorizontalPodAutoscaler changes the number of Pods based on metrics such as utilization relative to requests.

Try it: questions about Kubernetes

In Kubernetes, which of the following is the smallest unit that is deployed and managed, grouping one or more containers that share the same IP address and volumes?

  1. ANode
  2. BService
  3. CPod
Show answer and explanation

Answer: C. Pod

A Pod is the smallest unit Kubernetes places and runs. The containers in it share a network namespace, so they can talk to each other over localhost and can use the same volumes. Usually one Pod holds one application container, and helper containers, for example for forwarding logs, are sometimes added to the same Pod. Pods are disposable and get a new IP address when recreated, so they are normally managed indirectly through a Deployment or similar. A node is a machine on which Pods run, and a Service is a stable endpoint for several Pods.

In Kubernetes, a Deployment with replicas: 3 is running three Pods. Which of the following correctly describes what happens when one of these Pods is deleted with kubectl delete pod?

  1. AThe Deployment's setting is also rewritten to replicas: 2, and two Pods keep running
  2. BA controller detects that the actual number has fallen below the specified 3 and creates one new Pod
  3. CThe other two Pods of the Deployment are also deleted, and the whole Deployment stops
Show answer and explanation

Answer: B. A controller detects that the actual number has fallen below the specified 3 and creates one new Pod

In Kubernetes, users declare a desired state such as "run three Pods", and controllers repeatedly observe the actual state and act to bring it closer to the declaration when they differ (reconciliation). Deleting one Pod makes the actual number 2, so the ReplicaSet controller creates a new Pod to return to 3. When a Pod is lost because a node fails, the same mechanism recreates it on another node. To really reduce the number of Pods, change the Deployment's replicas instead of deleting Pods.

FAQ

What is the difference between Docker and Kubernetes?

Docker is mainly a tool for building images and running containers on one machine. Kubernetes is a platform that manages, across many machines, which node runs what, how many copies run and how they are updated. Kubernetes runs containers from standard-format images built with Docker or other tools.

Should even a small system use Kubernetes?

Not necessarily. Kubernetes is strong at high availability, automatic recovery and managing many services, but operating a cluster takes knowledge and effort. For a small system, running containers on a single machine or using a managed container service in the cloud may suit better.

Kubernetes in the explanations

Questions that mention Kubernetes (10)

  1. In Kubernetes, which of the following is the smallest unit that is deployed and managed, grouping one or more containers that share the same IP address and volumes?
  2. In Kubernetes, a Deployment with replicas: 3 is running three Pods. Which of the following correctly describes what happens when one of these Pods is deleted with kubectl delete pod?
  3. In a Kubernetes Deployment, the container image in the Pod template is changed to a new version. Which of the following correctly describes what happens with the default update strategy (RollingUpdate)?
  4. In Kubernetes, a Pod gets a different IP address every time it is recreated. Which of the following resources lets other applications connect, through a name and address that do not change, to several Pods selected by labels, with the load spread across them?
  5. In a Kubernetes cluster, HTTPS requests arriving for one host name should be routed to the api Service if the path begins with /api, and to the web Service otherwise. Which of the following resources is suitable for defining this routing rule?
  6. A database password is stored in a Kubernetes Secret. Which of the following correctly describes a Secret?
  7. In a web application on Kubernetes, the check performed by the liveness probe was made to include whether the application can connect to the database it depends on. Which of the following is the most likely problem with this setting?
  8. A Kubernetes HorizontalPodAutoscaler has a target CPU utilization of 70% and a range of 1 to 10 Pods. Currently the average CPU utilization of 5 Pods is 30%. When the required number of Pods is computed as ⌈current number × current utilization ÷ target utilization⌉ (⌈ ⌉ means rounding up), which of the following is the required number of Pods?
  9. In Kubernetes, which of the following correctly describes the resource requests and limits set for a container?
  10. As shown above, the database connection target is not written into the image but passed as an environment variable when the container starts. Which of the following is the most appropriate main advantage of this design?

Books on Cloud and Container Basics Ad

As an Amazon Associate I earn from qualifying purchases.

Related terms

Pod Container Environment variable Container image DNS (Domain Name System) HTTP (Hypertext Transfer Protocol) TLS Reverse proxy Deadlock Autoscaling

Back to the glossary