Understanding Deployments and Replica Sets in Kubernetes
Hafeez Baig |
17 steps |
2 minutes
Please review the previous lab on Pods in Kubernetes before proceeding with this lab. <https://scribehow.com/shared/Understanding_Pods_in_Kubernetes__kJVQfpjbRUGzsxQRyaK-rA>
1
On the **Cloud Shell CLI**, type the command [[kubectl set image deplyment hello-world-rest-api hello-world-rest-api=in28min/hello-world-rest-api:0.0.2.RELEASE]]
**What is [[kubectl set image deplyment hello-world-rest-api hello-world-rest-api=in28min/hello-world-rest-api:0.0.2.RELEASE ]]command?**\
\
The command `kubectl set image deployment hello-world-rest-api hello-world-rest-api=in28min/hello-world-rest-api:0.0.2.RELEASE` updates the image used by the `hello-world-rest-api` container in the `hello-world-rest-api` Deployment to the new version `in28min/hello-world-rest-api:0.0.2.RELEASE`. This triggers a rolling update, where Pods are gradually replaced with new ones using the specified image version, ensuring zero downtime for the application.
2
**deployment.apps/hello-world-rest-api image updated** is displayed
3
Go back to the **hello-world** tab
4
**Hello World V1 hpknq** is displayed
5
On the top left corner click on the page reload button
6
**Hello World V2 72fk4** is displayed
**Note:** You can view that now the Version is updated to V2
7
To get replicas, type the command [[kubectl get replicasets]]
**What is command** [[kubectl get replicasets]]**?**\
\
The `kubectl get replicasets` command lists all ReplicaSets in your Kubernetes cluster, showing their status and the number of desired, current, and ready replicas.
8
Information of the replicasets is displayed
**What are replicasets in GCP?**
ReplicaSets in Google Cloud Platform (GCP) are a Kubernetes object used to ensure a specified number of pod replicas are running at any given time. They play a crucial role in maintaining the desired state of your application by monitoring and managing pod instances.
9
To get **Pods**, type the command [[kubectl get pods]]
**What is the command** [[kubectl get pods]]**?**\
\
The `kubectl get pods` command is used to list all pods in your Kubernetes cluster, showing their status, namespaces, and other relevant details.
10
Copy the Name **hello-world-rest-api-5df8fb76f9-a5w27**
11
To delete the Pod, type the command [[kubectl delete pod <paste the pod name here>]]
**What is** [[kubectl delete pod hello-world-rest-api-5df8fb76f9-a5w27 ]]**command?**\
\
The `kubectl delete pod hello-world-rest-api-5df8fb76f9-a5w27` the command deletes the specified pod (`hello-world-rest-api-5df8fb76f9-a5w27`) from your Kubernetes cluster.
12
**pod "hello-world-rest-api-5df8fb76f9-a5w27" deleted** is displayed
Congratulations you have successfully deleted the pod!
13
To get the Pods, type the command [[kubectl get pods]]
**Note:** You can see that a new pod has been created