Skip to content

Files

Latest commit

7e303ca · Mar 18, 2022

History

History
105 lines (69 loc) · 6.37 KB

tutorial-ingress-controller-add-on-new.md

File metadata and controls

105 lines (69 loc) · 6.37 KB
title description services author ms.service ms.topic ms.date ms.author
Tutorial: Enable the Ingress Controller add-on for a new AKS cluster with a new Azure Application Gateway
Use this tutorial to learn how to enable the Ingress Controller add-on for your new AKS cluster with a new Application Gateway instance.
application-gateway
caya
application-gateway
tutorial
03/02/2021
caya

Tutorial: Enable the Ingress Controller add-on for a new AKS cluster with a new Application Gateway instance

You can use the Azure CLI to enable the Application Gateway Ingress Controller (AGIC) add-on for a new Azure Kubernetes Services (AKS) cluster.

In this tutorial, you'll create an AKS cluster with the AGIC add-on enabled. Creating the cluster will automatically create an Azure Application Gateway instance to use. You'll then deploy a sample application that will use the add-on to expose the application through Application Gateway.

The add-on provides a much faster way to deploy AGIC for your AKS cluster than previously through Helm. It also offers a fully managed experience.

In this tutorial, you learn how to:

[!div class="checklist"]

  • Create a resource group.
  • Create a new AKS cluster with the AGIC add-on enabled.
  • Deploy a sample application by using AGIC for ingress on the AKS cluster.
  • Check that the application is reachable through Application Gateway.

[!INCLUDE quickstarts-free-trial-note]

[!INCLUDE azure-cli-prepare-your-environment.md]

Create a resource group

In Azure, you allocate related resources to a resource group. Create a resource group by using az group create. The following example creates a resource group named myResourceGroup in the canadacentral location (region):

az group create --name myResourceGroup --location canadacentral

Deploy an AKS cluster with the add-on enabled

You'll now deploy a new AKS cluster with the AGIC add-on enabled. If you don't provide an existing Application Gateway instance to use in this process, we'll automatically create and set up a new Application Gateway instance to serve traffic to the AKS cluster.

Note

The Application Gateway Ingress Controller add-on supports only Application Gateway v2 SKUs (Standard and WAF), and not the Application Gateway v1 SKUs. When you're deploying a new Application Gateway instance through the AGIC add-on, you can deploy only an Application Gateway Standard_v2 SKU. If you want to enable the add-on for an Application Gateway WAF_v2 SKU, use either of these methods:

In the following example, you'll deploy a new AKS cluster named myCluster by using Azure CNI and managed identities. The AGIC add-on will be enabled in the resource group that you created, myResourceGroup.

Deploying a new AKS cluster with the AGIC add-on enabled without specifying an existing Application Gateway instance will mean an automatic creation of a Standard_v2 SKU Application Gateway instance. So, you'll also specify the name and subnet address space of the Application Gateway instance. The name of the Application Gateway instance will be myApplicationGateway, and the subnet address space we're using is 10.2.0.0/16.

az aks create -n myCluster -g myResourceGroup --network-plugin azure --enable-managed-identity -a ingress-appgw --appgw-name myApplicationGateway --appgw-subnet-cidr "10.2.0.0/16" --generate-ssh-keys

To configure additional parameters for the az aks create command, see these references.

Note

The AKS cluster that you created will appear in the resource group that you created, myResourceGroup. However, the automatically created Application Gateway instance will be in the node resource group, where the agent pools are. The node resource group by is named MC_resource-group-name_cluster-name_location by default, but can be modified.

Deploy a sample application by using AGIC

You'll now deploy a sample application to the AKS cluster that you created. The application will use the AGIC add-on for ingress and connect the Application Gateway instance to the AKS cluster.

First, get credentials to the AKS cluster by running the az aks get-credentials command:

az aks get-credentials -n myCluster -g myResourceGroup

Now that you have credentials, run the following command to set up a sample application that uses AGIC for ingress to the cluster. AGIC will update the Application Gateway instance that you set up earlier with corresponding routing rules to the new sample application that you deployed.

kubectl apply -f https://raw.githubusercontent.com/Azure/application-gateway-kubernetes-ingress/master/docs/examples/aspnetapp.yaml 

Check that the application is reachable

Now that the Application Gateway instance is set up to serve traffic to the AKS cluster, let's verify that your application is reachable. First, get the IP address of the ingress:

kubectl get ingress

Check that the sample application that you created is running by either:

  • Visiting the IP address of the Application Gateway instance that you got from running the preceding command.
  • Using curl.

Application Gateway might take a minute to get the update. If Application Gateway is still in an Updating state on the portal, let it finish before you try to reach the IP address.

Clean up resources

When you no longer need them, remove the resource group, the Application Gateway instance, and all related resources:

az group delete --name myResourceGroup

Next steps

[!div class="nextstepaction"] Learn about disabling the AGIC add-on