# How to Create an AKS Cluster with Cilium > [!NOTE] > **WHAT TO EXPECT** > > In order to have an operational xNICv2 DaemonSet, a managed cluster using Azure Kubernetes Service (AKS) with Cilium CNI must be deployed. > > **Note**: The AKS service **cannot be installed** using the Azure Kubernetes Service console, as the only network types that it supports are "Kubenet" and "Azure CNI." The xNIC must be installed on AKS Cilium as the network. > > **In this article**, you will learn the following: > > - [How to Create an Azure Kubernetes Service (AKS)](#aks-creation) > - [How to Install Cilium on AKS](#cilium-on-aks-installation) #### Pre-Creation Steps If an AKS Cilium does not already exist, then the following steps can be used to create one.  If it does exist but Cilium is not installed, then go to the section, [Cilium on AKS Installation](#cilium-on-aks-installation). Prior to running the script, ensure the following are already created in Azure: - **Azure Resource Group** (must be same as the one used to create the cloudSwXtch ) - **Azure VNET** (must be same as the one used to create the cloudSwXtch ) - **Azure Control Subnet** (must be same as the one used to create the cloudSwXtch ) Each of these components **must match** the one used to create the cloudSwXtch on Azure. The cluster nodes must be able to reach the cloudSwXtch control IP on **TCP 9443** (control) and **TCP 443** (the cloudSwXtch's xNIC image registry). #### AKS Creation After verifying their match, complete these steps: 1. Log into **Azure portal.** 2. Open **cloudShell** as bash. ![Azure portal with the Cloud Shell icon highlighted in the top bar and Cloud Shell open in Bash at the bottom](../../../assets/document360/2f44a626da-aks-install-azure-cloudshell-as-bash.png) 3. Run the following script to get security data: ``` az network vnet subnet show -g "Azure_Resource_Group" -n "Azure_subnet_ctrl" --vnet-name "Azure-VNET" --query id --output tsv ``` 4. Copy the entire output for the next command: ```  az aks create \ --generate-ssh-keys \ --resource-group "Azure_Resource_Group" \ --network-plugin none \ --name cilium-sample \ --vnet-subnet-id "entire ouptput from above command" \ --node-vm-size Standard_Ds2_v2 \ --node-count 2 ActionScript ``` 1. The following will have to be replaced in the script: - **The Resource Group**:   "Azure\_Resource\_Group"  - Change to the Resource group desired. This must be the same resource group as your cloudSwXtch. - **The Name**:  NAME="cilium-sample"- Change to an appropriate name for your AKS. - **The vnet-subnet-id**:  Will be the entire output of the previous command. 5. Edit the script with your desired values. Below is an example with filled in data: ``` az aks create \  --generate-ssh-keys \ --resource-group MyNetwork \ --network-plugin none \ --name cilium-sample2 \ --vnet-subnet-id /subscriptions/b10209ad-ad22-4c27-9aef-be93b2f0bb58/resourceGroups/MyNetwork/providers/Microsoft.Network/virtualNetworks/my-vnet/subnets/my-subnet-ctrl \ --node-vm-size Standard_Ds2_v2 \ --node-count 2 ``` 1. This script will create 2 nodes. If more is desired, you can change it by increasing the node count. 6. Open **cloudShell** as bash. ![Azure portal with the Cloud Shell icon highlighted in the top bar and Cloud Shell open in Bash at the bottom](../../../assets/document360/2f44a626da-aks-install-azure-cloudshell-as-bash.png) 7. Paste in the script and hit **Enter**. 8. Wait for the script to complete. 1. You may get the following warning: "Could not create a role assignment for subnet. Are you an Owner on this subscription?" This is nothing to be concerned about. The cluster is created with 1 node pool containing 2 nodes as shown below: ![Azure Kubernetes services, node pools of the cluster, Nodes tab: two nodes in Ready status with their Kubernetes, node image and container runtime versions](../../../assets/document360/fe0d3d9200-aks-install-azure-aks-cilium-created.png) To ensure that credentials are properly set, run the following command where "Your-AKS-Name" is the name given in Step 4a: ``` az aks get-credentials --resource-group "Azure_Resource_Group" --name "Your-AKS-Name" ``` To validate, run the following command: ``` kubectl config get-contexts ``` Here is an example output: ``` donna@Azure:~$ kubectl config get-contexts CURRENT   NAME                 CLUSTER              AUTHINFO                                          NAMESPACE *         cilium-sample-200    cilium-sample-200    clusterUser_test-donna-200-rg_cilium-sample-200          cilium-sample2       cilium-sample2       clusterUser_saDevNetwork_cilium-sample2          dsd-k8-cluster-100   dsd-k8-cluster-100   clusterUser_saDevNetwork_dsd-k8-cluster-100 ``` #### Cilium on AKS Installation The section above created the AKS without a network. **Cilium** will provide network connectivity to the whole cluster. This section will describe how to install the Cilium CNI on an existing AKS without a network. Please refer to the [Cilium Official Documentation](https://docs.cilium.io/en/stable/gettingstarted/k8s-install-default/ "https://docs.cilium.io/en/stable/gettingstarted/k8s-install-default/") or run the shell script provided next to install Cilium CLI: ``` CILIUM_CLI_VERSION=$(curl -s https://raw.githubusercontent.com/cilium/cilium-cli/master/stable.txt) CLI_ARCH=amd64 if [ "$(uname -m)" = "aarch64" ]; then CLI_ARCH=arm64; fi curl -L --fail --remote-name-all https://github.com/cilium/cilium-cli/releases/download/${CILIUM_CLI_VERSION}/cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum} sha256sum -c cilium-linux-${CLI_ARCH}.tar.gz.sha256sum mkdir -p ~/bin tar xzvf cilium-linux-${CLI_ARCH}.tar.gz -C /usr/local/bin -C ~/bin rm cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum} ``` 1. Copy the code above into a **Text Editor** and name the file **cilium-install.sh.** 2. Open **CloudShell** as Bash.![Azure portal with the Cloud Shell icon highlighted in the top bar and Cloud Shell open in Bash at the bottom](../../../assets/document360/2f44a626da-aks-install-azure-cloudshell-as-bash.png) 3. Upload the edited file using the Bash **Upload** feature. ![Azure Cloud Shell toolbar with the upload/download icon open and Upload highlighted](../../../assets/document360/25ba841d94-aks-install-azure-cloudshell-upload-file.png) 4. Run the following command to change the script to an executable in the Azure Bash window: ``` chmod +x cilium-install.sh ``` 5. Run the following command to run the executable in the Azure Bash window: ``` ./cilium-install.sh ``` 6. Run the script below, replacing the azure-resource group with the resource group used to create the AKS and that the cloudSwXtch was deployed with. This will install Cilium as the CNI for the AKS cluster. ``` cilium install --azure-resource-group "your resource group" ``` 7. Validate that it was successfully installed by running this command: ``` cilium status ``` 1. An example of the validation is illustrated below: ``` $ cilium status    /¯¯\ /¯¯\__/¯¯\ Cilium: OK \__/¯¯\__/ Operator: OK /¯¯\__/¯¯\ Hubble Relay: OK \__/¯¯\__/ ClusterMesh: disabled \__/ Deployment hubble-relay Desired: 1, Ready: 1/1, Available: 1/1 Deployment cilium-operator Desired: 1, Ready: 1/1, Available: 1/1 DaemonSet cilium Desired: 2, Ready: 2/2, Available: 2/2 Containers: cilium Running: 2 hubble-relay Running: 1 cilium-operator Running: 1 Cluster Pods: 10/10 managed by Cilium Image versions cilium quay.io/cilium/cilium:v1.13.1@sha256:428a09552707cc90228b7ff48c6e7a33dc0a97fe1dd93311ca672834be25beda: 2 hubble-relay quay.io/cilium/hubble-relay:v1.13.1@sha256:ad7ce650c7877f8d769264e20bf5b9020ea778a9530cfae9d67a5c9d942c04cb: 1 cilium-operator quay.io/cilium/operator-generic:v1.13.1@sha256:f47ba86042e11b11b1a1e3c8c34768a171c6d8316a3856253f4ad4a92615d555: 1 $ ``` **Note**: The Hubble Relay and ClusterMesh may not be enabled. This does not impact xNIC operation. > [!NOTE] > **NEXT STEPS** > > The prerequisites have been completed. You can now continue onto the next step, [Install xNIC2 on AKS Cilium](../../../cloudswxtch/installing-xnic/install-xnic-on-kubernetes/install-xnic-daemonset-on-k8s-cluster.md).