Operational Best Practices For Azure Kubernetes Service
Operational Best Practices For Azure Kubernetes Service
Operational Best Practices For Azure Kubernetes Service
Saurya Das
Senior Program Manager
Azure Kubernetes Service
Microsoft Corporation.
CI32
Agenda
Pod Pod Pod Pod Staging Pod Pod Pod Pod Team2
Pod Pod Pod Pod DevTeam2 Pod Pod Pod Pod Team3
Kubernetes Namespaces
• Note: Container Level isolation still need to be done to achieve hard Isolation
• Constraints that limit aggregate resource consumption Create a namespace:
per namespace
$ kubectl create namespace ignite
• You can limit Compute Resources (CPU,Memory,
Strage,…) and/or limit the number of Objects (Pods, Apply a resource quota to the namespace:
Services, etc..) and admin/resource/ignite.yaml
• When enabled, users must specify requests or limits, apiVersion: v1
otherwise the quota system will fail the request. kind: ResourceQuota
metadata:
• Kubernetes will not overcommit
name: mem-cpu-demo
spec:
hard:
requests.cpu: "1"
requests.memory: 1Gi
limits.cpu: "2"
limits.memory: 2Gi
Physical Logical
Pod Density Low to Medium Medium to High
Cost $$ $
*Logical Isolation via Namespaces can achieve hard isolation assuming the cluster admin has applied all the required security controls
Kube-advisor
• Diagnostic tool for Kubernetes clusters. At the moment, it returns pods that are missing
resource and request limits.
• More info can be found at https://github.com/Azure/kube-advisor
VS Code extension for warnings
• Kubernetes VS Code extension adding warnings for resource request/limits
Cluster Isolation - Summary
• Think of the sensitivity of the workload, cost, organization culture, operations model, and
blast radius, when trying to choose which isolation pattern to use, a mixture is fine too.
• Always use Namespaces even in physical isolation, never use the Default Namespace for
production workloads
• Done using Kubenet network plugin and has the following features
• Nodes and Pods are placed on different IP subnets
• User Defined Routing and IP Forwarding is for connectivity between Pods across Nodes.
• Drawbacks
• 2 different IP CIDRs to manage
• Performance impact
• Peering or On-Premise connectivity is hard to achieve
AKS Advanced Networking
• Advantages
• Single IP CIDR to manage
• Better Performance
• Peering and On-Premise connectivity is out of the box
AKS with Advanced Networking
Azure VNet A
Backend
AKS subnet services subnet
On-premises
infrastructure
Enterprise
system
Azure
Express
Route
VNet peering
VNet B
ALB
Public IP
Public LB
name: frontendservice
spec: FrontEndService
loadBalancerIP: X.X.X.X
type: LoadBalancer
Pod1 Pod2 Pod3
ports: label:Frontend label:Frontend label:Frontend
- port: 80
selector:
app: frontend
On-premises
VNet B infrastructure
Enterprise
Other peered VNets
system
• Ingress is a Kubernetes API that manages external access to the services in the cluster
• Supports HTTP and HTTPs
• Path and Subdomain based routing
• SSL Termination
• Save on public Ips
• Ingress controller is a daemon, deployed as a Kubernetes Pod, that watches the Ingress
Endpoint for updates. Its job is to satisfy requests for ingresses. Most popular one being
Nginx.
On-premises
infrastructure
Enterprise
system
kind: Ingress
metadata:
name: contoso-ingress
annotations: kubernetes.io/ingress.class: Azure Express Route
”PublicIngress"
Azure AKS VNet
spec:
tls:
- hosts: Private IP
- contoso.com
secretName: contoso-secret
Public IP
rules:
- host: contoso.com Public LB Internal LB
http:
paths: AKS subnet
- path: /b
backend: ServiceA ServiceB ServiceC
serviceName: serviceb
servicePort: 80
Azure
Management VNET
APP GW
Subnet
VNet peering
Azure AKS VNet
Private IP
Internal LB
AKS subnet
AKS cluster
Ingress
Bastion
Host
Azure
Express
Route
VNet peering
Azure AKS VNet
Private IP
Internal LB
AKS subnet
AKS cluster
Ingress
➢ Use AKS Advanced networking for seamless integration with your VNET
➢ Use Ingress and Ingress controllers for HTTP and HTTPs services
➢ Use Azure Application Gateway or any other alternative from the Azure Market place to
secure your services using a WAF
➢ Use Bastion Hosts to access your nodes when needed
Cluster Level Security
Cluster Level Security
1. Kubernetes Developer
authenticates with AAD
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and
enter the code BUJHWDGNL to authenticate.
Or
Web tier
Azure
Inner loop Source Container Azure
code control Registry Monitor
AKS dev
VSCode cluster
Test Aqua, Twistlock, Neuvector
Container Security
Business tier
Debug
Auto-build
Azure Pipelines/
DevOps Project
Database tier
CI/CD
Container Level – The access
• Avoid access to HOST IPC namespace - only if absolutely necessary
• Avoid access to Host PID namespace - only if absolutely necessary
• Avoid root / privileged access
o Consider Linux Capabilities
Container Level – App Armor
AKS w/
Key Vault RBAC
Azure SQL
Storage Database Cosmos DB
Securing workloads
• Service Endpoints
• Filter secrets from the logs
• Encrypted Service to Service Communication
o mTLS between services
o Service Meshes
Compliance
Kublet
replicas++
replicas--
Pod cAdvisor
Gets
metrics NodeX
from
Node2
Collects metrics from all nodes
Pod
Metrics Server
Collects metrics
Kublet from all containers
on the node
cAdvisor
• Scales nodes based on pending pods 2. Additional
node(s) needed
CA
• Scale up and scale down 1. Pods are in
pending state
• Reduces dependency on monitoring Pod Pod
Node Node
AKS Cluster
VM VM
Pods Pods
Application Pods
Architect
Kubernetes
control pane
Infrastructure
Architect
Deployment/ ACI
tasks Connector
VM VM
Pods Pods
Fast container autoscaling
Cluster autoscaler
AKS + VK burst ACI
• Minimize downtime risk Azure Traffic
Manager
In the roadmap
Overview health of AKS cluster
Node event Logs
Pod usage and details
Customer control plane logs