クイックスタート: Application Gateway for Containers ALB コントローラーをデプロイする
[アーティクル]
2025/02/15
ALB コントローラーは、Kubernetes 内のゲートウェイ API とイングレス API 構成を、Application Gateway for Containers 内の負荷分散規則に変換する役割を担います。 以下のガイドでは、ALB コントローラーを新規または既存の AKS クラスターにプロビジョニングするために必要な手順について説明します。
前提条件
Azure に Application Gateway for Containers をデプロイし、クラスターに ALB コントローラーをインストールする前に、次のタスクを完了する必要があります。
Azure サブスクリプションと az-cli クライアントを準備します。
# Sign in to your Azure subscription.
SUBSCRIPTION_ID='<your subscription id>'
az login
az account set --subscription $SUBSCRIPTION_ID
# Register required resource providers on Azure.
az provider register --namespace Microsoft.ContainerService
az provider register --namespace Microsoft.Network
az provider register --namespace Microsoft.NetworkFunction
az provider register --namespace Microsoft.ServiceNetworking
# Install Azure CLI extensions.
az extension add --name alb
既存のクラスターを使用している場合は、AKS クラスターでワークロード ID のサポートを有効にしてください。 ワークロード ID は、以下の方法で有効にすることができます。
AKS_NAME='<your cluster name>'
RESOURCE_GROUP='<your resource group name>'
az aks update -g $RESOURCE_GROUP -n $AKS_NAME --enable-oidc-issuer --enable-workload-identity --no-wait
既存のクラスターがない場合は、以下のコマンドを使用して、Azure CNI とワークロード ID が有効になっている新しい AKS クラスターを作成します。
AKS_NAME='<your cluster name>'
RESOURCE_GROUP='<your resource group name>'
LOCATION='northeurope'
VM_SIZE='<the size of the vm in AKS>' # The size needs to be available in your location
az group create --name $RESOURCE_GROUP --location $LOCATION
az aks create \
--resource-group $RESOURCE_GROUP \
--name $AKS_NAME \
--location $LOCATION \
--node-vm-size $VM_SIZE \
--network-plugin azure \
--enable-oidc-issuer \
--enable-workload-identity \
--generate-ssh-key
ALB コントローラーのユーザー マネージド ID を作成し、AKS クラスターで使用するワークロード ID として ID をフェデレーションします。
RESOURCE_GROUP='<your resource group name>'
AKS_NAME='<your aks cluster name>'
IDENTITY_RESOURCE_NAME='azure-alb-identity'
mcResourceGroup=$(az aks show --resource-group $RESOURCE_GROUP --name $AKS_NAME --query "nodeResourceGroup" -o tsv)
mcResourceGroupId=$(az group show --name $mcResourceGroup --query id -otsv)
echo "Creating identity $IDENTITY_RESOURCE_NAME in resource group $RESOURCE_GROUP"
az identity create --resource-group $RESOURCE_GROUP --name $IDENTITY_RESOURCE_NAME
principalId="$(az identity show -g $RESOURCE_GROUP -n $IDENTITY_RESOURCE_NAME --query principalId -otsv)"
echo "Waiting 60 seconds to allow for replication of the identity..."
sleep 60
echo "Apply Reader role to the AKS managed cluster resource group for the newly provisioned identity"
az role assignment create --assignee-object-id $principalId --assignee-principal-type ServicePrincipal --scope $mcResourceGroupId --role "acdd72a7-3385-48ef-bd42-f606fba81ae7" # Reader role
echo "Set up federation with AKS OIDC issuer"
AKS_OIDC_ISSUER="$(az aks show -n "$AKS_NAME" -g "$RESOURCE_GROUP" --query "oidcIssuerProfile.issuerUrl" -o tsv)"
az identity federated-credential create --name "azure-alb-identity" \
--identity-name "$IDENTITY_RESOURCE_NAME" \
--resource-group $RESOURCE_GROUP \
--issuer "$AKS_OIDC_ISSUER" \
--subject "system:serviceaccount:azure-alb-system:alb-controller-sa"
HELM_NAMESPACE='<namespace for deployment>'
CONTROLLER_NAMESPACE='azure-alb-system'
az aks get-credentials --resource-group $RESOURCE_GROUP --name $AKS_NAME
helm install alb-controller oci://mcr.microsoft.com/application-lb/charts/alb-controller \
--namespace $HELM_NAMESPACE \
--version 1.4.14 \
--set albController.namespace=$CONTROLLER_NAMESPACE \
--set albController.podIdentity.clientID=$(az identity show -g $RESOURCE_GROUP -n azure-alb-identity --query clientId -o tsv)
既存のデプロイの場合
以下のコマンドを実行することで ALB をアップグレートできます。
注意
以前に行ったインストールで名前空間をオーバーライドした場合は、アップグレード時に、--namespace または --set albController.namespace パラメーターを指定するようにしてください。 以前に使用した名前空間を確認するには、Helm 名前空間には helm list コマンドを、ALB コントローラーには kubectl get pod -A -l app=alb-controller を実行します。
クラスターに ALB コントローラーが正常にインストールされたので、Azure で Application Gateway For Containers リソースをプロビジョニングできます。
次の手順では、ALB コントローラーを Application Gateway for Containers にリンクします。 このリンクの作成方法は、デプロイ戦略によって異なります。
Application Gateway for Containers の管理に関しては、次の 2 つのデプロイ戦略があります。
Bring your own (BYO) デプロイ: このデプロイ戦略では、Application Gateway for Containers リソース、関連付けリソース、フロントエンド リソースのデプロイとライフサイクルが Azure portal、CLI、PowerShell、Terraform などを介していることが前提となっており、Kubernetes 内の構成で参照されます。