Kubernetes
► This course is sponsored by Kasten 🙌🏼 ► Free Kubernetes Backup and Migration - Download Kasten's K10 and Get 10 nodes free forever: https://www.kasten.io/nana
Orchestration
Basic elements
kubelet
is the piece of code in change to handle the communication between nodes. If this process goes down, then the node can be communicated with the others in the cluster.
Cluster Nodes
All the nodes together are shaping the kubernetes cluster:
master nodes
: at least two per cluster. One of them is a backup, to support the availability of the cluster if one master node goes down. The important infrastructure pieces are:api server
controller manager
- scheduler
worker nodes
: every node handles severalpods
. Every node has their owncpu and memory
assigment. The important infrastructure pieces arekubelet
andpods
Main kubernetes components
every pod
has their ip
. But the pods are ephemeris, so the pod can die, and another pod is replacing the previous. So the system setup a new ip for the new pod. So the communication between pods can rely into the ip
straightforward. To do that the pods are using the kubernetes services
. Pods communicates each of other using services
Main kubernetes components: services
The services
are not attached to the instance of the pod itself, are attached to the pod as something generic (as a class into the program world)
when the pods are running, we want to access to them outside the cluster, I mean, using a browser, cli or whatever. We can expose some services and others not.
Main kubernetes components: ingress
and we want to access using logical names instead ip's for instance. We need a domain name service DNS
to do achieve that.
this is what ingress
do for us:
Main kubernetes components: config map
The config is the kubernetes feature in charge to store env variables as url's. Something that can change over the time or similar.
Sometimes the database or service name changes. So we have to rebuild everything, push it to repo and deploy.
It's a problem. To avoid that we can use the config-map
. Use a var into your code, and this var is resolved into the cluster when the pod is deployed
Main kubernetes components: secrets
Secrets
are the same than `config map but encoded into base64. This is not secure, you have to use another solution to encrypt to your passwords o whatever
Main kubernetes components: volume
Sometimes we need persist our status. For doing that we need local or remote storage. The piece of infrastructure to achieve this is called `volume. Volume allows you to connect your pod to a source to storage/persist the status.
Main kubernetes components: deployment and statefulset
Deployment
is the piece of infrastructure is order to create/destroy as many pods as we want. If a pod dies, kubernetes starts another pod for you automatically, for instance. So the deployment
is the descriptor to do that. The pods don't have status, are stateless. So you can create/destroy as many pods as we want and the system remains the same, regarding status.
statefulset
is a deployment
but for databases with status. Take care with this feature, because it's hard or dificult handle database replicas inside a kubernetes cluster. So it's usually to handle the persistence into another external system.