Kubernetes Journey - Scaling Deployments and Resizing Node Pools | Scribe

    Kubernetes Journey - Scaling Deployments and Resizing Node Pools

    • Hafeez Baig |
    • 18 steps |
    • 2 minutes
    alert ordinal icon
    Please review the previous lab on How to Connect to Gcloud and create a deployment and a Service before proceeding with this lab.<https://scribehow.com/shared/Kubernetes_Journey__Create_a_Deployment_and_a_Service__pTjVercQTLWeU3wURWgEcQ>
    1
    Make sure you are still connected to the **CLOUD SHELL Terminal**
    2
    Type the command "**kubectl scale deployment hello-world -rest-api --replicas=3**"
    information ordinal icon
    **What is [[kubectl scale deployment hello-world -rest-api --replicas=3 ]]command?**\ \ The command `kubectl scale deployment hello-world-rest-api --replicas=3` scales the specified deployment named `hello-world-rest-api` to have three replicas. This means it adjusts the number of running instances (Pods) of the application to three, ensuring that three copies of the application are running within the Kubernetes cluster for load balancing and redundancy.
    3
    **deployment.apps/hello-world-rest-api scaled** is displayed **Note:** It means the deployment is now scaled
    4
    To get the deployment, type the command [[kubectl get deployment]]
    information ordinal icon
    **What is [[kubectl get deployment ]]command?**\ \ The command `kubectl get deployment` retrieves and displays information about all the deployments in the Kubernetes cluster. It provides details such as the deployment names, the number of desired and current replicas, the number of updated and available replicas, and their current status. This command helps you monitor and manage the deployments running in your cluster.
    5
    deployments information is displayed
    6
    Go back to the **&lt;your ip&gt;/hello-world** tab
    7
    **Hello World V1 6ck28** is displayed
    8
    On the top left corner click on the page refresh button
    9
    **Hello World V1 hpkmq** is displayed **Note:** You can view that the Host details has been changed
    information ordinal icon
    **How does load balancing cause the instance host to change?** Load balancing distributes incoming traffic across multiple instance hosts, ensuring no single instance is overwhelmed. This dynamic distribution can cause the specific instance handling a request to change, optimizing resource utilization and enhancing application availability and performance.
    10
    Go back to the **Cloud Shell** tab
    11
    To get the Pods, type the command [[kubectl get pods]]
    information ordinal icon
    **What is [[kubectl get pods ]]command?**\ \ The command `kubectl get pods` retrieves and displays information about all the Pods running in the Kubernetes cluster. It provides details such as Pod names, their current status (e.g., Running, Pending, Failed), the number of restarts, and the node they are assigned to. This command is useful for monitoring the state and health of your Pods.
    12
    Pods information is displayed **Note:** These are the pods where the load balancer will distribute the load.
    13
    Type the command [[gcloud container clusters resize my-cluster --node-pool default=pool --num=nodes=2 --zone=us-central1-c]] **Note:** Make sure to recheck the Zone details in which your Kubernetes Cluster is created.
    information ordinal icon
    **What is [[gcloud container clusters resize my-cluster --node-pool default=pool --num=nodes=2 --zone=us-central1-c]] command?**\ \ The command `gcloud container clusters resize my-cluster --node-pool default-pool --num-nodes=2 --zone=us-central1-c` resizes the specified node pool `default-pool` in the Kubernetes cluster `my-cluster` to have 2 nodes. This operation takes place in the `us-central1-c` zone, adjusting the number of nodes in the node pool to meet the desired size, either by adding or removing nodes. This helps manage the cluster's capacity and resource allocation.
    14
    Type "**Y**" to proceed with the cluster resizing process.