Quickstart: Deploy an Azure Linux Container Host for an AKS cluster using Azure PowerShell

Get started with the Azure Linux Container Host by using Azure PowerShell to deploy an Azure Linux Container Host for an AKS cluster. After installing the prerequisites, you create a resource group, create an AKS cluster, connect to the cluster, and run a sample multi-container application in the cluster.

Prerequisites

Create a resource group

An Azure resource group is a logical group in which Azure resources are deployed and managed. When creating a resource group, you need to specify a location. This location is the storage location of your resource group metadata and where your resources run in Azure if you don't specify another region during resource creation.

The following example creates resource group named testAzureLinuxResourceGroup in the eastus region.

  • Create a resource group using the New-AzResourceGroup cmdlet.

    New-AzResourceGroup -Name testAzureLinuxResourceGroup -Location eastus
    

    The following example output resembles successful creation of the resource group:

    ResourceGroupName : testAzureLinuxResourceGroup
    Location          : eastus
    ProvisioningState : Succeeded
    Tags              :
    ResourceId        : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testAzureLinuxResourceGroup
    

    Note

    The above example uses eastus, but Azure Linux Container Host clusters are available in all regions.

Create an Azure Linux Container Host cluster

The following example creates a cluster named testAzureLinuxCluster with one node.

  • Create an AKS cluster using the New-AzAksCluster cmdlet with the -NodeOsSKU flag set to AzureLinux.

    New-AzAksCluster -ResourceGroupName testAzureLinuxResourceGroup -Name testAzureLinuxCluster -NodeOsSKU AzureLinux
    

    After a few minutes, the command completes and returns JSON-formatted information about the cluster.

Connect to the cluster

To manage a Kubernetes cluster, use the Kubernetes command-line client, kubectl. kubectl is already installed if you use Azure Cloud Shell.

  1. Install kubectl locally using the Install-AzAksCliTool cmdlet.

    Install-AzAksCliTool
    
  2. Configure kubectl to connect to your Kubernetes cluster using the Import-AzAksCredential cmdlet. This command downloads credentials and configures the Kubernetes CLI to use them.

    Import-AzAksCredential -ResourceGroupName testAzureLinuxResourceGroup -Name testAzureLinuxCluster
    
  3. Verify the connection to your cluster using the kubectl get command. This command returns a list of the cluster pods.

    kubectl get pods --all-namespaces
    

Deploy the application

A Kubernetes manifest file defines a cluster's desired state, such as which container images to run.

In this quickstart, you use a manifest to create all objects needed to run the Azure Vote application. This manifest includes two Kubernetes deployments:

  • The sample Azure Vote Python applications.
  • A Redis instance.

This manifest also creates two Kubernetes Services:

  • An internal service for the Redis instance.
  • An external service to access the Azure Vote application from the internet.
  1. Create a file named azure-vote.yaml and copy in the following manifest.

    • If you use the Azure Cloud Shell, you can create the file using code, vi, or nano.
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: azure-vote-back
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: azure-vote-back
      template:
        metadata:
          labels:
            app: azure-vote-back
        spec:
          nodeSelector:
            "kubernetes.io/os": linux
          containers:
          - name: azure-vote-back
            image: mcr.microsoft.com/oss/bitnami/redis:6.0.8
            env:
            - name: ALLOW_EMPTY_PASSWORD
              value: "yes"
            resources:
              requests:
                cpu: 100m
                memory: 128Mi
              limits:
                cpu: 250m
                memory: 256Mi
            ports:
            - containerPort: 6379
              name: redis
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: azure-vote-back
    spec:
      ports:
      - port: 6379
      selector:
        app: azure-vote-back
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: azure-vote-front
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: azure-vote-front
      template:
        metadata:
          labels:
            app: azure-vote-front
        spec:
          nodeSelector:
            "kubernetes.io/os": linux
          containers:
          - name: azure-vote-front
            image: mcr.microsoft.com/azuredocs/azure-vote-front:v1
            resources:
              requests:
                cpu: 100m
                memory: 128Mi
              limits:
                cpu: 250m
                memory: 256Mi
            ports:
            - containerPort: 80
            env:
            - name: REDIS
              value: "azure-vote-back"
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: azure-vote-front
    spec:
      type: LoadBalancer
      ports:
      - port: 80
      selector:
        app: azure-vote-front
    

    For a breakdown of YAML manifest files, see Deployments and YAML manifests.

  2. Deploy the application using the kubectl apply command and specify the name of your YAML manifest:

    kubectl apply -f azure-vote.yaml
    

    The following example resembles output showing the successfully created deployments and services:

    deployment "azure-vote-back" created
    service "azure-vote-back" created
    deployment "azure-vote-front" created
    service "azure-vote-front" created
    

Test the application

When the application runs, a Kubernetes service exposes the application frontend to the internet. This process can take a few minutes to complete.

  1. Monitor progress using the kubectl get service command with the --watch argument.

    kubectl get service azure-vote-front --watch
    

    The EXTERNAL-IP output for the azure-vote-front service initially shows as pending.

    NAME               TYPE           CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
    azure-vote-front   LoadBalancer   10.0.37.27   <pending>     80:30572/TCP   6s
    
  2. Once the EXTERNAL-IP address changes from pending to an actual public IP address, use CTRL-C to stop the kubectl watch process. The following example output shows a valid public IP address assigned to the service:

    azure-vote-front   LoadBalancer   10.0.37.27   52.179.23.131   80:30572/TCP   2m
    
  3. Open a web browser to the external IP address of your service to see the application in action.

    Screenshot of browsing to Azure Vote sample application.

Delete the cluster

If you don't plan on continuing through the following tutorials, remove the created resources to avoid incurring Azure charges.

  • Remove the resource group and all related resources using the RemoveAzResourceGroup cmdlet.

    Remove-AzResourceGroup -Name testAzureLinuxResourceGroup
    

Next steps

In this quickstart, you deployed an Azure Linux Container Host AKS cluster. To learn more about the Azure Linux Container Host and walk through a complete cluster deployment and management example, continue to the Azure Linux Container Host tutorial.