Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Connetti i gruppi Google a GKE su Azure
Questo documento descrive come puoi connetterti a GKE su Azure come membro di un
gruppo Google.
L'utilizzo di Google Gruppi per concedere l'accesso al cluster è più efficiente della creazione di autorizzazioni separate per i singoli utenti. Ad esempio, supponiamo che tu voglia
aggiungere 50 utenti al gruppo Amministratore del cluster, 75 utenti a un gruppo Editor
e 100 utenti a un gruppo Lettore. Per consentire a tutti questi utenti di connettersi al tuo
cluster, devi creare regole RBAC nel file manifest di Kubernetes
per 225 utenti. Tuttavia, se attivi l'accesso al tuo cluster con Google Gruppi, risparmi tempo perché devi creare solo regole RBAC per tre gruppi Google.
Prima di iniziare
Per connetterti al cluster come membro di un gruppo Google, devi soddisfare i seguenti prerequisiti:
Assicurati di avere installato la versione più recente di Google Cloud CLI. Per informazioni sull'aggiornamento di gcloud CLI, consulta gcloud components update.
Utilizza GKE su Azure versione 1.25 o successive, che è necessaria per kubectl
l'accesso tramite Connect Gateway.
Connettiti al cluster con i gruppi Google
Per autorizzare i gruppi Google a connettersi a GKE su Azure:
Abilita le API connectgateway e cloudresourcemanager con il seguente comando:
Sostituisci PROJECT_ID con l'ID del tuo progetto Azure.
Se non esiste, crea un gruppo denominato gke-security-groups nel dominio del progetto.
Crea uno o più sottogruppi all'interno del gruppo gke-security-groups per l'autenticazione del cluster.
Aggiungi gli utenti ai sottogruppi appena creati.
Per l'accesso a kubectl utilizzando il gateway di connessione, devi concedere i ruoli IAM ai gruppi Google:
Seleziona un ruolo appropriato per un gruppo. Questo ruolo determina il modo in cui il gruppo interagisce con il gateway di connessione. Il ruolo può essere uno dei seguenti: roles/gkehub.gatewayAdmin,roles/gkehub.gatewayEditor, roles/gkehub.gatewayReader.
Tieni presente che qui non stai concedendo autorizzazioni per il cluster, questo passaggio verrà eseguito in un secondo momento.
Qui stai solo determinando in che modo gli utenti del gruppo possono manipolare il gateway di connessione.
Esegui il seguente comando per concedere il ruolo al gruppo:
GROUP_NAME: il nome del gruppo a cui concedere accesso
DOMAIN: il tuo dominio Google Workspace
GATEWAY_ROLE: il ruolo selezionato. Ad esempio, roles/gkehub.gatewayAdmin, roles/gkehub.gatewayEditor o
roles/gkehub.gatewayReader.
In un manifest Kubernetes, definisci le autorizzazioni di ciascun gruppo Google sul cluster. Ad esempio, il seguente manifest concede al gruppo Google cluster-admin-team il ruolo di amministratore del cluster:
Salva il manifest in un file e applicalo al cluster eseguendo il seguente comando:
kubectlapply-kubeconfig=KUBECONFIG_PATH-fFILENAME
Sostituisci quanto segue:
KUBECONFIG_PATH: il percorso del file kubeconfig.
FILENAME: il nome del file manifest che hai creato.
Una volta eseguiti questi passaggi, gli utenti appartenenti a determinati gruppi Google possono collegarsi al cluster. Nell'esempio riportato, gli utenti appartenenti al gruppo Google cluster-admin-team possono connettersi al cluster come amministratori.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-07-14 UTC."],[],[],null,["# Connect Google groups to GKE on Azure\n=====================================\n\nThis document describes how you can connect to GKE on Azure as a member of a\n[Google group](/iam/docs/groups-in-cloud-console).\n\nUsing Google groups to grant cluster access is more efficient than creating\nseparate authorizations for individual users. For example, let's say you want\nto add 50 users to the cluster Administrator group, 75 users to an Editor group,\nand 100 users to a Reader group. Enabling all these users to connect to your\ncluster would require you to create RBAC rules in the Kubernetes manifest file\nfor 225 users. Enabling access to your cluster with Google groups, however\nsaves you time because you only need to create RBAC rules for three Google\ngroups.\n\nBefore you begin\n----------------\n\nTo connect to your cluster as a member of a Google group, you need to satisfy\nthe following prerequisites:\n\n1. Ensure that you have the latest version of the Google Cloud CLI. For\n information on updating gcloud CLI, see\n [`gcloud components update`](/sdk/gcloud/reference/components/update).\n\n2. Use GKE on Azure version 1.25 or above, which is required for `kubectl`\n access using connect gateway.\n\nConnect to your cluster with Google groups\n------------------------------------------\n\nTo authorize Google groups to connect to GKE on Azure, follow these\nsteps:\n\n1. Enable the `connectgateway` and `cloudresourcemanager` APIs\n with the following command:\n\n gcloud services enable --project=\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n connectgateway.googleapis.com \\\n cloudresourcemanager.googleapis.com\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with the ID of your\n Azure project.\n2. Create a group called `gke-security-groups` as a group in your project's\n domain if it doesn't exist.\n\n3. Create one or more sub-groups within the `gke-security-groups` group for\n cluster authentication.\n\n4. Add users to the newly created sub-groups.\n\n5. For `kubectl` access using connect gateway, you need to grant\n IAM roles to Google groups:\n\n 1. Select an appropriate role for a group. This role determines how the\n group interacts with the connect gateway. The role can be\n one of the following: `roles/gkehub.gatewayAdmin`,\n `roles/gkehub.gatewayEditor`, `roles/gkehub.gatewayReader`.\n (Note that you're not granting\n permissions over the cluster here - that step comes later.\n Here, you're just determining how users of the group can manipulate\n the connect gateway.)\n\n 2. Run the following command to grant the role to the group:\n\n gcloud projects add-iam-policy-binding \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n --member=group:\u003cvar translate=\"no\"\u003eGROUP_NAME\u003c/var\u003e@\u003cvar translate=\"no\"\u003eDOMAIN\u003c/var\u003e \\\n --role=\u003cvar translate=\"no\"\u003eGATEWAY_ROLE\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your Google project ID\n - \u003cvar translate=\"no\"\u003eGROUP_NAME\u003c/var\u003e: the name of the group to grant access to\n - \u003cvar translate=\"no\"\u003eDOMAIN\u003c/var\u003e: your Google Workspace domain\n - \u003cvar translate=\"no\"\u003eGATEWAY_ROLE\u003c/var\u003e: the selected role. For example `roles/gkehub.gatewayAdmin`, `roles/gkehub.gatewayEditor`, or `roles/gkehub.gatewayReader`.\n\n | **Note:** To grant `kubectl` access through a private endpoint, follow the preceding steps, but grant `roles/gkemulticloud.viewer` to the Google groups instead.\n6. In a Kubernetes manifest, define the permissions each Google group\n has on the cluster. For example, the following manifest grants the Google\n Group `cluster-admin-team` the role of cluster administrator:\n\n apiVersion: rbac.authorization.k8s.io/v1\n kind: ClusterRoleBinding\n metadata:\n name: gateway-cluster-admin-group\n subjects:\n - kind: Group\n name: cluster-admin-team@example.com\n roleRef:\n kind: ClusterRole\n name: cluster-admin\n apiGroup: rbac.authorization.k8s.io\n\n7. Save the manifest to a file and apply it to the cluster by running the\n following command:\n\n kubectl apply -kubeconfig=\u003cvar translate=\"no\"\u003eKUBECONFIG_PATH\u003c/var\u003e -f \u003cvar translate=\"no\"\u003eFILENAME\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eKUBECONFIG_PATH\u003c/var\u003e: the path to your `kubeconfig` file.\n - \u003cvar translate=\"no\"\u003eFILENAME\u003c/var\u003e: the name of the manifest file you created.\n\nOnce you've performed these steps, users belonging to certain Google groups can\nconnect to the cluster. In the given example, users belonging to the Google\ngroup `cluster-admin-team` can connect to the cluster as administrators."]]