Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette page explique ce qu'est un profil d'instance IAM AWS, pourquoi il est important dans le contexte de GKE sur AWS et comment mettre à jour le profil d'instance.
Qu'est-ce qu'un profil d'instance IAM AWS ?
Un profil d'instance est un concept spécifique à AWS. Il s'agit d'un ensemble d'identifiants qu'une instance Amazon EC2 utilise pour accéder à différentes ressources AWS.
Plus précisément, un profil d'instance est un type de conteneur pour un rôle IAM pouvant être associé à une instance EC2. Un profil d'instance confère des autorisations à l'instance EC2, ce qui lui permet d'interagir avec différents services AWS en fonction des autorisations définies. Pour en savoir plus, consultez
Utiliser des profils d'instance
Comment les profils d'instance sont-ils utilisés dans GKE sur AWS ?
Chaque plan de contrôle et chaque pool de nœuds d'un cluster GKE sur AWS
est associé à un profil d'instance AWS unique. Les profils d'instance dans GKE sur AWS ont un double objectif :
Un profil d'instance accorde à GKE sur AWS les autorisations nécessaires pour gérer les ressources AWS. Par exemple, il accorde à l'autoscaler de cluster les autorisations nécessaires pour adapter le cluster en ajoutant ou en supprimant des instances EC2 en fonction des exigences de la charge de travail.
Un profil d'instance accorde aux instances EC2 l'accès aux services Google Cloud.
Par exemple, le kubelet, qui s'exécute sur une machine AWS, nécessite des
autorisations spécifiques permettant de fournir des identifiants d'extraction d'image à containerd. Ces
identifiants sont nécessaires pour accéder aux images et les extraire de Artifact Registry privé ou de Container Registry Dans le contexte de
GKE sur AWS, le profil d'instance EC2 associé au cluster est
configuré pour emprunter l'identité des agents de service de machine de Google (tels que l'agent de service de machine du pool de nœuds ou l'agent de service de machine du plan de contrôle). Cette
l'emprunt d'identité permet aux instances EC2 du cluster de
s'authentifier auprès de Google Artifact Registry ou Container Registry
Mettre à jour le profil d'instance
La mise à jour du profil d'instance implique la création d'un profil d'instance dans AWS
avec des autorisations spécifiques, puis de l'associer à votre
cluster ou pool de nœuds GKE sur AWS.
Pour mettre à jour correctement le profil d'instance de votre cluster ou de votre pool de nœuds,
procédez comme suit:
Créez un profil d'instance IAM pour vos instances Amazon EC2 et ajoutez-y le rôle IAM dont vous avez besoin. Pour en savoir plus, consultez
Utiliser des profils d'instance
Associez le nouveau profil d'instance à votre cluster ou pool de nœuds GKE sur AWS
en exécutant la commande suivante dans Google Cloud CLI:
Il est important de comprendre la mauvaise façon de mettre à jour un profil d'instance, car
c'est une erreur simple qui peut
provoquer des défaillances du cluster.
La mauvaise façon de mettre à jour un profil d'instance consiste à modifier directement un profil
à l'aide de la console de gestion AWS ou de la CLI AWS. Ces modifications peuvent perturber l'interaction de GKE sur AWS avec les ressources AWS. GKE sur AWS s'attend à ce que les profils d'instance restent tels qu'ils étaient lors de leur première association au cluster ou au pool de nœuds. Les modifier en dehors de GKE dans les outils de gestion d'AWS peut créer un conflit avec l'ID du rôle IAM figurant dans le profil d'instance. Cette non-concordance peut entraîner la défaillance du cluster.
La méthode décrite dans la section précédente garantit que les mises à jour sont effectuées sans perturber l'intégration de GKE sur AWS avec AWS.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2024/06/29 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2024/06/29 (UTC)."],[],[],null,["# Update AWS IAM instance profile\n\nThis page explains what an AWS IAM instance profile is, why it's important in\nthe context of GKE on AWS, and how to update the instance profile.\n\nWhat is an AWS IAM instance profile?\n------------------------------------\n\nAn instance profile is an AWS-specific concept. It consists of a set of\ncredentials that an Amazon EC2 instance uses to access various AWS resources.\nMore specifically, an instance profile is a kind of container for an IAM role\nthat can be attached to an EC2 instance. An instance profile confers permissions\nto the EC2 instance, allowing the instance to interact with various AWS services\nunder the defined permissions. For more information, see\n[Using instance profiles](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html).\n\nHow are instance profiles used in GKE on AWS?\n---------------------------------------------\n\nEach control plane and each node pool within a GKE on AWS cluster\nis associated with a unique AWS instance profile. Instance profiles in\nGKE on AWS serve a dual purpose:\n\n1. An instance profile grants GKE on AWS the permissions needed to manage AWS resources. For example, they give the cluster autoscaler the necessary permissions to scale the cluster by adding or removing EC2 instances based on workload demands.\n2. An instance profile grants EC2 instances access to Google Cloud services. For example the `kubelet`, running on an AWS machine, requires specific permissions to supply image pull credentials to `containerd`. These credentials are necessary for accessing and pulling images from Google's private Artifact Registry or from Container Registry. In the context of GKE on AWS, the EC2 instance profile associated with the cluster is configured to impersonate Google's Machine Service Agents (such as the Node Pool Machine Service Agent or the Control Plane Machine Service Agent). This impersonation allows the cluster's EC2 instances to automatically authenticate with Google's Artifact Registry or Container Registry.\n\nUpdate instance profile\n-----------------------\n\nUpdating the instance profile involves creating a new instance profile in AWS\nwith specific permissions, and then associating it with your\nGKE on AWS cluster or node pool.\n\nTo correctly update the instance profile for your cluster or node pool, follow\nthese steps:\n\n1. Create an IAM instance profile for your Amazon EC2 instances and add the IAM role you need to the instance profile. For details, see [Using instance profiles](https://docs.aws.amazon.com/codedeploy/latest/userguide/getting-started-create-iam-instance-profile.html).\n2. Link the new instance profile to your GKE on AWS cluster or node\n pool by running the following command in your Google Cloud CLI:\n\n ### Link profile to cluster\n\n gcloud container aws clusters update \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e \\\n --update-instance-profile \\\n --instance-profile-name \u003cvar translate=\"no\"\u003eNEW_INSTANCE_PROFILE_NAME\u003c/var\u003e \\\n ...\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: the name of your cluster\n - \u003cvar translate=\"no\"\u003eNEW_INSTANCE_PROFILE_NAME\u003c/var\u003e: the name of the new AWS instance profile you created\n\n ### Link profile to node pool\n\n gcloud container aws node-pools update \u003cvar translate=\"no\"\u003eNODE_POOL_NAME\u003c/var\u003e \\\n --update-instance-profile \\\n --instance-profile-name \u003cvar translate=\"no\"\u003eNEW_INSTANCE_PROFILE_NAME\u003c/var\u003e \\\n ...\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eNODE_POOL_NAME\u003c/var\u003e: the name of your node pool\n - \u003cvar translate=\"no\"\u003eNEW_INSTANCE_PROFILE_NAME\u003c/var\u003e: the name of the new AWS instance profile you created\n\n These commands show only the relevant flags for updating the instance\n profile, but you need to provide additional flags in order to run the\n `update` command. For details, see\n [Update your AWS cluster parameters](/kubernetes-engine/multi-cloud/docs/aws/how-to/update-cluster) or\n [Update a node pool](/kubernetes-engine/multi-cloud/docs/aws/how-to/update-node-pool).\n\n### The incorrect update method\n\nUnderstanding the wrong way to update an instance profile is important, because\nit's an easy mistake to make that can cause cluster failures.\n\nThe wrong way to update an instance profile is to directly modify an existing\ninstance profile using the AWS Management Console or AWS CLI. Such changes can\ndisrupt GKE on AWS interaction with AWS resources. GKE on AWS\nexpects instance profiles to remain as they were when first linked to the\ncluster or node pool. Altering them outside of GKE on AWS's management\ntools can create a mismatch with the ID of the IAM role that's in the instance\nprofile. This mismatch can create a cluster failure.\n\nThe approach described in the preceding section ensures that updates are made\nwithout disrupting GKE on AWS's integration with AWS."]]