Deploy KubeSphere on AKS

This guide walks you through the steps of deploying KubeSphere on Azure Kubernetes Service.

Prepare an AKS cluster

Azure can help you implement infrastructure as code by providing resource deployment automation options. Commonly adopted tools include ARM templates and Azure CLI. In this guide, we will use Azure CLI to create all the resources that are needed for the installation of KubeSphere.

Use Azure Cloud Shell

You don’t have to install Azure CLI on your machine as Azure provides a web-based terminal. Click the Cloud Shell button on the menu bar at the upper-right corner in Azure portal.

Cloud Shell

Select Bash Shell.

Bash Shell

Create a Resource Group

An Azure resource group is a logical group in which Azure resources are deployed and managed. The following example creates a resource group named KubeSphereRG in the location westus.

  1. az group create --name KubeSphereRG --location westus

Create an AKS Cluster

Use the command az aks create to create an AKS cluster. The following example creates a cluster named KuberSphereCluster with three nodes. This will take several minutes to complete.

  1. az aks create --resource-group KubeSphereRG --name KuberSphereCluster --node-count 3 --enable-addons monitoring --generate-ssh-keys

Note

You can use --node-vm-size or -s option to change the size of Kubernetes nodes. The default node size is Standard_DS2_v2 (2vCPU, 7GB memory). For more options, see az aks create.

Connect to the Cluster

To configure kubectl to connect to the Kubernetes cluster, use the command az aks get-credentials. This command downloads the credentials and configures that the Kubernetes CLI will use.

  1. az aks get-credentials --resource-group KubeSphereRG --name KuberSphereCluster
  1. $ kubectl get nodes
  2. NAME STATUS ROLES AGE VERSION
  3. aks-nodepool1-23754246-vmss000000 Ready agent 38m v1.16.13

Check Azure Resources in the Portal

After you execute all the commands above, you can see there are 2 Resource Groups created in Azure Portal.

Resource groups

Azure Kubernetes Services itself will be placed in KubeSphereRG.

Azure Kubernetes Services

All the other Resources will be placed in MC_KubeSphereRG_KuberSphereCluster_westus, such as VMs, Load Balancer and Virtual Network.

Azure Kubernetes Services

Deploy KubeSphere on AKS

To start deploying KubeSphere, use the following commands.

  1. kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.2.0/kubesphere-installer.yaml
  2. kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.2.0/cluster-configuration.yaml

You can inspect the logs of installation through the following command:

  1. kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f

Access KubeSphere Console

To access KubeSphere console from a public IP address, you need to change the service type to LoadBalancer.

  1. kubectl edit service ks-console -n kubesphere-system

Find the following section and change the type to LoadBalancer.

  1. spec:
  2. clusterIP: 10.0.78.113
  3. externalTrafficPolicy: Cluster
  4. ports:
  5. - name: nginx
  6. nodePort: 30880
  7. port: 80
  8. protocol: TCP
  9. targetPort: 8000
  10. selector:
  11. app: ks-console
  12. tier: frontend
  13. version: v3.0.0
  14. sessionAffinity: None
  15. type: LoadBalancer # Change NodePort to LoadBalancer
  16. status:
  17. loadBalancer: {}

After saving the configuration of ks-console service, you can use the following command to get the public IP address (under EXTERNAL-IP). Use the IP address to access the console with the default account and password (admin/[[email protected]](https://kubesphere.io/cdn-cgi/l/email-protection)).

  1. $ kubectl get svc/ks-console -n kubesphere-system
  2. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  3. ks-console LoadBalancer 10.0.181.93 13.86.xxx.xxx 80:30194/TCP 13m 6379/TCP 10m

Enable Pluggable Components (Optional)

The example above demonstrates the process of a default minimal installation. For pluggable components, you can enable them either before or after the installation. See Enable Pluggable Components for details.