https://github.com/whiteducksoftware/aks-scaling-examples
This repo contains examples for using different scaling options with AKS
https://github.com/whiteducksoftware/aks-scaling-examples
Last synced: 8 months ago
JSON representation
This repo contains examples for using different scaling options with AKS
- Host: GitHub
- URL: https://github.com/whiteducksoftware/aks-scaling-examples
- Owner: whiteducksoftware
- Created: 2023-12-04T15:19:58.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-06T13:53:53.000Z (over 2 years ago)
- Last Synced: 2024-10-31T02:33:49.127Z (over 1 year ago)
- Language: C#
- Size: 1.75 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AKS scaling examples
## Create AKS cluster
```bash
# Create 1 AKS clusters with VPA, KEDA and cluster-autoscaler enabled
cd ./src
# Login to Azure
az login
az account set --subscription
# Execute Terraform
terraform init
terraform apply -auto-approve
```
### Enable VPA
```terraform
resource "azurerm_kubernetes_cluster" "aks" {
workload_autoscaler_profile {
vertical_pod_autoscaler_enabled = true
}
}
```
### Enable KEDA
```terraform
resource "azurerm_kubernetes_cluster" "aks" {
workload_autoscaler_profile {
keda_enabled = true
}
}
```
## Enable cluster-autoscaler
```terraform
# Set the global auto-scaler config
resource "azurerm_kubernetes_cluster" "aks" {
auto_scaler_profile {
}
}
# Enable auto-scaler per node pool
resource "azurerm_kubernetes_cluster_node_pool" "scale" {
enable_auto_scaling = true
}
```
## Horizontal Pod Autoscaler
This demo uses the VPA (needs to be activated on AKS) and metrics-server shipped with AKS
```bash
kubectl create ns hpa
# Create HPA and deployment resources vor v1 API
kubectl -n hpa apply -f ./k8s/hpav1.yaml
kubectl -n hpa get hpa hpa-demo-deployment-v1
kubectl -n hpa events
kubectl -n hpa get rs,pod
kubectl -n hpa get hpa hpa-demo-deployment-v1
kubectl -n hpa describe hpa hpa-demo-deployment-v1
# Create some load
watch -n 1 kubectl -n hpa get hpa,rs,pod
kubectl -n hpa run -i --tty load-generator-v1 --rm --image=busybox --restart=Never \
-- /bin/sh -c "while sleep 0.01; do wget -q -O- http://hpa-demo-deployment-v1; done"
kubectl -n hpa describe hpa hpa-demo-deployment-v1
# Create HPA and deployment resources vor v2 API
kubectl -n hpa apply -f ./k8s/hpav2.yaml
kubectl -n hpa get hpa hpa-demo-deployment-v2
kubectl -n hpa events
kubectl -n hpa get rs,pod
kubectl -n hpa get hpa hpa-demo-deployment-v2
kubectl -n hpa describe hpa hpa-demo-deployment-v2
kubectl -n hpa get rs,pod
# Create some load
watch -n 1 kubectl -n hpa get hpa,rs,pod
kubectl -n hpa run -i --tty load-generator-v2 --rm --image=busybox --restart=Never \
-- /bin/sh -c "while sleep 0.01; do wget -q -O- http://hpa-demo-deployment-v2; done"
kubectl -n hpa describe hpa hpa-demo-deployment-v2
```
## Vertical Pod Autoscaler
This demo uses the VPA (needs to be activated on AKS)
```bash
kubectl create ns vpa
# Create VPA and deployment resources with too low resources with update mode "auto"
kubectl -n vpa apply -f ./k8s/vpa-low.yaml
kubectl -n vpa describe pod hamster-low-
kubectl -n vpa describe vpa/hamster-vpa-low
kubectl -n vpa events
# Create VPA and deployment resources with too high resources but with update mode "Off"
kubectl -n vpa apply -f ./k8s/vpa-high.yaml
kubectl -n vpa get pods
kubectl -n vpa describe pod hamster-high-
kubectl -n vpa get vpa
kubectl -n vpa describe vpa/hamster-vpa-high
```
## KEDA
This demo uses the KEDA (needs to be activated on AKS). Keda leverages Worload Identity to check if messages Azure Service Bus queue.
```bash
kubectl create ns keda
# Set the base64 encrypted "servicebus-connectionstring" for the ServiceBus in the file ./k8s/keda.yaml
kubectl -n keda apply -f ./k8s/keda.yaml
kubectl -n keda get triggerauthentications.keda.sh trigger-auth-service-bus-orders
kubectl -n keda get pods
kubectl -n keda describe scaledobjects.keda.sh order-processor-scaler
# Set the "ConnectionString" for the ServiceBus in the file ./orders/Keda.Samples.Dotnet.OrderGenerator/Program.cs
watch -n 1 kubectl -n keda get rs,pod
watch -n 1 az servicebus queue list -g --namespace-name -otsv --query "[].messageCount"
dotnet run --project ./orders/Keda.Samples.Dotnet.OrderGenerator/Keda.Samples.Dotnet.OrderGenerator.csproj
kubectl -n keda events
```
## cluster-autoscaler
This demo uses the cluster-autoscaler (needs to be activated on AKS)
```bash
kubectl create ns cluster
kubectl -n cluster run nginx --image nginx --replicas 500
kubectl -n cluster events
kubectl -n cluster get nodes -w
```