Skip to content

Commit 2f3de4f

Browse files
author
Houssem Dellai
committed
work in progress
1 parent 03d75e8 commit 2f3de4f

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

02_kubernetes_intro_for_infra_teams/Readme.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,74 @@ The IP address returned is the external IP address of the cluster, which is the
662662

663663
>Note that you can control egress traffic using Network Policies or by configuring an `Azure Firewall` or `NAT Gateway`.
664664
665+
## Scaling the application
666+
667+
Kubernetes allows you to scale your applications up or down easily. You can scale your application by changing the number of replicas in the Deployment resource.
668+
669+
To scale the Inspectorgadget application to 5 replicas, you can run the following command:
670+
671+
```sh
672+
kubectl scale deployment inspectorgadget --replicas=5
673+
# deployment.apps/inspectorgadget scaled
674+
```
675+
676+
You can verify the scaling operation by checking the status of the Pods:
677+
678+
```sh
679+
kubectl get pods
680+
# NAME READY STATUS RESTARTS AGE
681+
# inspectorgadget-5c6b7c8f5c-abcde 1/1 Running 0 1m
682+
# inspectorgadget-5c6b7c8f5c-fghij 1/1 Running 0 1m
683+
# inspectorgadget-5c6b7c8f5c-klmno 1/1 Running 0 1m
684+
# inspectorgadget-5c6b7c8f5c-pqrst 1/1 Running 0 1m
685+
# inspectorgadget-5c6b7c8f5c-uvwxy 1/1 Running 0 1m
686+
```
687+
688+
Now lets scale the application to 100 replicas.
689+
690+
```sh
691+
kubectl scale deployment inspectorgadget --replicas=100
692+
# deployment.apps/inspectorgadget scaled
693+
```
694+
695+
You can verify the scaling operation by checking the status of the Pods:
696+
697+
```sh
698+
kubectl get deploy -w
699+
```
700+
701+
Lets push forward and scale out to 1000 replicas:
702+
703+
```sh
704+
kubectl scale deployment inspectorgadget --replicas=1000
705+
# deployment.apps/inspectorgadget scaled
706+
707+
kubectl get deploy -w
708+
```
709+
710+
Note that autoscaling will hit the limits allowed by `max pods per node`.
711+
712+
```sh
713+
kubectl get nodes -o=jsonpath='{.items[*].status.allocatable.pods}'
714+
# 110
715+
```
716+
717+
This should trigger the cluster autoscaler to add more nodes to the cluster to accommodate the new Pods. The cluster autoscaler will monitor the resource usage and scale the cluster up or down based on the demand.
718+
719+
Check the number of nodes in the cluster:
720+
721+
```sh
722+
kubectl get nodes
723+
```
724+
725+
Note how new nodes are being created.
726+
727+
## Auto scaling the cluster
728+
729+
You can manually set up the number of nodes on the cluster or you can enable the cluster autoscaler to automatically scale the number of nodes in the cluster based on the resource usage.
730+
731+
Explore these features in the Azure portal or using the Azure CLI. You can set the minimum and maximum number of nodes in the node pool, and the cluster autoscaler will automatically add or remove nodes based on the resource usage of the Pods in the cluster.
732+
665733
## Getting container logs
666734

667735
You can view the logs of a container running in a Pod using the `kubectl logs` command. For example, to view the logs of the Nginx container in the `nginx` Pod, you can run the following command:

0 commit comments

Comments
 (0)