Orchestration: Kubernetes Flashcards
What to all install when installing K8s?
- kubectl
- K8s Master
- Worker node agents
How to run a pod using the soon to be deprecated method?
kubectl run mywebserver –image=nginx
How to exec into a pod?
kubectl exec -it mywebserver-xyz – bash
How to delete a pod?
kubectl delete pod mywebserver-xyz
What is an object?
Object is a record of intent, once created K8s will work to ensure that the object exists.
How to create a K8s object via YAML configuration file?
kubectl apply -f file.yaml
How to delete a K8s object via YAML configuration file?
kubectl delete -f file.yaml
What is a the purpose of a ReplicaSet?
To maintain a set of replica pods
What are the two states of pods in a ReplicaSet?
Current and Desired
How to view the labels of pods?
kubectl get pods –show-labels
What does the “selector / matchLabels” section do in ReplicaSets?
Determines which label is used to count the number of current pods for the ReplicaSet
What is the main difference between a ReplicaSet and a Deployment?
Deployment sits on top of ReplicaSets, with features like rolling out updates and rolling back.
How does a Deployment rollout changes?
Creates a new ReplicaSet, once running, deletes old ReplicaSet.
Equivalent K8s command for docker inspect?
kubectl describe resource_type resource_name
How to get the rollout history for a deployment?
kubectl rollout history deployment.v1.apps/my_deployment
How to get information about a specific deployment revision?
kubectl deployment history deployment.v1.apps/my_deployment –revision=1
What is the default max unavailable pods and maximum surge during a deployment rollout?
25%
For deployment rollout, which parameter determines the max number of pods that can be scheduled above the original number of pods?
maxSurge
For deployment rollout, which parameter determines the maximum amount of pods that can be unavailable during the deployment?
maxUnavailable
Two different ways of getting information about a resource (pod/deployment/replicaset/etc)
kubectl get pod my_pod -o yaml
kubectl describe pod my_pod
How to create a new basic K8s secret with a literal value?
kubectl create secret generic my_secret –from-literal=dbpass=password123
How to create a new basic K8s secret from a file?
kubectl create secret generic my_secret –from-file=./file.txt
What are two approaches to make secrets available to Pods?
Environment Variables
Volumes
How to create a ConfigMap
kubectl create configmap my_config –from-literal=memory=2048m
What does a Kubernetes service do?
Acts as a load balancer and a single point of contact for pods to communicate to downstream pods
What are the four types of K8s services?
ClusterIP
NodePort
LoadBalancer
ExternalName
What are the 3 characteristics of ClusterIP service?
Internal Cluster IP address is assigned to the service
Only reachable from inside the cluster
Default service type
What is the NodePort service?
K8s opens a random port on each worker node
Is accessible over the internet
What are the 4 networking considerations for K8s?
- Container to container
- Pod to Pod
- Pod to Service
- Internet to Service
How does container to container communication occur in K8s Networking Model?
Using localhost and port numbers for other containers in the same pod
How does pod to pod communication occur in K8s Networking Model?
Virtual interfaces on the pod communicating via a bridge
How does pod to service communication occur in K8s Networking Model?
Service creates an IP or DNS endpoint which can be used to route traffic to
How does internet to service communication occur in K8s Networking Model?
Using an Ingress controller (like Traefik)
What is a Liveness Probe?
Used to detect the state (healthy/unhealthy) of an application, and take actions such as restarting
What is Readiness Probe?
A healthcheck that will wait for new pods before serving traffic or trying to restart the pod
How does a Readiness Probe differ from Liveness Probe?
Liveness is to know when to restart a container
Readiness is to know when it can start accepting traffic
What is a K8s DaemonSet?
Similar to docker global replicated services. One pod per node, and new nodes get the pod
What are Taints?
Used to repel pods from a specific node ie, prevents a pod from running on a specific node
What is a Toleration?
It’s a pass for a pod to be deployed to a tainted node
What is the command to taint a node?
kubectl taint node node_name key=value:NoSchedule
What is the purpose of the key and value in the taint command?
Used to issue a toleration for a pod for a specific taint key:value
What is a Selector in K8s?
Used to filter on specific labels
How to get all pods with the label of env=prod?
kubectl get pods -l env=prod
What is a resource Request?
The amount of resources that a pod is guaranteed to get
What is a resource Limit?
Makes sure that the resource does not go above a specific value
How to view the Requests and Limits for a specific node?
kubectl describe node my_node
What are the three states of Requests/Limits?
Guaranteed
Burstable
Best Effort