2 min read
Azure Kubernetes Service: Managed Kubernetes
AKS provides managed Kubernetes with integrated Azure services. You manage the applications; Azure manages the control plane.
Creating a Cluster
az aks create \
--resource-group myResourceGroup \
--name myAKSCluster \
--node-count 3 \
--node-vm-size Standard_DS2_v2 \
--enable-addons monitoring \
--generate-ssh-keys \
--enable-managed-identity
# Get credentials
az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
Deploying an Application
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: myregistry.azurecr.io/myapp:v1
ports:
- containerPort: 80
resources:
limits:
cpu: "500m"
memory: "128Mi"
---
apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
type: LoadBalancer
ports:
- port: 80
selector:
app: myapp
kubectl apply -f deployment.yaml
Azure Integration
ACR Integration
az aks update -n myAKSCluster -g myResourceGroup --attach-acr myRegistry
Azure AD Integration
az aks update -g myResourceGroup -n myAKSCluster --enable-aad --aad-admin-group-object-ids <group-id>
Key Vault Secrets
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
name: azure-kvname
spec:
provider: azure
parameters:
keyvaultName: "myKeyVault"
objects: |
array:
- |
objectName: secret1
objectType: secret
tenantId: "<tenant-id>"
Scaling
# Manual scale
kubectl scale deployment myapp --replicas=5
# Cluster autoscaler
az aks update --enable-cluster-autoscaler --min-count 1 --max-count 10 -g myRG -n myAKS
# Horizontal Pod Autoscaler
kubectl autoscale deployment myapp --cpu-percent=50 --min=3 --max=10
AKS is the path to production Kubernetes without the operational burden.