Need for Kubernetes
Services Provided by Kubernetes
Platform for managing containerized workloads and services that facilitates
declarative configuration and automation.
Service discovery and load balancing
Storage orchestration
Automated rollouts and rollbacks
Optimized scheduling
Self-healing
Secret and configuration management
Components of a cluster
Kubectl
Kubernetes Core Objects - Pods
Managed Pods
Liveness Probes: HTTP GET, TCP socket, Exec (arbitrary command inside container)
ReplicationController - a kube resource that ensures pods are always kept running.
Matches pod by a label selector, can scale up or down
ReplicaSet - newer version of ReplicationController with more expressive labelSelectors
in,notIn, exists, doesNotExist
DeamonSet - one pod per node. Useful for system level ops like log controller, resource mon
Job - After a process completes, it is not restarted again. If it fails it can be setup to either
restart or not.
Services - Enable clients to talk to pods
Service provides a single constant point of entry to a group of pods providing same service.
Use labelSelectors to pick pods
Connect to external service by creating an endpoint manually or by using FQDN
Expose service as
NodePort - open a port on the node and redirects traffic from that node to service.
LoadBalancer -Dedicated loadBalancer provisioned from cloud for each service
Ingress - Multiple services through one IP address, operates at HTTP level. One load balancer
for all services. Uses host and path to redirect. Can terminate TLS
NodePort service
LoadBalancer
Ingress
Config Maps
ConfigMap : a map of key value pair with values ranging from strings to full config files
kubectl create configmap my-config --from-file=foo.json --from-file=bar=foobar.conf
--from-file=config-opts/ --from-literal=some=thing
Can use as env var, argument or a volume
Secrets
Key value pair maps like configMaps
Only distributed to nodes that need them
Stored in tmpfs never in memory
On master secrets are stored encrypted from 1.7
Storing & Sharing data
Each container will have its own filesystem.
Volume: allows you to preserve data between restarts and share with different containers
It is not an object so cannot be created or deleted. It needs to be mounted.
VolumeTypes:
emptyDir, hostPath, gitRepo, nfs, gcePersistentDisk, awsElasticBlockStore,
configMap, secret, downwardAPI
PersistentVolume & PersistentVolumeClaims : Pre provisioned volumes
PersistentVolumeClaim
PersistentVolumeProvisioner will provision the persistentVolume automatically when a
persistentVolumeClaim is posted.