I am learning Kubernetes as part of my personal learning goal and these are just some rough notes. I’ll coma back and beautify these but for now this gives enough hints. Please note that this learning is from a developer perspective, not a system administrator perspective.
Why Kubernetes?
pods
creating deployments
creating services
storage options
configmaps and secrets
Developer context
Not Administrator context
Kubernetes pre-reqs
command line tools
virtual machines
docker containers
High Level Kubernetes
Benefits and Use Cases
Running Kubernetes locally
kubectl
web ui dashboard
Kubernetes k8s Benefits
automatic deployment, scaling and management
of containerized apps.
Load Balancer
Container1
Container2
Container3
Container4
Monitor containers
manage containers
Docker compose can be used but does not work very well in production.
Let Kubernetes manage containers.
Robust networking and storage options.
Kubernetes is conductor of containers orchestra
– service discovery
– load balancing
– storage orchestration
– automate rollouts/rollbacks
– self healing when containers go down
– secrets and configuration management
– horizontal scaling
Big Picture
– From Google (Container and cluster management)
– Open sourced by Google. Used for 15 years
Kubernetes can take a container from current state to desired state.
Master Node
Worker nodes (VMs) – they create cluster
Master will start something on each of these nodes
called Pods.
Pod – Way to host a container.
Package of a container.
Many pods on a machine is possible.
Pod is spacesuit and container is a person.
We talk to container through pod.
Deploy pods
Deployment and ReplicaSet
Kubernetes Service
Pod communication
Node
Virtual machine
can have multiple pods.
Master Node can communicate to all virtual nodes in cluster.
Store (etcd) like database.
It will have everything that boss/master node needs to track.
Scheduler tracks schedules of all the nodes coming to life, going away, etc.
kubectl
send requests to master.
yaml,json to API Server.
Each node has agent Kubelet agent installed so that communication can happen with master.
Container runtime
running containers in pod.
Kube-proxy
each pod gets unique ip address
Benefits and Use Cases
Why Kubernetes?
Why Docker?
accelerate dev onboarding
eliminate app conflicts
environment consistency
ship software faster
Why Kubernetes?
Orchestrate containers (better than Docker compose in prod)
Zero downtime deployments
Self healing powers
scale containers horizontally easily
Emulate production locally easily
Move from docker compose to Kubernetes
Create end to end testing environment
Ensure app scales properly
Ensure secrets/configs are working properly
Performance testing scenarios
Build servers
Canary Testing
Blue Green Testing
Help Devops solve problems
Running Kubernetes Locally
Minikube github
Docker Desktop – better – 1 master node 1 worker node
kind – Kubernetes in Docker
kubeadm – Admin (If you want to install full kubernetes)
kubectl //iteracts with master node commands kubectl version kubectl cluster-info kubectl get all kubectl run containername --image=imagename kubectl port-forward pod ports kubectl expose ... //expose a port kubectl create resource kubectl apply resource
Powershell
set-alias -Name k -Value kubectl
Linux/Mac
alias k="kubectl"
WebUI Dashboard
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.2.0/aio/deploy/recommended.yaml kubectl describe secret -n kube-system kubectl proxy
Type: kubernetes.io/service-account-token
Data
====
ca.crt: 1066 bytes
namespace: 11 bytes
token: eyJhbGciOiJSUzI1NiIsImtpZCI6IldtTmhhQnBPelk4dkRkWlZuSFk1Uy1ZVTZXdlhZMnpGWUlsQ2o1WDBCcGsifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMudsfdnkdp\dfepvokwqpdeewvwvwwd8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJ2cG5raXQtY29udHJvbGxlci10b2tlbi1zNWg2ZyIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJ2cG5raXQtY29udHJvbGxlciIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjEzMTgwNTczLWY3M2ItNDExZS04OGQ1LWE5ZmE3MzM2YjUxYyIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTp2cG5raXQtY29udHJvbGxlciJ9.rmRfsS1phDWeINZm17VwvFQwbiODt6u8kf6MJ6BnvRKGj85uDb0ft4ggADpb00BnzvyLCU81WJDSHDNpP7k5uP9A7Mzb9lRuwUG9-97toyTVunvRP6aD_WdlWFJilQNl8nkGKlKTn-t3JZkOxsSoJ74etc9ENWHLpVJqydJRwO0nAi1Qb5sFq2VPFw4hp40Mky7kHbxX-JB4Qj4zupRBzDSBwInXV7xYBWlAZ1Xbdcv8cVvDbf9ahzyih9k_EkFQFqqPnwB1ZHNXUU8VTJ7L0mxkrTjVAruLNQ37UlnC72sORfJFBic-oj3NUMmP4mO9Tgv8OhWD4oYbFJaQvopvcw
Follow this link to run Kubernetes web ui dashboard.
https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/
Kubernetes
Container orchestration
production
emulating production
testing
kubectl