Esta documentação é referente à versão mais recente do GKE no Azure, lançada em novembro de 2021. Consulte as Notas de lançamento para mais informações.
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Criar um aplicativo do Azure Active Directory
Nesta seção, crie um aplicativo do
Azure Active Directory
(Azure AD) e objetos principais de serviço. O GKE no Azure
usa esses objetos para armazenar informações de configuração no Azure.
Para criar o aplicativo do Azure AD, execute o seguinte comando:
az ad app create --display-name APPLICATION_NAME
Substitua APPLICATION_NAME por um nome para o aplicativo, por exemplo, anthos-clusters.
Para salvar o ID do aplicativo em uma variável de ambiente para uso posterior, execute
o seguinte comando:
APPLICATION_ID=$(az ad app list --all \
--query "[?displayName=='APPLICATION_NAME'].appId" \
--output tsv)
Substitua APPLICATION_NAME pelo nome do aplicativo.
Para criar um principal de serviço para o aplicativo, execute o seguinte comando:
az ad sp create --id "${APPLICATION_ID}"
Configurar a federação de identidade da carga de trabalho
A federação de identidade da carga de trabalho permite que o GKE no Azure seja autenticado no Azure
usando uma conta de serviço do Google. Esse método de autenticação no Azure é
mais simples do que o método de autenticação legado do AzureClient, que exige
que você gerencie os certificados e faça o upload manual deles no Azure Active Directory
(AD).
Para configurar uma credencial de identidade federada no aplicativo Azure AD, execute os comandos a seguir. É possível adicionar até 20
credenciais a cada aplicativo do Azure AD.
Crie um arquivo JSON chamado credential.json.
{
"name": "CREDENTIAL_NAME",
"issuer": "https://accounts.google.com",
"subject": "service-PROJECT_NUMBER@gcp-sa-gkemulticloud.iam.gserviceaccount.com",
"audiences": ["api://AzureADTokenExchange"],
"description": "Allow GKE on Azure to authenticate to the Azure AD application using a Google service account."
}
CREDENTIAL_NAME: o nome da credencial.
PROJECT_NUMBER: o número do projeto do Google Cloud que
hospeda o cluster.
Crie uma credencial de identidade federada no aplicativo Azure AD:
az ad app federated-credential create --id "${APPLICATION_ID}" --parameters credential.json
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2024-06-26 UTC."],[],[],null,["# Create an Azure Active Directory application\n============================================\n\nIn this section, you create an\n[Azure Active Directory](https://azure.microsoft.com/en-us/services/active-directory/)\n(Azure AD) application and service principal objects. GKE on Azure\nuses these objects to store configuration information on Azure.\n\n1. To create the Azure AD application, run the following command:\n\n az ad app create --display-name \u003cvar translate=\"no\"\u003eAPPLICATION_NAME\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eAPPLICATION_NAME\u003c/var\u003e with a name for your\n application---for example, `anthos-clusters`.\n2. To save the application's ID to an environment variable for later use, run\n the following command:\n\n APPLICATION_ID=$(az ad app list --all \\\n --query \"[?displayName=='\u003cvar translate=\"no\"\u003eAPPLICATION_NAME\u003c/var\u003e'].appId\" \\\n --output tsv)\n\n Replace \u003cvar translate=\"no\"\u003eAPPLICATION_NAME\u003c/var\u003e with the name of your\n application.\n3. To create a service principal for the application, run the following command:\n\n az ad sp create --id \"${APPLICATION_ID}\"\n\nSet up Workload identity federation\n-----------------------------------\n\n\u003cbr /\u003e\n\n| **Note:** GKE on Azure provides two\n| methods of authenticating to Azure: workload identity federation\n| authentication and *AzureClient* authentication. We recommend that you use\n| the workload identity federation method described in this document, because\n| it's simpler and more secure.\n\n\u003cbr /\u003e\n\nWorkload identity federation allows GKE on Azure to authenticate to Azure\nusing a Google service account. This method of authenticating to Azure is\nsimpler than the legacy AzureClient authentication method, which requires\nyou to manage certificates and manually upload them to Azure Active Directory\n(AD).\n\nTo configure a federated identity credential on your Azure AD\napplication, run the following commands. Note that you can add up to twenty\ncredentials to each Azure AD application.\n\n1. Create a JSON file named `credential.json`.\n\n ```json\n {\n \"name\": \"CREDENTIAL_NAME\",\n \"issuer\": \"https://accounts.google.com\",\n \"subject\": \"service-PROJECT_NUMBER@gcp-sa-gkemulticloud.iam.gserviceaccount.com\",\n \"audiences\": [\"api://AzureADTokenExchange\"],\n \"description\": \"Allow GKE on Azure to authenticate to the Azure AD application using a Google service account.\"\n }\n ```\n - \u003cvar translate=\"no\"\u003eCREDENTIAL_NAME\u003c/var\u003e: the credential name.\n - \u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e: the number of the Google Cloud project that hosts the cluster.\n2. Create a federated identity credential on the Azure AD application:\n\n az ad app federated-credential create --id \"${APPLICATION_ID}\" --parameters credential.json\n\nFor more details, see the Azure documentation\n[Azure AD workload identity federation with Google Cloud](https://blog.identitydigest.com/azuread-federate-gcp/).\n\nYou can also provision the Azure federated identity credential using Terraform.\nFor details, see [azuread_application_federated_identity_credential](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/resources/application_federated_identity_credential).\n\nWhat's next\n-----------\n\n- [Create Azure role assignments](/kubernetes-engine/multi-cloud/docs/azure/how-to/create-azure-role-assignments)"]]