Deploy KubeSphere on Azure VM Instances

    Alternatively, you can set up a highly-available cluster on Azure instances. This tutorial demonstrates how to create a production-ready Kubernetes and KubeSphere cluster.

    This tutorial uses two key features of Azure virtual machines (VMs):

    • Virtual Machine Scale Sets (VMSS): Azure VMSS let you create and manage a group of load balanced VMs. The number of VM instances can automatically increase or decrease in response to demand or a defined schedule (Kubernetes Autoscaler is available, but not covered in this tutorial. See for more details), which perfectly fits Worker nodes.
    • Availability Sets: An availability set is a logical grouping of VMs within a datacenter that are automatically distributed across fault domains. This approach limits the impact of potential physical hardware failures, network outages, or power interruptions. All the Master and etcd VMs will be placed in an availability set to achieve high availability.

    Besides these VMs, other resources like Load Balancer, Virtual Network and Network Security Group will also be used.

    Prerequisites

    • You need an account to create all the resources.
    • Basic knowledge of Azure Resource Manager (ARM) templates, which are files that define the infrastructure and configuration for your project.
    • For a production environment, it is recommended that you prepare persistent storage and create a StorageClass in advance. For development and testing, you can use , which is installed by KubeKey by default, to provision LocalPV directly.

    Six machines of Ubuntu 18.04 will be deployed in an Azure Resource Group. Three of them are grouped into an availability set, serving as both the Master and etcd nodes. The other three VMs will be defined as a VMSS where Worker nodes will be running.

    These VMs will be attached to a load balancer. There are two predefined rules in the load balancer:

    • Inbound NAT: The SSH port will be mapped for each machine so that you can easily manage VMs.
    • Load Balancing: The http and https ports will be mapped to Node pools by default. Other ports can be added on demand.

    Create HA Cluster Infrastructrue

    You don’t have to create these resources one by one. According to the best practice of infrastructure as code on Azure, all resources in the architecture are already defined as ARM templates.

    1. Click the Deploy button below, and you will be redirected to Azure and asked to fill in deployment parameters.

    2. On the page that appears, only few parameters need to be changed. Click Create new under Resource group and enter a name such as .

    3. Enter Admin Username.

    4. Copy your public SSH key for the field Admin Key. Alternatively, create a new one with ssh-keygen.

      azure-template-parameters

      Note

    5. Click Purchase at the bottom to continue.

    Review Azure resources in the Portal

    After successfully created, all the resources will display in the resource group KubeSphereVMRG. Record the public IP of the load balancer and the private IP addresses of the VMs. You will need them later.

    Execute the following commands on your device or connect to one of the Master VMs through SSH. During the installation, files will be downloaded and distributed to each VM.

    Kubekey is a brand-new installation tool which provides an easy, fast and flexible way to install Kubernetes and KubeSphere.

    1. Download it so that you can generate a configuration file in the next step.

      Download KubeKey from its or use the following command directly:

        Run the following command first to make sure you download KubeKey from the correct zone.

        1. export KKZONE=cn

        Run the following command to download KubeKey:

        1. curl -sfL https://get-kk.kubesphere.io | VERSION=v1.2.0 sh -

        Note

        After you download KubeKey, if you transfer it to a new machine also with poor network connections to Googleapis, you must run export KKZONE=cn again before you proceed with the steps below.

        Note

        The commands above download the latest release (v1.2.0) of KubeKey. You can change the version number in the command to download a specific version.

        Make kk executable:

        1. ./kk create config --with-kubesphere v3.2.0 --with-kubernetes v1.21.5

        Note

        • Recommended Kubernetes versions for KubeSphere 3.2.0: v1.19.x, v1.20.x, v1.21.x or v1.22.x (experimental). If you do not specify a Kubernetes version, KubeKey will install Kubernetes v1.21.5 by default. For more information about supported Kubernetes versions, see Support Matrix.

        • If you do not add the flag --with-kubesphere in the command in this step, KubeSphere will not be deployed unless you install it using the addons field in the configuration file or add this flag again when you use ./kk create cluster later.

        • If you add the flag --with-kubesphere without specifying a KubeSphere version, the latest version of KubeSphere will be installed.

      Example configurations

      1. spec:
      2. hosts:
      3. - {name: master-0, address: 40.81.5.xx, port: 50200, internalAddress: 10.0.1.4, user: kubesphere, privateKeyPath: "~/.ssh/id_rsa"}
      4. - {name: master-1, address: 40.81.5.xx, port: 50201, internalAddress: 10.0.1.5, user: kubesphere, privateKeyPath: "~/.ssh/id_rsa"}
      5. - {name: master-2, address: 40.81.5.xx, port: 50202, internalAddress: 10.0.1.6, user: kubesphere, privateKeyPath: "~/.ssh/id_rsa"}
      6. - {name: node000000, address: 40.81.5.xx, port: 50100, internalAddress: 10.0.0.4, user: kubesphere, privateKeyPath: "~/.ssh/id_rsa"}
      7. - {name: node000001, address: 40.81.5.xx, port: 50101, internalAddress: 10.0.0.5, user: kubesphere, privateKeyPath: "~/.ssh/id_rsa"}
      8. roleGroups:
      9. etcd:
      10. - master-0
      11. - master-1
      12. - master-2
      13. master:
      14. - master-0
      15. - master-1
      16. - master-2
      17. worker:
      18. - node000000
      19. - node000001

      For more information, see this file.

      In addition to node information, you need to configure your load balancer in the same YAML file. For the IP address, you can find it in Azure > KubeSphereVMRG > PublicLB. Assume the IP address and listening port of the load balancer are 40.81.5.xx and 6443 respectively, and you can refer to the following example.

      1. ## Public LB config example
      2. ## apiserver_loadbalancer_domain_name: "lb.kubesphere.local"
      3. controlPlaneEndpoint:
      4. domain: lb.kubesphere.local
      5. port: "6443"

      Note

      The public load balancer is used directly instead of an internal load balancer due to Azure .

      Persistent storage plugin configurations

      See for details.

      Azure Virtual Network doesn’t support the IPIP mode used by Calico. You need to change the network plugin to flannel.

      Create a cluster

      1. After you complete the configuration, you can execute the following command to start the installation:

        1. ./kk create cluster -f config-sample.yaml
      2. Inspect the logs of installation:

        1. kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f
      3. When the installation finishes, you can see the following message:

        1. #####################################################
        2. ### Welcome to KubeSphere! ###
        3. #####################################################
        4. Console: http://10.128.0.44:30880
        5. Account: admin
        6. Password: [email protected]
        7. NOTES
        8. 1. After you log into the console, please check the
        9. monitoring status of service components in
        10. the "Cluster Management". If any service is not
        11. ready, please wait patiently until all components
        12. are up and running.
        13. 2. Please change the default password after login.
        14. #####################################################
        15. https://kubesphere.io 2020-xx-xx xx:xx:xx
      4. Access the KubeSphere console using with the default account and password (admin/[[email protected]](https://kubesphere.io/cdn-cgi/l/email-protection)).

      Add Additional Ports

      1. Create an Inbound Security rule to allow Internet access in the Network Security Group. Firewall