Creating an AKS Cluster

  1. Login into Azure. Execute the following command and follow the instructions.
    az login
  2. Set the subscription account that you want to use.
    azaccountset--subscription <subscriptionID>
  3. Create a resource group for K8S cluster. Use the following command to create a resource group:
    az group create --name <resourceGroupName> --location eastus
    Note: To see the availability of AKS according to region, refer to this chart: https://azure.microsoft.com/en-us/global-infrastructure/services/.
  4. Create a container registry inside the resource group created in step 3:
    az acr create --resource-group <resourceGroupName> --name <acrName> --sku Basic
    Sample command and output of the create Azure Container Registry:
    {
    
      "adminUserEnabled": false,
    
      "creationDate": "2018-10-16T19:04:25.870380+00:00",
    
      "id": "/subscriptions/<subscriptionID>/resourceGroups/ashishAKS/providers/Microsoft.ContainerRegistry/registries/ml5acreast",
    
      "location": "eastus",
    
      "loginServer": "ml5acreast.azurecr.io",
    
      "name": "ml5acreast",
    
      "provisioningState": "Succeeded",
    
      "resourceGroup": "ml5AKS",
    
      "sku": {
    
        "name": "Basic",
    
        "tier": "Basic"
    
      },
    
      "status": null,
    
      "storageAccount": null,
    
      "tags": {},
    
      "type": "Microsoft.ContainerRegistry/registries"
    
    }
    Note: If the above command prompts you to create the service principal or assign the appID to the existing principal, follow these instructions, and then retry creating the registry.
    To create a new service principal and assign access, run the following command:
    az ad sp create-for-rbac --scopes
    /subscriptions/<subscriptionID>/resourceGroups/< resourceGroupName>/providers/Microsoft.ContainerRegistry/registries/ <acrName> --role Owner --password
    <password>
    To use an existing service principal and assign access, run the following command:
    az role assignment create --scope
    /subscriptions//<subscriptionID>/resourceGroups/< resourceGroupName>/providers/Microsoft.ContainerRegistry/registries/ <acrName> --role Owner --assignee
    <app-id>
    To find the appId of an existing service principal from the output, run the following command:
    az ad sp list --display-name <servicePrincipalName> | grep appId
  5. Login into container registry:
    az acr login --name <acrName>
  6. Go to the Azure portal and create K8S cluster as shown below. Click Add, fill the required details and follow the instructions.
    Note: Select the resource group you created in Step 3 and Kubernetes version as 1.10.7. Select Node size and count as desired. Recommended is 4 core CPU with 16GB Memory.


  7. After successful creation, the container registry and k8s cluster is created under the resource group as shown below.

Configure kubectl and Install the Kubernetes Dashboard UI

To install the Kubernetes Dashboard UI:
  1. Configure kubectl to connect this cluster.
    az aks get-credentials --resource-group <resource_group_name> --name <k8s_cluster_name>
    For example:
    az aks get-credentials --resource-group ml51rg --name ml51ns
    The output from the example command should look like:
    Merged "ml51ns" as current context in /Users/<XYZ>/.kube/config
    This is must before going further.
    Note: If you modified the k8s_deploy_namespace to deploy Mashery Local 5.1 in a specific namespace in the k8s cluster, you need to configure kubectl again for the given namespace. After running the above command, your kube config file (~/.kube/config) will have an entry for the AKS k8s cluster and user as shown below.
    apiVersion: v1
    
    clusters:
    
    - cluster:
    
        certificate-authority-data: abc
    
        server: https://ml51ns-dns-x.hcp.eastus.azmk8s.io:443
    
      name: ml51ns
    
    contexts:
    
    - context:
    
        cluster: ml51ns
    
        user: clusterUser_ml51rg_ml51ns
    
      name: ml51ns
    
    current-context: ml51ns
    
    kind: Config
    
    preferences: {}
    
    users:
    
    - name: clusterUser_ml51rg_ml51ns
    
      user:
    
        client-certificate-data: xyz

    Note the value of cluster and user.

    Execute the following commands to create a new context for the namespace you want to deploy and configure kubectl to use the new context.
    1. kubectl config set-context <conext-name> --namespace=<namespace_value provided in the manifest-single-zone.json> --cluster=<k8s cluster name > --user=<k8s user>
      Sample command:
      kubectl config set-context mashery-dev --namespace=mashery
      --cluster=ml51ns --user=clusterUser_ml51rg_ml51ns
    2. kubectl config use-context <context-name>
      Sample command:
      kubectl config use-context mashery-dev
  2. Open another terminal and run the following command to start dashboard:
    az aks browse --resource-group <resource_group_name> --name <k8s_cluster_name>