Architecture Flashcards
What is cluster store?
If the apiserver is the brain of the master, that’s the memory of it. The config and the state of the cluster is persistently stored here. It uses etcd as Cluster Store
What is etcd?
etcd is a distributed key value store that provides a reliable way to store data across a cluster of machines.. KV store is a noSQL database. It’s distributed, consistent and watchable.
What is kube-scheduler?
This watches api-server for new pods and assigns work to nodes. It has to think about a lot of things like affiity/anti-affinity, constraints, resources etc.
What are nodes?
A.k.a. Minions. They are K8s workers. There are basically 3 components that we care about; kubelet, container runtime and the kube proxy.
What is Kubelet?
It is the main Kubernetes agent on Node and referred as Node. Registeres node with cluster. Watches the apiserver on master for work assignments. Any time it sees one, it carries out the task and reports back to master. Instantiates pods????? If the pod fails for some reason, it reports back to master and it does not try to restart it or find another node to run it. It’s masters responsibility to make decision at that point. It exposes and endpoint at localhost on port 10255 (it lets you inspect the spec of the Kubelet). /spec end point gives some info, /healthz for health check and /pods for running pods and much more.
What does Container Engine do?
It does container management like pulling images, starting/stopping containers, etc. It’s usually docker but its pluggable and can be rkt if one wants.
What is kube-proxy?
It’s networking brain of the node. It makes sure that every pod gets it unique id and all containers in a pod shares a single IP. It also makes load balancing. Load balances across all pods in a service. A service is a way to hide multiple nodes behind a single network address.
What is the model that K8s operates on?
It’s a declarative model. We give it a YAML or JSON manifest file where we describe how the app should look like. We do not give the commands needed for that. We just tell how we want it to look like. It’s up to K8s how to get there.
What happens when desired state and actual state diverges?
It should bring desired state back. It runs a lot of reconciliation loops that constantly checks the actual state matches the desired state.
What is a pod?
The atomic units of scheduling in VMs is the VM, Container in docker world and Pod in K8s. Containers always run inside of pods. Pods can have multiple containers.
What does a pod do and have?
It is a ring-fenced environment that runs containers. It has a network stack and kernel namespaces. It is also the unit of scaling.
How is the env arranged if more than one container are run inside a pod?
All containers in pod share the same environment. e.g. they have the same IP. If they want to talk each other there is localhost interface in there.
When should one use more than one container inside one pod?
If there are tightly coupled applications (e.g. 2 apps sharing the same DB, or a logging application(sidecar container) for a web server(main container)) we can put them together. But for loosely coupled apps no need for that. Also for scaling we should add more pods not more containers inside a pod.
How is the lifecycle of a pod?
They have 3 phases: pending, running, succeeded/failed. Once they die they can not be restarted back.
How do we deploy pods?
They are usually part of a bigger system but we can also deploy them alone by giving apiserver a manifest file. apiserver reads the file and deploys it to a suitable Node. They are usually deployed via higher level objects like Replication Controller.
Can we rely on pod IPs?
No. Each time a pod dies and a new one is created, it gets a new IP.
What are services?
Service is a Kubernetest obect just as Pod and Node. We define it inside yml file. E.g. we can set up an IP server between FE and db nodes to fix IP address and DNS. It can load balance requests among different pods.
How are services and pods tied?
The way that a pod belongs to a service is via labels. These labels tie services and pods. So if we give same labels that we give to normal pods to an irrelevant one, it will be load balanced through service as well. Also you can upgrade to a new version or return back to an older version by just changing labels on service.
What are basic properties of services?
- They only send requests to healthy pods
- They can be configured for session affinity
- They can point to things outside cluster
- They make random load balancing
- They use TCP by default