Architecture Flashcards
What is Kubernetes basically?
An orchestrator for microservice apps
What is a microservice app?
It is a name for an application that’s made up of lots of small and independent services.
How does Kubernetes basically works?
It organizes things so that they work on the right networks with the right secrets. That is called orchestration.
How does a typical K8s cluster look like?
It has masters and nodes. Masters are in charge and decide which node does what. Nodes do the work.
How do we package code for Kubernetes?
We have Kubernetes deployment where we define the process inside a yml file. It tells K8s how our app should like e.g. ports, how many replicas. We give the file to master in Kubernetes and it deploys the app on the cluster
Describe the platform agnostic property of K8s
It is platform agnostic. It runs on Linux but it is not interested on which platform this Linux runs; bare metal or VM etc.
How is master structured?
It’s a bunch of moving parts. They all run on a single server. We don’t run user workloads on master, it orchestrates nodes.
What is kube-apiserver (apiserver)?
It is the front-end to the control plane. It’s the only master component that we should be talking to so also known/called as master. It exposes a RESTful API and it consumes JSON. By default it exposes on port 443
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-controller-manager?
It’s the controller of controllers. At the moment it implements some features like Node controller, Endpoints controller, Namespace controller. These controllers watch for changes and help maintain desired state. They are all controlled by controller manager.
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.