Quickstart: Create Application Gateway for Containers - bring your own deployment
Artikel
This guide assumes you're following the bring your owndeployment strategy, where ALB Controller references the Application Gateway for Containers resources precreated in Azure. It's assumed that resource lifecycles are managed in Azure, independent from what is defined within Kubernetes.
Create the Application Gateway for Containers resource
Execute the following command to create the Application Gateway for Containers resource.
Azure CLI
RESOURCE_GROUP='<your resource group name>'
AGFC_NAME='alb-test'# Name of the Application Gateway for Containers resource to be createdaz network alb create -g$RESOURCE_GROUP-n$AGFC_NAME
Create a frontend resource
Execute the following command to create the Application Gateway for Containers frontend resource.
To create an association resource, you first need to reference a subnet for Application Gateway for Containers to establish connectivity to. Ensure the subnet for an Application Gateway for Containers association is at least a class C or larger (/24 or smaller CIDR prefix). For this step, you may either reuse an existing subnet and enable subnet delegation on it or create a new VNET, subnet, and enable subnet delegation.
To reference an existing subnet, execute the following command to set the variables for reference to the subnet in later steps.
Azure CLI
VNET_NAME='<name of the virtual network to use>'
VNET_RESOURCE_GROUP='<the resource group of your VNET>'
ALB_SUBNET_NAME='subnet-alb'# subnet name can be any non-reserved subnet name (i.e. GatewaySubnet, AzureFirewallSubnet, AzureBastionSubnet would all be invalid)
If you would like to use a new virtual network for the Application Gateway for Containers association resource, you can create a new vnet with the following commands.
Amaran
Upon creation of the virtual network, ensure you establish connectivity between this virtual network/subnet and the AKS node pool to enable communication between Application Gateway for Containers and the pods running in AKS. This may be achieved by establishing virtual network peering between both virtual networks.
Azure CLI
VNET_NAME='<name of the virtual network to use>'
VNET_RESOURCE_GROUP='<the resource group of your VNET>'
VNET_ADDRESS_PREFIX='<address space of the vnet that will contain various subnets. The vnet must be able to handle at least 250 available addresses (/24 or smaller cidr prefix for the subnet)>'
SUBNET_ADDRESS_PREFIX='<an address space under the vnet that has at least 250 available addresses (/24 or smaller cidr prefix for the subnet)>'
ALB_SUBNET_NAME='subnet-alb'# subnet name can be any non-reserved subnet name (i.e. GatewaySubnet, AzureFirewallSubnet, AzureBastionSubnet would all be invalid)az network vnet create \
--name$VNET_NAME \
--resource-group$VNET_RESOURCE_GROUP \
--address-prefix$VNET_ADDRESS_PREFIX \
--subnet-name$ALB_SUBNET_NAME \
--subnet-prefixes$SUBNET_ADDRESS_PREFIX
Enable subnet delegation for the Application Gateway for Containers service. The delegation for Application Gateway for Containers is identified by the Microsoft.ServiceNetworking/trafficControllers resource type.
ALB Controller needs the ability to provision new Application Gateway for Containers resources and join the subnet intended for the Application Gateway for Containers association resource.
In this example, we delegate the AppGW for Containers Configuration Manager role to the resource group and delegate the Network Contributor role to the subnet used by the Application Gateway for Containers association subnet, which contains the Microsoft.Network/virtualNetworks/subnets/join/action permission.
If desired, you can create and assign a custom role with the Microsoft.Network/virtualNetworks/subnets/join/action permission to eliminate other permissions contained in the Network Contributor role. Learn more about managing subnet permissions.
Azure CLI
IDENTITY_RESOURCE_NAME='azure-alb-identity'
resourceGroupId=$(az group show --name$RESOURCE_GROUP--query id -otsv)
principalId=$(az identity show -g$RESOURCE_GROUP-n$IDENTITY_RESOURCE_NAME--query principalId -otsv)
# Delegate AppGw for Containers Configuration Manager role to RG containing Application Gateway for Containers resourceaz role assignment create --assignee-object-id$principalId--assignee-principal-type ServicePrincipal --scope$resourceGroupId--role"fbc52c3f-28ad-4303-a892-8a056630b8f1"# Delegate Network Contributor permission for join to association subnetaz role assignment create --assignee-object-id$principalId--assignee-principal-type ServicePrincipal --scope$ALB_SUBNET_ID--role"4d97b98b-1d4f-4787-a291-c67834d212e7"
Create an association resource
Execute the following command to create the association resource and connect it to the referenced subnet. It can take 5-6 minutes for the Application Gateway for Containers association to be created.
Azure CLI
ASSOCIATION_NAME='association-test'az network alb association create -g$RESOURCE_GROUP-n$ASSOCIATION_NAME--alb-name$AGFC_NAME--subnet$ALB_SUBNET_ID
Next steps
Congratulations, you have installed ALB Controller on your cluster and deployed the Application Gateway for Containers resources in Azure!
Try out a few of the how-to guides to deploy a sample application, demonstrating some of Application Gateway for Container's load balancing concepts.
Welcome to this interactive skills validation experience. Completing this module helps prepare you for the Deploy and manage containers with Azure Kubernetes Service assessment.