Configure migrations to use service accounts on GCP Anthos
If you set up migrations and migration schedules using user accounts, you will encounter token expiration-related errors. To avoid these errors, Portworx, Inc. recommends setting up migration and migration schedules using service accounts. In contrast to user accounts, which expire after a specified interval of time has passed, service account tokens do not expire. Using service accounts ensures that you will not encounter token expiration-related errors. See the User accounts versus service accounts section of the Kubernetes documentation for more details about the differences between service accounts and user accounts. Perform the following steps on the destination cluster to configure migrations to use service accounts.
Create a service account and a cluster role binding
-
Create a file called
service-account-migration.yamlwith the following content, specifying thenamespace:to match one of the existing namespaces in your cluster. For this example we will use thedefaultnamespace:apiVersion: v1kind: ServiceAccountmetadata:name: migrationnamespace: default
2. Apply the spec:
kubectl apply -f service-account-migration.yaml
- Create a file called
cluster-role-binding-migration.yamlwith the following content, specifying thenamespace:field to match the namespace in the previous step:apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRoleBindingmetadata:name: migration-clusterrolebindingroleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: cluster-adminsubjects:- kind: ServiceAccountname: migrationnamespace: default
The roleRef.name field is set to cluster-admin. For details about super-user access, see the User-facing roles section of the Kubernetes documentation.
- Apply the spec:
kubectl apply -f cluster-role-binding-migration.yaml