Skip to content

Kubernetes Concepts

Some special features in Kubernetes environment:

  1. pods are often killed and respawned
  2. pods' IP are not fixed
  3. a group of pods will be load balanced, using a round robin mode. (In such DNS mode, a single hostname can be resolved into multiple IPs)
  4. kubernetes requires idempotence
  5. use random uid/gid by default
  6. In implementing probes, IO blocking may kill probes.
  7. Resource exhaustion will be more severe

StatefulSet Hostname

The hostnames take the form of <statefulset name>-<ordinal index>.

Service

A service object acts like an object in k8s networking. It helps find a pod and load balancing.

Finding a Pod

There are two ways of accessing a pod through the corresponding service:

  1. through service IP
  2. through service name and resolving it with kube-dns

Load Balancing

One service can do proxy for multiple pods. Therefore, a single DNS hostname can be resolved to multiple IPs.

Service type ClusterIP uses kube-proxy's iptables rules to distribute the requests roughly evenly in a round robin manner.

The documentation says:

By default, the choice of backend is round robin.

Although, the round robin distribution of requests may be affected by things like:

  1. Busy backends
  2. Sticky Sessions
  3. Connection-based (if a backend pod has established a TCP session or a secure tunnel with the user hitting the ClusterIP multiple times)
  4. Custom host-level / node-level iptables rules outside kubernetes

A service is kube-proxy plus iptables.

Research Papers

(HotCloud'16) Design patterns for container-based distributed systems

Borg, Omega, and Kubernetes