What is Kubernetes
It's a container orchestration tool, developed by Google. It helps you manage containerized applications in different environments.
What problem does it solve?
- trend from monolith to microservice therefore rise of containers
- applications now can be comprised of 100s or 1000s of containers
- management of those containers become very difficult manually or via scripts even
- this is where K8 comes in
What does it offer?
- HA - no downtime
- Scalability - high performance
- DR - backup and restore
Kubernetes Components
- Node - server/VM where Pods sit, this is also called worker node
- Pod:
- smallest unit of K8
- abstraction over containers
- one application per pod
- each pod gets its own IP address (internal/private)
- pods are euphemeral, they come and go (i.e. pod crashes, new one is spun up)
- new pod will always get a new IP address
- Service:
- permanent IP address with DNS name
- natively it's a load balancer
- can be attached to pod
- lifecycle of pod and service are not connected
- solves the issue where for example database pod dies and a new instance is spun with a new IP address
- Ingress:
- binds external requests to the pod
- solves the problem of not having to expose the pod and node address directly to outside world
- ConfigMap
- replaces the need to constantly update application settings for things like database endpoint, etc
- external config for your app
- for example the application is configured to connect to database endpoint defined by DB_URL (env) variable, the ConfigMap will make the link to whatever the db endpoint is: DB_URL = mongo-db
- should not contain any secrets or sensitive values
- Secret
- similar to ConfigMap but for storing secrets
- stored in base64 format
- Volumes
- persistent data, comparable to voulmes in Docker terminology
- attaches local or remote storage to the pod
- Deployment: blueprint to create pod
- Replica: deployment uses replica to create multiple copies of the pod attached to the service (same IP, DNS and load balanced)
- abstraction over pods
- databases CANNOT be replicated with deployments
- StatefulSet
- for stateful apps and database
- similar to deployment but for stateful components
- it's a more tedious task than deployments