examples of files that etcd holds in kubernetes?

2/6/2021

I'm kinda new to Kubernetes and I would like to know which kind of configuration/state/metadata files etcd cluster holds? didn't find any examples on that. just general explanation.

Thanks :)

-- El so
azure-aks
kubernetes

1 Answer

2/6/2021

which kind of configuration/state/metadata files etcd cluster holds?

Etcd is the database for Kubernetes, so it essentially store all configuration/state/metadata that you have in your cluster.

How Kubernetes works

Kubernetes is an eventual consistency system.

  1. When you want to create something in the cluster, you save the configuration in for your desired state - the state that you want to achieve.
  2. Kubernetes has controllers, that regularly (or on change) check what desired state is stored, then checks the current state - if there is a mismatch, the controller will try to make it to the desired state.

Example

There is no app in the cluster. Now you want to deploy an app that you have created.

  1. You create a Deployment-manifest in the cluster with the image for your app.
  2. Controllers in the cluster will detect what you want, it also see that the app is not in the cluster. The controllers now have to achieve the state you asked for, by e.g. scheduling the instances to nodes, the nodes then need to pull the image from a registry and then start the app (Pod).
  3. Controllers continuously maintain the desired state. If your app crashes, the controllers again need to work to achieve the desired state, and create a new instance (Pod).

Resources in etcd

In the above example, you created an resource, a Deployment that is stored in etcd. But also all the controllers also create resources, e.g. ReplicaSet and Pod when you created your Deployment.

Separation of Concern

When you created the Deployment-manifest, you wrote some metadata and then a spec: - this is the desired state. The controllers write its state in status: and you can inspect this with e.g. kubectl get deployment my-app -o yaml and you will see if the controllers have written any issues or that the condition is Running.

-- Jonas
Source: StackOverflow