+
+> View the current number of replicas for the store-front service
+
+```bash
+kubectl get deployment store-front
+```
+
+You should see the following output.
+
+```bash
+NAME READY UP-TO-DATE AVAILABLE AGE
+store-front 1/1 1 1 92m
+```
+
+Notice that there is currently only 1 replica running of the `store-front` service.
+
+
+
+> Scale the number of replicas for the store-front service to 10
+
+```bash
+kubectl scale deployment store-front --replicas=10
+```
+
+You should see the following output.
+
+```bash
+deployment.apps/store-front scaled
+```
+
+Scaling to 10 replicas may take a moment. You can view the increased number of replicas by viewing the `store-front` deployment again.
+
+```bash
+kubectl get deployment store-front
+```
+
+If scaling the `store-front` deployment was successfully, you should now see `READY` and `AVAILABLE` number of replicas as 10.
+
+```bash
+NAME READY UP-TO-DATE AVAILABLE AGE
+store-front 10/10 10 10 103m
+```
+
+We will now return the number of replicas of the `store-front` service back to 1.
+
+```bash
+kubectl scale deployment store-front --replicas=1
+```
+
+### Automatically scaling your application
+
+To automatically scale your deployments, you can use the Horizontal Pod Autoscale (HPA) setting. This is a more preferred approach to scale you applicaiton, as it allows you to define a set of resource requests and limits, for CPU and memory, that your application can support safely to stay operational. Once an HPA configuraiton has been set for your deployment, Kubernetes will track application pod resource utilization and will scale your deployment automatically if the limits of your resource configuraiton has been met.
+
+Let's first take a look and view the current CPU and memory requests and limits for the `store-front` deployment.
+
+```bash
+kubectl describe deployment store-front
+```
+
+A description of the `store-front` deployment is returned. Under the Pod Template\Containers section, you should see the following limits and requests:
+
+```bash
+Limits:
+ cpu: 1
+ memory: 512Mi
+Requests:
+ cpu: 1m
+ memory: 200Mi
+```
+
+As a quick explanation of the `store-front` deployment requests and limits configuration, this configuration limits the `store-front` deployment up to 1 CPU core and 512Mi of memory, which is the equivalent of 1MB of memory. That is the hardware limit of resources allowed by each pod in the deployment. The request section specifies the minimum ammount of resources the container is gauranteed to have from the hardware resources available. In this case, each `store-front` pod is gauranteed to have 1m (millicore) of CPU, which is 0.001 CPU, and 200Mi, which is approximately 209MB.
+
+Let's first take a look and see if an HPA configuration exists for the `store-front` deployment.
+
+```bash
+kubectl get hpa store-front
+```
+
+If no HPA configuration exists, you will see an error similar to:
+
+```bash
+Error from server (NotFound): horizontalpodautoscalers.autoscaling "store-front" not found
+```
+
+Let's now create a HPA configuration for the `store-front` deployment.
+
+We will create a HPA policy that will allow the HPA controller to increase or decrease the number of pods from 1 to 10, based on the pods keeping an average of 50% CPU utilization.
+
+```bash
+kubectl autoscale deployment store-front --cpu-percent=50 --min=1 --max=10
+```
+
+The output of the command
+
+```bash
+horizontalpodautoscaler.autoscaling/store-front autoscaled
+```
+
+We can then verify that an HPA policy exists for the `store-front` deployment.
+
+```bash
+kubectl get hpa store-front
+```
+
+You should see the following output:
+
+```
+NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
+store-front Deployment/store-front 100%/50% 1 10 2 2m4s
+```
+
+In my example output, notice that the HPA autoscaler has already added an additional replica (instance) of the `store-front` deployment to meet the HPA configuration.
+
+We will now deploy an application to simulate additional client load to the `store-front` deployment. In a seperate terminal, that has kubeclt access to your cluster, run the following command:
+
+```bash
+kubectl run -i --tty load-generator --rm --image=busybox:1.28 --restart=Never -- /bin/sh -c "while sleep 0.01; do wget -q -O- http://store-front; done"
+```
+
+After running the previous command, return back to your original terminal, where we will again look at the HPA policy for the `store-front` deployment to see if we have increased the need for replicas to meet the policy configuration.
+
+```bash
+kubectl get hpa store-front
+```
+
+You should see that the load generating application allowed the automatic scaling of the `store-front` deploymente to reach the maxium replica limit of 10.
+
+```bash
+NAME READY UP-TO-DATE AVAILABLE AGE
+store-front 10/10 10 10 4h13m
+```
+
+You can now terminate the load generating terminal, by either using ctrl+C, or closing the terminal window.
+
+You can also remove the HPA configuration for the `store-front` deployment by running the following command:
+
+```bash
+kubectl delete hpa store-front
+horizontalpodautoscaler.autoscaling "store-front" deleted
+```
+
+
+### Scaling your app
As your app becomes more popular, you'll need to scale it to handle the increased load. In AKS, you can scale your app by increasing the number of replicas in your deployment. The Kubernetes Horizontal Pod Autoscaler (HPA) will automatically scale your app based on CPU and/or memory utilization. But not all workloads rely on these metrics for scaling. If say, you need to scale your workload based on the number of items in a queue, HPA will not be sufficient.
From 40ff35d1e051291f8e563de964edfb68309c9133 Mon Sep 17 00:00:00 2001
From: Paul Yu
Date: Wed, 9 Oct 2024 14:27:45 -0700
Subject: [PATCH 2/3] Update workshops/getting-started-with-aks/workshop.md
---
workshops/getting-started-with-aks/workshop.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/workshops/getting-started-with-aks/workshop.md b/workshops/getting-started-with-aks/workshop.md
index f0bbf02f..5203b32c 100644
--- a/workshops/getting-started-with-aks/workshop.md
+++ b/workshops/getting-started-with-aks/workshop.md
@@ -1451,6 +1451,7 @@ If you click on the **Logs** section in the left-hand menu, you can view the log
![Azure portal AKS logs queries](./assets/azure-portal-aks-container-logs.png)
+You can also view live streaming logs for a specific container by clicking on the **Workloads** section in the left-hand menu. In the **Deployments** tab, scroll down and locate the **order-service** deployment. Click on the **order-service** deployment to view the details. In the left-hand menu, click on **Live logs**, then select the Pod you want to view logs for.
![Azure portal AKS live logs](./assets/azure-portal-aks-live-logs.png)
This is the equivalent of running `kubectl logs -f ` in the terminal.
From 1f25d0178050b7c7d328d9afd5b4f91daea685ac Mon Sep 17 00:00:00 2001
From: Paul Yu
Date: Wed, 9 Oct 2024 14:28:24 -0700
Subject: [PATCH 3/3] Update workshops/getting-started-with-aks/workshop.md
---
workshops/getting-started-with-aks/workshop.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/workshops/getting-started-with-aks/workshop.md b/workshops/getting-started-with-aks/workshop.md
index 5203b32c..974b5bec 100644
--- a/workshops/getting-started-with-aks/workshop.md
+++ b/workshops/getting-started-with-aks/workshop.md
@@ -1452,6 +1452,7 @@ If you click on the **Logs** section in the left-hand menu, you can view the log
![Azure portal AKS logs queries](./assets/azure-portal-aks-container-logs.png)
You can also view live streaming logs for a specific container by clicking on the **Workloads** section in the left-hand menu. In the **Deployments** tab, scroll down and locate the **order-service** deployment. Click on the **order-service** deployment to view the details. In the left-hand menu, click on **Live logs**, then select the Pod you want to view logs for.
+
![Azure portal AKS live logs](./assets/azure-portal-aks-live-logs.png)
This is the equivalent of running `kubectl logs -f ` in the terminal.