From 08663e6bb3c5694726aac665d71be26494475781 Mon Sep 17 00:00:00 2001 From: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com> Date: Wed, 8 Jan 2020 18:54:08 +0100 Subject: [PATCH] fix(helm): move ServiceAccount before Secret in InstallOrder. Service accounts must be installed before secrets when service account tokens (secrets) are be managed by Helm. Otherwise Kubernetes will delete any service account token right after creation, since there is no service account mounting the token (see https://kubernetes.io/docs/reference/access-authn-authz/service-accounts-admin/#token-controller) Closes #7159. Signed-off-by: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com> --- pkg/releaseutil/kind_sorter.go | 4 ++-- pkg/releaseutil/kind_sorter_test.go | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/releaseutil/kind_sorter.go b/pkg/releaseutil/kind_sorter.go index a5110a100..0402b8bb1 100644 --- a/pkg/releaseutil/kind_sorter.go +++ b/pkg/releaseutil/kind_sorter.go @@ -31,12 +31,12 @@ var InstallOrder KindSortOrder = []string{ "LimitRange", "PodSecurityPolicy", "PodDisruptionBudget", + "ServiceAccount", "Secret", "ConfigMap", "StorageClass", "PersistentVolume", "PersistentVolumeClaim", - "ServiceAccount", "CustomResourceDefinition", "ClusterRole", "ClusterRoleList", @@ -85,12 +85,12 @@ var UninstallOrder KindSortOrder = []string{ "ClusterRoleList", "ClusterRole", "CustomResourceDefinition", - "ServiceAccount", "PersistentVolumeClaim", "PersistentVolume", "StorageClass", "ConfigMap", "Secret", + "ServiceAccount", "PodDisruptionBudget", "PodSecurityPolicy", "LimitRange", diff --git a/pkg/releaseutil/kind_sorter_test.go b/pkg/releaseutil/kind_sorter_test.go index 93d8ae782..1b42383a5 100644 --- a/pkg/releaseutil/kind_sorter_test.go +++ b/pkg/releaseutil/kind_sorter_test.go @@ -40,7 +40,7 @@ func TestKindSorter(t *testing.T) { Head: &SimpleHead{Kind: "ClusterRoleBindingList"}, }, { - Name: "e", + Name: "f", Head: &SimpleHead{Kind: "ConfigMap"}, }, { @@ -84,11 +84,11 @@ func TestKindSorter(t *testing.T) { Head: &SimpleHead{Kind: "NetworkPolicy"}, }, { - Name: "f", + Name: "g", Head: &SimpleHead{Kind: "PersistentVolume"}, }, { - Name: "g", + Name: "h", Head: &SimpleHead{Kind: "PersistentVolumeClaim"}, }, { @@ -132,7 +132,7 @@ func TestKindSorter(t *testing.T) { Head: &SimpleHead{Kind: "RoleBindingList"}, }, { - Name: "d", + Name: "e", Head: &SimpleHead{Kind: "Secret"}, }, { @@ -140,7 +140,7 @@ func TestKindSorter(t *testing.T) { Head: &SimpleHead{Kind: "Service"}, }, { - Name: "h", + Name: "d", Head: &SimpleHead{Kind: "ServiceAccount"}, }, { @@ -166,8 +166,8 @@ func TestKindSorter(t *testing.T) { order KindSortOrder expected string }{ - {"install", InstallOrder, "aAbcC3de1fgh2iIjJkKlLmnopqrxstuvw!"}, - {"uninstall", UninstallOrder, "wvmutsxrqponLlKkJjIi2hgf1ed3CcbAa!"}, + {"install", InstallOrder, "aAbcC3def1gh2iIjJkKlLmnopqrxstuvw!"}, + {"uninstall", UninstallOrder, "wvmutsxrqponLlKkJjIi2hg1fed3CcbAa!"}, } { var buf bytes.Buffer t.Run(test.description, func(t *testing.T) {