Updating Registry Credentials for AKS/EKS Clusters
Protegrity Provisioned Cluster (PPC) uses image pull secrets to authenticate against the container registry, such as Harbor, when pulling images. When registry passwords are rotated, credentials expire, or the registry endpoint changes, the pull secrets must be updated across all namespaces in the cluster.
This procedure updates the harbor-secret image pull secret across all required namespaces using OpenTofu (tofu) -replace flags. This process does not require a reinstall of the full cluster.
Note: Existing running pods are unaffected by this operation. Only new image pulls use the rotated secret, for example, new pods, scaling events, and node replacements. If existing pods need to use the new credentials immediately, restart the affected deployments after applying the settings.
When to Use This Procedure
The following table outlines common scenarios and the frequency for updating registry credentials in PPC:
| Use Case | Trigger | Frequency |
|---|---|---|
| Scheduled password rotation | Policy/compliance schedule. | Quarterly |
| Security incident response | Credential compromise or leak. | Ad-hoc |
| Registry migration | Infrastructure change. For example, Artifactory to Harbor. | Rare |
| Multi-cluster credential management | Operational rollout across environments. | Ongoing |
| Service account token expiry | Automatic token expiration. For example, ECR or ACR. | Hours/days |
| User/team offboarding | HR process - account disabled. | Ad-hoc |
| Upgrade/patch deployment failures | Expired credentials blocking image pulls. | As needed |
| Audit and compliance | SOC2, ISO 27001, FedRAMP, HIPAA requirements. | Annual |
Prerequisites
Before you begin, ensure that the following requirements are met:
- You have access to the PPC Kubernetes cluster,
kubectlis configured. - OpenTofu (
tofu) is installed. - You have the new registry username and password.
- You have permission to manage secrets across namespaces in the cluster.
- The PPC directory is available at
/eclipse-init/iac/.
Target Namespaces
The harbor-secret is managed in the following namespaces:
| Namespace |
|---|
pty-admin |
api-gateway |
pty-loginui |
cert-manager |
karpenter |
default |
pty-backup-recovery |
email-service |
cli |
reloader |
pty-insight |
Procedure
This procedure must be run once per cloud, that is, AWS for EKS and Azure for AKS. Complete all steps for one cloud before proceeding to the next.
Follow these steps for each cloud environment:
Export the credentials for the new registry as environment variables.
export TF_VAR_username='<new-registry-username>' export TF_VAR_password='<new-registry-password>'Verify that the credentials are set.
[[ -n "$TF_VAR_username" && -n "$TF_VAR_password" ]] && echo "creds set" || echo "MISSING"Set the Kubernetes context to prevent accidentally writing secrets to the wrong cluster:
CLOUD=aws # or: azure KCTX=<your-cluster-context-name> kubectl config use-context "$KCTX" kubectl config current-context # must match the intended clusterNote: Operating on the wrong cluster will update secrets in the incorrect environment.
Navigate to the
iacdirectory.cd iac/azure/cluster/modules/05_helm_releasesPlan the credential update that targets only the
harbor-secretresources across all namespaces.NAMESPACES=(pty-admin api-gateway pty-loginui cert-manager karpenter default \ pty-backup-recovery email-service cli reloader pty-insight) REPLACE_ARGS=() for ns in "${NAMESPACES[@]}"; do REPLACE_ARGS+=(-replace="module.helm_releases.module.common.kubernetes_secret_v1.harbor_secret[\"$ns\"]") done tofu plan "${REPLACE_ARGS[@]}" -out="rotate-${CLOUD}.tfplan"Review the plan. Expected output:
Plan: 11 to add, 0 to change, 11 to destroy.Or equivalently,
11 to replace.The plan must affect only
harbor_secretresources. If any other resources appear in the plan, stop immediately and delete the plan file.rm "rotate-${CLOUD}.tfplan"Note: Investigate the unexpected changes before retrying.
Apply the plan.
tofu apply "rotate-${CLOUD}.tfplan"After successfully applying the plan, clean up the plan file. Use the command below:
rm "rotate-${CLOUD}.tfplan"Note: The
lifecycle.ignore_changes = [data]directive on the secret resource is bypassed by-replacebecause the resource is destroyed and recreated, not updated in place.Verify the update. Confirm that all
harbor-secretresources were recreated with current timestamps.for ns in pty-admin api-gateway pty-loginui cert-manager karpenter default \ pty-backup-recovery email-service cli reloader pty-insight; do kubectl -n "$ns" get secret harbor-secret \ -o jsonpath='{.metadata.namespace}{"\t"}{.metadata.creationTimestamp}{"\n"}' doneAll timestamps must reflect the time of the apply operation.
Reset the context variables, then repeat from step 4 for the next cloud.
CLOUD=azure KCTX=<your-azure-context-name>
Optional Post-Update Step: Rolling Deployments
If the running pods need to use the new credentials immediately, rather than waiting for the next pod restart, roll the affected deployments.
kubectl rollout restart deployment -n <namespace> <deployment-name>
Troubleshooting
| Symptom | Cause | Resolution |
|---|---|---|
tofu plan shows changes to non-secret resources. | State drift or other pending changes. | Do not apply. Investigate and resolve the unrelated changes first. |
tofu apply fails with state lock error. | Another operation is in progress. | Wait for the other operation to complete, or manually release the lock if it is stale. |
Pods enter ImagePullBackOff after apply. | New credentials are invalid, or a namespace was missed. | Verify credentials against the registry manually. Check that all 11 namespaces were updated. |
| Timestamps are not updated for some namespaces. | Partial apply failure. | Re-run the procedure for the affected namespaces only. |
MISSING TF_VAR_* error. | Environment variables not exported. | Re-export TF_VAR_username and TF_VAR_password and verify. |
Feedback
Was this page helpful?