Kubernetes Draft

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

KUBERNETES

Features: kubectl get events / pods / service


Multiple replicas kubectl get replicaset /
Load balancing deployment
Autoscaling kubectl get nodes
Service discovery kubectl get ns
Self healing kubectl version
Zero downtime deployments kubectl explain pods / deployment / replicaset

Architecture:

Master Node
Api Server – kubi-apiserver -
ETCD – distributed database – all configurations are stored here – desired state - HA
Scheduler – kube-scheduler – schedule PODS on specific nodes
Controller Manager – manages health of the cluster – responsible that state matches desired
state
kubectl get componentstatuses

Worker Nodes
Kubelet – node agent – monitors node and communicates to master
PODS
Kube-proxy – networking component – service exposing
Container runtime – docker, rkt, podman

Master node goes down – applications continue to run on nodes – no changes

Single responsibility principle – one concept one responsibility pod/rs/depl


ClusterIP Service
GKE – google kubernetes engine

Kubernetes uses resources on all nodes


gcloud – connect
kubectl create deployment DEPL_NAME –image=DOCKER_IMAGE – creaza depl, rs , pod
kubectl expose deployment DEPL_NAME –type=LoadBalancer –port=8080 – service LB

POD – wrapper for set of containers, has IP, labels


All containers in a pod share resources, communicate with localhost
kubectl describe pod POD_NAME
Namespace
Cgroups
kubectl logs podname
Selector – how a pod is mapped to a service and viceversa
- how a service is mapped to a pod

Replicaset – ensure desired number of containers are running


kubectl scale deployment DEPL_NAME –replicas=3
Deployment
kubectl set image deployment DEPL_NAME CONTAINER_NAME=IMAGE_NAME – change
image in deployment config
Create new deployment, this creates a new replica set which creates new pods, scale down old rs
scale up new rs, delete pod
kubectl get deployment DEPL_NAME -o yaml – configuration in a yaml file
kubectl apply -f deployment.yaml
minReadySeconds

Service
LoadBalancer – Internal and External port
Kubernetes ClusterIP Service – accesed from inside cluster
kubectl get service service_name -o yaml
Kubernetes provides env variables for services
Kubernetes provides DNS and loadbalancing for free by using service names

Rollout
kubectl rollout history deployment DEPL_NAME
kubectl set image deployment DEPL_NAME CONTAINER_NAME=DOCKER_IMAGE –
record=true # the record will save the command in the rollout history
kubectl rollout undo deployment DEPL_NAME –to-revision=VERSION – rollback

kubectl delete all -l app=app_level


kubectl diff -f deployment.yaml

Deployment vs Replicaset
Replicaset does not know about a deployment strategy
A deployment cares about the new release versions

Kubernetes commands
kubectl get pods –all-namespaces
kubectl cluster-info
kubectl top node / pod

Readiness probe – if container is ready to accept request – get request


Liveness probe – check if container is runnign properly

DNS
As soon as a service is started up, it is registered with Kubernetes DNS

ConfigMaps
Centralized configuratio
kubectl apply -f configmap.yaml
Use in a deployment – valueFrom:

Ingress
Service type – NodePort
Every path like /currency redirect to a specific service on specific port
HELM
2 components – helm
- tiller – can run on any worker node
Standardization
give tiller permission to deploy to any namespace, create a new service account

You might also like