Overview
Azure Kubernetes Service (AKS) is a fully managed Kubernetes service provided by Microsoft Azure. We have developed an integration with AKS to ensure that users can provision AKS Clusters in any region using the RCTL CLI.
Declarative¶
You can also create the cluster based on a version controlled cluster spec that you can store in a Git repository. This enables users to develop automation for reproducible infrastructure.
Create Cluster¶
./rctl create cluster aks -f cluster-spec.yaml
An illustrative example of the cluster spec YAML file for AKS is shown below
apiVersion: rafay.io/v1alpha1
kind: Cluster
metadata:
name: aks-ui-01
project: defaultproject
spec:
blueprint: default-aks
cloudprovider: provider-aks
clusterConfig:
apiVersion: rafay.io/v1alpha1
kind: aksClusterConfig
metadata:
name: aks-ui-01
spec:
managedCluster:
apiVersion: "2021-05-01"
identity:
type: SystemAssigned
location: centralindia
properties:
apiServerAccessProfile:
enablePrivateCluster: true
dnsPrefix: aks-ui-01-dns
kubernetesVersion: 1.23.8
networkProfile:
loadBalancerSku: standard
networkPlugin: kubenet
sku:
name: Basic
tier: Free
type: Microsoft.ContainerService/managedClusters
nodePools:
- apiVersion: "2021-05-01"
location: centralindia
name: primary
properties:
count: 1
enableAutoScaling: true
maxCount: 1
maxPods: 40
minCount: 1
mode: System
orchestratorVersion: 1.23.8
osType: Linux
type: VirtualMachineScaleSets
vmSize: Standard_DS2_v2
type: Microsoft.ContainerService/managedClusters/agentPools
- apiVersion: "2021-05-01"
location: centralindia
name: secondary
properties:
count: 1
enableAutoScaling: true
maxCount: 1
maxPods: 40
minCount: 1
mode: User
nodeLabels:
app: infra
dedicated: "true"
nodeTaints:
- app=infra:NoSchedule
- dedicated=true:NoSchedule
orchestratorVersion: 1.23.8
osType: Linux
type: VirtualMachineScaleSets
vmSize: Standard_DS2_v2
type: Microsoft.ContainerService/managedClusters/agentPools
resourceGroupName: demo_resourcegroup
proxyconfig: {}
systemComponentsPlacement:
nodeSelector:
app: infra
dedicated: "true"
tolerations:
- effect: NoSchedule
key: dedicated
operator: Equal
value: "true"
- effect: NoSchedule
key: app
operator: Equal
value: infra
type: aks
Below is an example of the AKS addon yaml file
apiVersion: rafay.io/v1alpha1
kind: Cluster
metadata:
name: demo-aks-addon
project: defaultproject
spec:
blueprint: default-aks
cloudprovider: azure-credentials
clusterConfig:
apiVersion: rafay.io/v1alpha1
kind: aksClusterConfig
metadata:
name: demo-aks-addon
spec:
managedCluster:
apiVersion: "2022-07-01"
identity:
type: SystemAssigned
location: centralindia
properties:
addonProfiles:
azureKeyVaultSecretsProvider:
config:
enableSecretRotation: "true"
rotationPollInterval: 1m
enabled: true
azurePolicy:
enabled: true
httpApplicationRouting:
enabled: true
ingressApplicationGateway:
config:
applicationGatewayId: "Application Gateway ID"
enabled: true
omsAgent:
config:
logAnalyticsWorkspaceResourceID: "Resource ID"
enabled: true
openServiceMesh:
enabled: true
apiServerAccessProfile:
enablePrivateCluster: false
dnsPrefix: demo-aks-addon-dns
kubernetesVersion: 1.22.11
networkProfile:
dnsServiceIP: 10.0.0.10
dockerBridgeCidr: 172.17.0.1/16
loadBalancerSku: standard
networkPlugin: azure
networkPolicy: azure
serviceCidr: 10.0.0.0/16
sku:
name: Basic
tier: Free
type: Microsoft.ContainerService/managedClusters
nodePools:
- apiVersion: "2022-07-01"
location: centralindia
name: primary
properties:
count: 1
enableAutoScaling: true
maxCount: 1
maxPods: 40
minCount: 1
mode: System
nodeLabels:
check1: value1
nodeTaints:
- check1=value1:PreferNoSchedule
orchestratorVersion: 1.22.11
osType: Linux
tags:
check1: value1
type: VirtualMachineScaleSets
vmSize: Standard_B4ms
type: Microsoft.ContainerService/managedClusters/agentPools
- apiVersion: "2022-07-01"
location: centralindia
name: np1
properties:
count: 1
enableAutoScaling: true
maxCount: 1
maxPods: 40
minCount: 1
mode: User
nodeLabels:
check2: value2
nodeTaints:
- check2=value2:NoSchedule
orchestratorVersion: 1.22.11
osType: Linux
tags:
check2: value2
type: VirtualMachineScaleSets
vmSize: Standard_B4ms
type: Microsoft.ContainerService/managedClusters/agentPools
- apiVersion: "2022-07-01"
location: centralindia
name: np102
properties:
count: 1
enableAutoScaling: true
maxCount: 1
maxPods: 40
minCount: 1
mode: User
nodeLabels:
check3: value3
nodeTaints:
- check3=value3:NoSchedule
orchestratorVersion: 1.22.11
osType: Windows
tags:
check3: value3
type: VirtualMachineScaleSets
vmSize: Standard_B4ms
type: Microsoft.ContainerService/managedClusters/agentPools
resourceGroupName: demoaks
proxyconfig: {}
systemComponentsPlacement:
daemonSetOverride:
tolerations:
- operator: Exists
nodeSelector:
check2: value2
tolerations:
- effect: NoSchedule
key: check2
operator: Equal
value: value2
type: aks
Important
Customer has to explicitly set "enabled": false
in the addonProfile when an AKS cluster provisioning with addon profiles did not successfully complete. Removing the addon section from the config file will NOT remove the addon from the cluster.
Create Nodepool¶
./rctl create nodepool aks -f node-spec.yaml
An illustrative example of the cluster spec YAML file for AKS is shown below
apiVersion: rafay.io/v1alpha1
kind: aksClusterConfig
metadata:
name: demo-aks
spec:
resourceGroupName: my-rg
nodePools:
- type: Microsoft.ContainerService/managedClusters/agentPools
apiVersion: "2021-05-01"
name: agentpooly
properties:
count: 1
maxPods: 30
mode: System
vmSize: Standard_B2s
- type: Microsoft.ContainerService/managedClusters/agentPools
apiVersion: "2021-05-01"
name: agentpoolz
properties:
count: 1
vmSize: Standard_B2s
Download Cluster Config¶
Use the below command to download the AKS Cluster Config file
./rctl get cluster config ClusterName > ClusterConfigFileName.yaml
Example:
/rctl get cluster config demo-aks demo-akscluster-config.yaml
Important
Download the cluster configuration only after the cluster is completely provisioned
List Clusters¶
To retrieve a list of clusters, use the below command
./rctl get cluster
Output
+---------------------+-----------+-----------+
| NAME | TYPE | OWNERSHIP |
+---------------------+-----------+-----------+
| swag-aws | aws-ec2 | self |
+---------------------+-----------+-----------+
| aks19 | azure-aks | self |
+---------------------+-----------+-----------+
| aks1 | azure-aks | self |
+---------------------+-----------+-----------+
To retrieve a single cluster, use the below command
./rctl get cluster <cluster-name>
Example:
./rctl get cluster aks1
Output
+------+----------------------------+-----------+-----------+-------------+-----------------------+
| NAME | CREATED AT | TYPE | STATUS | BLUEPRINT | PROVISION STATUS |
+------+----------------------------+-----------+-----------+-------------+-----------------------+
| aks1 | 2021-09-16T20:44:45.88153Z | azure-aks | NOT_READY | default-aks | INFRA_CREATION_FAILED |
+------+----------------------------+-----------+-----------+-------------+-----------------------+
Delete Cluster¶
Users can delete one or more clusters with a single command
./rctl delete cluster <cluster-name>
(or)
./rctl delete cluster <cluster1-name> <cluster2-name>
Imperative¶
Create Cluster¶
Use this command to create an AKS cluster object in the configured project on the controller. You can optionally also specify the cluster blueprint during this step.
To create an AKS cluster: cloud credential, resource group and Kubernetes version are mandatory
./rctl create cluster aks <demo-aks> --cloud-creds <user-credentials> --resource-group <demo-resoursegroup> --version <k8s-version>
Users can add more flags based on the cluster requirement. The below help flag allows the users to view and utilize the required flags that can be associated with a new cluster
./rctl create cluster aks --help
Below is an example to create an AKS cluster with cluster autoscaler enabled and a custom blueprint:
./rctl create cluster aks <demo-aks> --cloud-creds <user-credentials> --resource-group <demo-resoursegroup> --version <k8s-version> --count 1 --enable-auto-scaling --min-count 1 --max-count 3 --blueprint <blueprint-name>
Create nodePool¶
To create a nodepool on AKS clusters, use the below command
./rctl create nodepool aks <node-pool-name> <cluster-name>
Users can add more flags based on the nodepool requirement. The below help flag allows the users to view and utilize the required flags that can be associated with a new nodepool
./rctl create nodepool aks --help
Below is an example to create a Nodepool on an AKS cluster with cluster autoscaler enabled:
./rctl create node-pool aks newpool ap-aks-2 --enable-auto-scaling --count 1 --max-pods-per-node 50 --node-labels pool=new
Update Nodepool¶
Use the below commands to update a nodePool
./rctl update node-pool aks <np-name> <cluster-name>
./rctl update node-pool aks --help
Scaling command
Auto Scaling
./rctl update node-pool aks <np-name> <cluster-name> --scaling-type auto --min-count <n> --max-count <n>
Example:
./rctl update node-pool aks demo-np demo-cluster --scaling-type auto --min-count 1 --max-count 2
Manual Scaling
./rctl update node-pool aks <np-name> <cluster-name> --scaling-type manual --count <n>
Example:
./rctl update node-pool aks demo-np demo-cluster --scaling-type manual --count 3
Mode change command
./rctl update node-pool aks <np-name> <cluster-name> --mode
Delete Nodepool¶
Use the below command to delete a nodePool
./rctl delete node-pool <node-name> <cluster-name>
Cluster Upgrade¶
Use the below command to upgrade a cluster
./rctl upgrade cluster <cluster-name> --version <version>
Example:
./rctl upgrade cluster kal-aks-nov16 --version 1.20.9
Cluster Node Pool Upgrade¶
Users are allowed to upgrade the Cluster Node Pool with three modes
- Upgrade only node pools
./rctl upgrade cluster ClusterName --mode node-pools-only --node-pools <PoolName> --version <version>
(or)
./rctl upgrade node-pool <nodepool-name> <cluster-name> --version <version>
- Upgrade control plane only
./rctl upgrade cluster <cluster-name> --mode control-plane-only --version <version>
- Upgrade both node pools and control plane
./rctl upgrade cluster <cluster-name> --mode both --version <version>
Node Pool Image Upgrade¶
Use the below command to upgrade a Node Pool image
./rctl upgrade node-pool <nodepool-name> <cluster-name> --image-update