Crie um diretório para armazenar um backup dos seus secrets atuais:
mkdir backup
Observe as seguintes informações sobre a conta de serviço relevante:
Acesso a componentes
Cluster
Secret
Namespace
Administrador
admin-cluster-creds
kube-system
Administrador
user-cluster-creds
CLUSTER_NAME-gke-onprem-mgmt
Administrador
private-registry-creds
kube-system
Usuário
private-registry-creds
kube-system
Se você não está usando um
registro particular
o secret private-registry-creds contém a chave para o acesso ao componente
conta de serviço.
Se você estiver usando um registro particular, o
Secret private-registry-creds manterá as credenciais do registro particular, não a chave da conta de serviço de acesso ao componente.
Registro do Connect
Cluster
Secret
Namespace
Administrador
admin-cluster-creds
kube-system
Administrador
user-cluster-creds
CLUSTER_NAME-gke-onprem-mgmt
Geração de registros/monitoramento
Cluster
Secret
Namespace
Administrador
admin-cluster-creds
kube-system
Administrador
user-cluster-creds
CLUSTER_NAME-gke-onprem-mgmt
Usuário
google-cloud-credentials
kube-system
Usuário
stackdriver-service-account-key
knative-serving
Registro de auditoria
Cluster
Secret
Namespace
Administrador
admin-cluster-creds
kube-system
Administrador
user-cluster-creds
CLUSTER_NAME-gke-onprem-mgmt
Administrador
kube-apiserver
CLUSTER_NAME
Medição de uso
Cluster
Secret
Namespace
Administrador
user-cluster-creds
CLUSTER_NAME-gke-onprem-mgmt
Usuário
usage-metering-bigquery-service-account-key
kube-system
Stackdriver
Cluster
Secret
Namespace
Administrador
admin-cluster-creds
kube-system
Administrador
user-cluster-creds
CLUSTER_NAME-gke-onprem-mgmt
Usuário
google-cloud-credentials
kube-system
Usuário
stackdriver-service-account-key
knative-serving
Crie um backup de cada secret usando o seguinte comando:
Para criar um novo arquivo de chave da conta de serviço, execute o seguinte comando:
gcloud iam service-accounts keys create NEW_KEY_FILE --iam-account IAM_ACCOUNT
Substitua:
NEW_KEY_FILE: o nome do novo arquivo de chave da conta de serviço.
IAM_ACCOUNT: o endereço de e-mail da conta de serviço.
No arquivo de configuração do cluster de administrador, encontre o
campo componentAccessServiceAccountKeyPath, a seção gkeConnect, a
seção stackdriver e a seção cloudAuditLogging. Nesses locais, substitua os caminhos para os arquivos de chave da conta de serviço.
No arquivo de configuração do cluster de usuário, localize o
campo componentAccessServiceAccountKeyPath, a seção gkeConnect,
a seção stackdriver, a seçãocloudAudigLogging e
a seção usageMetering. Nesses locais, substitua os caminhos para os arquivos de chave da conta de serviço.
Salve as alterações feitas executando os comandos a seguir. É possível girar
as chaves de um componente por vez, ou você pode girar todas as chaves de uma só vez
definindo o componente como sakeys:
sakeys: alterna as chaves para vários componentes.
ADMIN_CLUSTER_KUBECONFIG: o caminho para o arquivo kubeconfig do cluster do administrador.
ADMIN_CLUSTER_CONFIG: o caminho até o arquivo de configuração do cluster de administrador.
USER_CLUSTER_CONFIG: o caminho para o arquivo de configuração
do cluster de usuário.
Recriação de nós
Algumas rotações de chaves da conta de serviço podem levar mais tempo porque o nó
a recriação seja necessária:
Conta de serviço
É necessário recriar os nós
Acesso a componentes
Se estiver usando o Container Registry: sim
Se estiver usando um registro particular: não
Registro de auditoria
Cluster de administrador: sim
Cluster de usuário com o Contrlplane V2 ativado: sim, mas apenas o plano de controle
nós
Geração de registros/monitoramento
Não
Registro do Connect
Não
Medição de uso
Não
No caso de uma rotação de chaves que exige a recriação de nós, eles são substituídos
em um processo de atualização gradual, ou seja, os nós são recriados um por um.
O tempo de inatividade durante uma rotação de chaves é semelhante ao tempo de inatividade de uma
para um upgrade no cluster. Para mais detalhes, consulte
Inatividade durante os upgrades.
Como restaurar backups
Se você precisar restaurar os backups dos secrets criados anteriormente, execute
o seguinte comando:
[[["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-09-30 UTC."],[],[],null,["# Rotating service account keys\n\nThis page describes how to rotate keys for the following service accounts:\n\n- [Component access](/kubernetes-engine/distributed-cloud/vmware/docs/how-to/service-accounts#component_access_service_account)\n- [Connect-register](/kubernetes-engine/distributed-cloud/vmware/docs/how-to/service-accounts#connect_register_service_account)\n- [Logging-monitoring](/kubernetes-engine/distributed-cloud/vmware/docs/how-to/service-accounts#logging_monitoring_service_account)\n- [Audit logging](/kubernetes-engine/distributed-cloud/vmware/docs/how-to/service-accounts#audit_logging_service_account)\n\n| **Important:** The capabilities described in this document aren't fully supported for 1.31 or 1.32 clusters that have advanced clusters enabled. For details about what is or isn't supported for updating credentials for advanced clusters, see [Advanced cluster differences for rotating service account\n| keys](#adv-cluster-diffs). For a comprehensive list of Google Distributed Cloud for VMware features and capabilities that are or aren't supported for advanced clusters, see [Differences when running advanced\n| clusters](/kubernetes-engine/distributed-cloud/vmware/docs/concepts/advanced-clusters#adv-clusters-feature-support).\n\nTo rotate your service account keys:\n\n1. Create a directory to store a backup of your current secrets:\n\n ```\n mkdir backup\n ```\n2. Note the following information for the relevant service account:\n\n **Component access**\n\n - If you aren't using a [private registry](/kubernetes-engine/distributed-cloud/vmware/docs/how-to/admin-cluster-configuration-file-latest#privateregistry-section), the `private-registry-creds` Secret holds the key for your component access service account.\n - If you are using a private registry, the `private-registry-creds` Secret holds the credentials for your private registry, **not** the component access service account key.\n\n **Connect-register**\n\n **Logging-monitoring**\n\n **Audit logging**\n\n **Stackdriver**\n\n3. Create a backup of each secret using the following command:\n\n ```\n kubectl get secret SECRET --namespace NAMESPACE \\\n --kubeconfig KUBECONFIG -o json \u003e backup/SECRET-NAMESPACE.json\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e: the namespace where the secret is located. For example, `kube-system`.\n - \u003cvar translate=\"no\"\u003eKUBECONFIG\u003c/var\u003e: the path to the kubeconfig file for the admin or user cluster.\n - \u003cvar translate=\"no\"\u003eSECRET\u003c/var\u003e: the name of the secret. For example, `admin-cluster-creds`.\n\n For example, run the following commands for the audit logging service\n account: \n\n ```\n kubectl get secret admin-cluster-creds --namespace kube-system \\\n --kubeconfig KUBECONFIG -o json \u003e backup/admin-cluster-creds-kube-system.json\n\n kubectl get secret user-cluster-creds --namespace NAMESPACE \\\n --kubeconfig KUBECONFIG -o json \u003e backup/user-cluster-creds-NAMESPACE.json\n\n kubectl get secret kube-apiserver --namespace NAMESPACE \\\n --kubeconfig KUBECONFIG -o json \u003e backup/kube-apiserver-NAMESPACE.json\n ```\n4. To create a new service account key file, run the following command:\n\n ```\n gcloud iam service-accounts keys create NEW_KEY_FILE --iam-account IAM_ACCOUNT\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eNEW_KEY_FILE\u003c/var\u003e: the name for your new service account key file\n - \u003cvar translate=\"no\"\u003eIAM_ACCOUNT\u003c/var\u003e: the email address of the service account\n5. In the admin cluster configuration file, find the\n `componentAccessServiceAccountKeyPath` field, the `gkeConnect` section, the\n `stackdriver` section, and the `cloudAuditLogging` section. In those places,\n replace the paths to the service account key files.\n\n6. In the user cluster configuration file, find the\n `componentAccessServiceAccountKeyPath` field, the `gkeConnect` section, the\n `stackdriver` section, and the `cloudAudigLogging` section.\n In those places, replace the paths to the service\n account key files.\n\n7. Save the changes you made by running the following commands:\n\n You can rotate the keys for one component at a time, or you can rotate all\n keys at once by setting the component to `sakeys`. \n\n ```\n gkectl update credentials COMPONENT \\\n --kubeconfig ADMIN_CLUSTER_KUBECONFIG \\\n --config ADMIN_CLUSTER_CONFIG \\\n --admin-cluster\n\n gkectl update credentials COMPONENT \\\n --kubeconfig ADMIN_CLUSTER_KUBECONFIG \\\n --config USER_CLUSTER_CONFIG\n ```\n\n Replace the following;\n - \u003cvar translate=\"no\"\u003eCOMPONENT\u003c/var\u003e: one of:\n\n - `componentaccess`\n - `register`\n - `cloudauditlogging`\n - `stackdriver`\n - `sakeys` (rotates all component keys)\n - \u003cvar translate=\"no\"\u003eADMIN_CLUSTER_KUBECONFIG\u003c/var\u003e: the path to the\n kubeconfig file for the admin cluster.\n\n - \u003cvar translate=\"no\"\u003eADMIN_CLUSTER_CONFIG\u003c/var\u003e: the path to the admin\n cluster configuration file.\n\n - \u003cvar translate=\"no\"\u003eUSER_CLUSTER_CONFIG\u003c/var\u003e: the path to the user\n cluster configuration file.\n\nNode re-creation\n----------------\n\nSome service account key rotations may take longer time because node\nre-creation is required:\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nFor a key rotation that requires nodes to be re-created, the nodes are replaced\nin a rolling update process; that is, the nodes are re-created one by one.\n\nThe possible downtime during a key rotation is similar to the downtime for a\ncluster upgrade. For details, see\n[Downtime during upgrades](/kubernetes-engine/distributed-cloud/vmware/docs/how-to/upgrading#downtime_upgrades).\n\nRestoring backups\n-----------------\n\nIf you need to restore the backups of the secrets you made earlier, run the\nfollowing command:\n\n```\nkubectl apply -f backup/\n```\n\nAdvanced cluster differences for rotating service account keys\n--------------------------------------------------------------\n\nThe `gkectl update credentials` command is only partially supported for advanced\nclusters. The following table lists command variations that are and aren't\nsupported: \n\nFor a comprehensive list of Google Distributed Cloud for VMware features and\ncapabilities that are or aren't supported for advanced clusters, see\n[Differences when running advanced\nclusters](/kubernetes-engine/distributed-cloud/vmware/docs/concepts/advanced-clusters#adv-clusters-feature-support)."]]