fix refreshing gcp-auth pull secret

pull/12497/head
Sharif Elgamal 2021-09-16 15:06:31 -07:00
parent 24ab2962e3
commit 047f2e553f
2 changed files with 10 additions and 4 deletions

View File

@ -61,6 +61,7 @@ metadata:
name: gcp-auth-certs-create
namespace: gcp-auth
spec:
ttlSecondsAfterFinished: 120
template:
metadata:
name: gcp-auth-certs-create
@ -120,6 +121,7 @@ metadata:
name: gcp-auth-certs-patch
namespace: gcp-auth
spec:
ttlSecondsAfterFinished: 120
template:
metadata:
name: gcp-auth-certs-patch

View File

@ -169,7 +169,7 @@ func createPullSecret(cc *config.ClusterConfig, creds *google.Credentials) error
}
for _, n := range namespaces.Items {
if n.Name == "kube-system" {
if skipNamespace(n.Name) {
continue
}
secrets := client.Secrets(n.Name)
@ -197,7 +197,7 @@ func createPullSecret(cc *config.ClusterConfig, creds *google.Credentials) error
Type: "kubernetes.io/dockercfg",
}
if exists && Refresh {
if Refresh {
_, err := secrets.Update(context.TODO(), secretObj, metav1.UpdateOptions{})
if err != nil {
return err
@ -261,7 +261,7 @@ func refreshExistingPods(cc *config.ClusterConfig) error {
}
for _, n := range namespaces.Items {
// Ignore kube-system and gcp-auth namespaces
if n.Name == metav1.NamespaceSystem || n.Name == namespaceName {
if skipNamespace(n.Name) {
continue
}
@ -331,7 +331,7 @@ func disableAddonGCPAuth(cfg *config.ClusterConfig) error {
// No need to check for an error here, if the secret doesn't exist, no harm done.
for _, n := range namespaces.Items {
if n.Name == "kube-system" {
if skipNamespace(n.Name) {
continue
}
secrets := client.Secrets(n.Name)
@ -397,3 +397,7 @@ func verifyGCPAuthAddon(cc *config.ClusterConfig, name string, val string) error
return err
}
func skipNamespace(name string) bool {
return name == metav1.NamespaceSystem || name == namespaceName
}