k8s

Kubernetes Concept 8

k8s sharing

Posted by frankie on July 18, 2019

StatefulSets

Stateful sets are useful for stateful applications. Unlike deployments, stateful sets maintain a persistent identity for each pod. Each pod in a stateful set maintains a persistent identity and has an ordinal index with the relevant pod name, a stable hostname and stably identified persistent storage that is linked to the ordinal index.

Imgur

An ordinal index is just a unique sequential number that is assigned to each pod in the stateful set. This number defines the pods position in the sets sequence of pods.

Imgur

Imgur

Imgur

Stateful sets require a service to control their networking. Sometimes you may not want or need load balancing and a single service IP. In this case, a headless service is created by specifying none for the cluster IP in the service definition as shown here on the left.

Imgur

Imgur

Imgur

Imgur

ConfigMaps

ConfigMaps decouple configuration from Pods. This means that you don’t have to enter the same information across multiple parts specifications. This prevents config drift.

Imgur

Creating a ConfigMaps

  kubectl create configmap [NAME] [DATA]

Imgur

Imgur

Imgur

Imgur

Imgur

Imgur

Imgur

Imgur

Imgur

Each nodes Kubelet periodically syncs with ConfigMap to keep the ConfigMap volume updated. When a ConfigMap volume is already mounted and the source ConfigMap is changed, the projected keys are eventually updated. It is on the order of seconds or minutes. If you have a piece of configuration data that will change more rapidly than that, you should probably implement a micro-service to provide its value to Pods rather than using a ConfigMap.

Imgur

Secrets

Just like ConfigMaps, Secrets pass information to pods. Secrets let you manage sensitive information in their own control plane. Secrets also helped to ensure Kubernetes doesn’t accidentally output these data to logs.

Imgur

Imgur

Values are in base64 encoded strings.

Imgur

Imgur

Imgur

Imgur

Imgur