Quickstart: Deploy an application to a new Azure Kubernetes Service (AKS) Automatic cluster (preview) from a code repository

Applies to: ✔️ AKS Automatic (preview)

Use automated deployments to build and deploy an application from a code repository to a new or existing AKS Automatic cluster. Automated deployments simplify the process of setting up a GitHub Action workflow to build and deploy your code. Once connected, every new commit you make kicks off the pipeline. Automated deployments build on draft.sh. When you create a new deployment workflow, you can use an existing Dockerfile, generate a Dockerfile, use existing Kubernetes manifests, or generate Kubernetes manifests. The generated manifests are created with security and resiliency best practices in mind.

In this quickstart, you learn to:

  • Connect to a code repository
  • Containerize your application
  • Configure Kubernetes manifests
  • Create an AKS Automatic cluster
  • Deploy the application via a pull request

Before you begin

  • Register the AutomaticSKUPreview feature in your Azure subscription.
  • Have a GitHub account with the application to deploy.
  • The identity creating the cluster should also have the following permissions on the resource group:
    • Microsoft.Authorization/policyAssignments/write
    • Microsoft.Authorization/policyAssignments/read
  • AKS Automatic clusters require deployment in Azure regions that support at least three availability zones.

Important

AKS Automatic tries to dynamically select a virtual machine size for the system node pool based on the capacity available in the subscription. Make sure your subscription has quota for 16 vCPUs of any of the following sizes in the region you're deploying the cluster to: Standard_D4pds_v5, Standard_D4lds_v5, Standard_D4ads_v5, Standard_D4ds_v5, Standard_D4d_v5, Standard_D4d_v4, Standard_DS3_v2, Standard_DS12_v2. You can view quotas for specific VM-families and submit quota increase requests through the Azure portal.

Bring your application source code

To deploy an application from a code repository, start at the Azure portal home page.

Screenshot showing select 'Deploy application' on the Kubernetes services create menu.

  1. Search for Kubernetes services in the top search bar.
  2. Select Kubernetes services in the search results.
  3. Select the Create button and select Deploy application.

Connect to source code repository

Create and automated deployment workflow and authorize it to connect to the desired source code repository.

  1. In the Basics tab, select Deploy your application.
  2. Under Project details, choose the Subscription, Resource Group, and Region.
  3. Under Repository details, enter a name for the workflow, then select Authorize access to connect to the desired GitHub repository.
  4. Choose the Repository and Branch.
  5. Select the Next button.

Choose the container image configuration

To get an application ready for Kubernetes, you need to build it into a container image and stored into a container registry. You use a Dockerfile to provide instructions on how to build the container image. If your source code repository doesn't already have a Dockerfile, Automated Deployments can generate one for you, otherwise, you can utilize an existing Dockerfile.

Use Automated Deployments to generate a Dockerfile for many languages and frameworks such as Go, C#, Node.js, Python, Java, Gradle, Clojure, PHP, Ruby, Erlang, Swift, and Rust. The language support is built on what's available in draft.sh.

  1. Select Auto-containerize (generate Dockerfile) for the container configuration.
  2. Select the location of where to save the generated Dockerfile in the repository.
  3. Choose the application environment from the list of supported languages and frameworks.
  4. Enter the application port.
  5. Select an existing Azure Container Registry or create a new one. This registry is used to store the built application image. The kubelet identity of the AKS Automatic cluster is given AcrPull permissions on that registry.

Choose the Kubernetes manifest configuration

An application running on Kubernetes consists of many Kubernetes primitive components. These components describe what container image to use, how many replicas to run, if there's a public IP required to expose the application, etc. For more information, see the official Kubernetes documentation. If your source code repository doesn't already have the basic Kubernetes manifests to deploy, Automated Deployments can generate them for you, otherwise, you can utilize a set of existing manifests. You can also choose an existing Helm chart.

Use Automated Deployments to generate a set of basic Kubernetes manifest files to have your application up and running. At the moment, Automated Deployments creates a Deployment, a Service, and a ConfigMap.

The generated manifests are designed to apply recommendations of deployment safeguards, such as:

To generate Kubernetes manifests:

  1. Select Generate application deployment files for the deployment options.
  2. Enter the application port. This port is used on the generated Service.
  3. Select the location of where to save the generated Kubernetes manifests in the repository.
  4. Select the Next button.

Select where you want to deploy the application

If you don't have a cluster already, you can create a new AKS Automatic cluster as part of this deployment.

  1. Select Create Automatic Kubernetes cluster for the cluster configuration.
  2. Enter a cluster name.
  3. Choose the automatic upgrade maintenance schedule or leave the default selected.
  4. Enter the Kubernetes namespace where the application is deployed.
  5. Choose the monitoring and logging level or leave the default selected.
  6. Select the Next button.

Review configuration and deploy

Review the configuration for the cluster, application, and Kubernetes manifests, then select Deploy. Creating a cluster takes a few minutes, don't navigate away from deployment page.

Screenshot showing Deploying the application.

  1. A new AKS Automatic cluster is created or an existing one is configured.
  2. A container registry is created or an existing one is configured with the cluster.
  3. Federated credentials are created to allow the GitHub Action workflow to deploy to the cluster.
  4. A pull request is created on the code repository with any generated files and the workflow.

Review and merge pull request

When the deployment succeeds, select the View pull request button to view the details of the generated pull request on your code repository.

Screenshot of pull request on GitHub.

  1. Review the changes under Files changed and make any desired edits.
  2. Select Merge pull request to merge the changes into your code repository.

Merging the change runs the GitHub Actions workflow that builds your application into a container image, store it in Azure Container Registry, and deploy it to the cluster.

Screenshot showing GitHub Actions workflow in progress.

Check the deployed resources

After the pipeline is completed, you can review the created Kubernetes Service on the Azure portal by selecting Services and ingresses under Kubernetes resources service menu.

Screenshot of the Services and ingresses pane.

Selecting the External IP should open up a new browser page with the running application.

Screenshot showing the Contoso Air application running.

Delete resources

Once you're done with your cluster, can delete it to avoid incurring Azure charges.

  1. In the Azure portal, navigate to your resource group.
  2. Select Delete resource group.
  3. Enter the name of your resource group to confirm deletion and select Delete.
  4. In the Delete confirmation dialog box, select Delete.

Next steps

In this quickstart, you deployed an application to a Kubernetes cluster using AKS Automatic and set up a continuous integration/continious deployment (CI/CD) pipeline from a code repository.

To learn more about AKS Automatic, continue to the introduction.