Overview
Rancher provides native integration with Azure Kubernetes Service (AKS) through theClusterDriverAKS driver. This allows you to provision, manage, and import AKS clusters directly from Rancher.
Cluster Driver
Driver Name:AKS
Defined in: pkg/apis/management.cattle.io/v3/cluster_types.go:82
Configuration Spec
AKS clusters are configured using theAKSClusterConfigSpec structure in the cluster specification.
Cluster Spec Fields
Authentication Configuration
namespace.GlobalNamespace) contains:
azurecredentialConfig-tenantId: Azure AD tenant IDazurecredentialConfig-subscriptionId: Azure subscription IDazurecredentialConfig-clientId: Service principal client IDazurecredentialConfig-clientSecret: Service principal secretazurecredentialConfig-environment: Azure environment (AzurePublicCloud, AzureChinaCloud, AzureUSGovernmentCloud)
pkg/api/norman/customization/aks/handler.go:248-252
Networking Configuration
Node Pool Configuration
Security Configuration
Advanced Features
API Integration
The AKS handler provides API endpoints for interacting with Azure services: Handler Location:pkg/api/norman/customization/aks/handler.go
Available Endpoints
- aksCheckCredentials: Validate Azure credentials (POST)
- aksVersions: List available Kubernetes versions
- aksUpgrades: List available upgrade versions for a cluster
- aksVirtualNetworks: List virtual networks
- aksClusters: List existing AKS clusters
- aksVMSizes: List available VM sizes (v1)
- aksVMSizesV2: List available VM sizes (v2)
- aksLocations: List Azure locations
- aksRegions: List Azure regions
pkg/api/norman/customization/aks/handler.go:100-159
Credential Authentication
The handler supports two authentication methods:- Cloud Credential ID: Pass
cloudCredentialIdas a query parameter - Direct Credentials: POST credentials in request body
pkg/api/norman/customization/aks/handler.go:318-354
Cluster Status
The AKS cluster status is tracked instatus.aksStatus:
pkg/apis/management.cattle.io/v3/cluster_types.go:405-409
Azure Environments
Rancher supports multiple Azure cloud environments:- AzurePublicCloud (default):
cloud.AzurePublic - AzureChinaCloud:
cloud.AzureChina - AzureUSGovernmentCloud:
cloud.AzureGovernment
pkg/api/norman/customization/aks/handler.go:379-388
Provisioning Workflow
- Create Cluster Object: Define cluster with
spec.aksConfig - Credential Validation: System validates Azure credentials
- Resource Creation: Azure resources are provisioned:
- Resource group (if needed)
- Virtual network and subnet (if not provided)
- AKS cluster
- Node pools
- Status Updates: Cluster status reflects provisioning state
- Agent Deployment: Rancher cluster agent is deployed
- Ready State: Cluster becomes active and manageable
Importing Existing Clusters
To import an existing AKS cluster:imported: true, Rancher registers the cluster without modifying its configuration.
Best Practices
Network Configuration
- Use Azure CNI (
networkPlugin: azure) for advanced networking features - Configure
authorizedIpRangesto restrict API server access - Use private clusters for enhanced security
Node Pools
- Separate system and user workloads using different node pools
- Enable autoscaling for dynamic workload handling
- Use availability zones for high availability
Security
- Use managed identities instead of service principals when possible
- Enable monitoring and log analytics for observability
- Rotate SSH keys and service principal credentials regularly
Cost Optimization
- Use appropriate VM sizes for workload requirements
- Enable autoscaling to scale down during low usage
- Use spot instances for non-critical workloads
Troubleshooting
Credential Issues
If you receive a403 error, verify:
- Service principal has
Contributorrole on subscription - Tenant ID matches the subscription
- Credentials are not expired
pkg/api/norman/customization/aks/handler.go:162-213
Private Cluster Access
For private clusters, Rancher determines if tunneling is required:privateRequiresTunnel: true: Cluster agent tunnel is requiredprivateRequiresTunnel: false: Direct API access is possible
Networking Conflicts
Ensure that:- Service CIDR doesn’t overlap with VNet CIDR
- Pod CIDR doesn’t overlap with service or VNet CIDRs
- DNS service IP is within service CIDR
Related Resources
API Reference
Cluster Type Definition
Location:pkg/apis/management.cattle.io/v3/cluster_types.go:161
AKS Handler Registration
The AKS API handler is registered in the Norman API server and handles all AKS-related API requests. Location:pkg/api/norman/customization/aks/handler.go:52-60