k8s part 2 Flashcards
what is a label in k8s?
In Kubernetes (k8s), labels are key-value pairs that you attach to objects, such as pods, nodes, and services. You can label all pods that belong to a specific application or environment
what is the command to label a pod ?
kubectl label pod [pod name] key=value
what are selectors
Selectors in Kubernetes are used to filter and identify a set of objects based on their labels
what is the command to see all pods with labels?
kubectl get pods - - show-labels
what is the command to remove a label from a pod ?
kubectl label pod [pod name] key -
what are replica sets?
A ReplicaSet ensures that a specified number of identical pods are running at any given time
what is the command to generate a pod manifest on the cli?
kubectl run [pod name] - - image=[image name] - - dry-run=client -o yaml
what is a deployment ?
A deployment in Kubernetes (k8s) is a way to manage and update applications. If you need to update your app, the deployment ensures the changes are applied smoothly without downtime using replicaset.
what are some challenges you face if you just use a replica set?
- Updating your application requires manual changes to the ReplicaSet
- There is no built-in way to revert to a previous version if an update fails.
- ReplicaSets do not support advanced update strategies like rolling update.
what are advantages of using a deployment ?
- updates your application, ensuring new versions are rolled out smoothly.
- If an update fails or causes issues, Deployments can easily revert to a previous version.
- Deployments make it easy to scale your application up or down by simply changing the number of replicas
- Ensures that the desired state of your application is consistently maintained across all replicas.
- Automatically replaces failed or crashed pods to maintain the desired number of replicas.
- Keeps a history of previous versions and updates, making it easier to track changes and diagnose issues.
what is the command to output a deployment manifest file?
kubectl run deployment [name] –image=[name] - -dry-run=client -o yaml
what is the command to create a deployment using cli?
kubectl run deployment my-deployment - -image=nginx
what is the command to generate a deployment manifest file via CLI?
kubectl create deployment [name]
- -image=nginx - -dry-run=client -o yaml