diff --git a/cli/cmd/cluster-apply.go b/cli/cmd/cluster-apply.go index 0a75d1557..69f8debce 100644 --- a/cli/cmd/cluster-apply.go +++ b/cli/cmd/cluster-apply.go @@ -21,6 +21,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "github.com/kinvolk/lokomotive/internal" "github.com/kinvolk/lokomotive/pkg/install" "github.com/kinvolk/lokomotive/pkg/k8sutil" "github.com/kinvolk/lokomotive/pkg/lokomotive" @@ -84,6 +85,12 @@ func runClusterApply(cmd *cobra.Command, args []string) { ctxLogger.Fatalf("Verify cluster: %v", err) } + labels := map[string]string{} + internal.AppendNamespaceNameToLabels("kube-system", &labels) + + if err := k8sutil.UpdateNamespaceWithLabels(labels, "kube-system", kubeconfigPath); err != nil { + ctxLogger.Fatalf("error updating namespace %q with labels: %q", "kube-system", err) + } // Do controlplane upgrades only if cluster already exists and it is not a managed platform. if exists && !p.Meta().Managed { fmt.Printf("\nEnsuring that cluster controlplane is up to date.\n") diff --git a/pkg/components/util/install.go b/pkg/components/util/install.go index 95f69867f..2289f8617 100644 --- a/pkg/components/util/install.go +++ b/pkg/components/util/install.go @@ -62,6 +62,12 @@ func InstallComponent(c components.Component, kubeconfig string) error { return fmt.Errorf("failed ensuring that namespace %q for component %q exists: %w", ns, name, err) } + labels := c.GetNamespaceLabels() + + if err := k8sutil.UpdateNamespaceWithLabels(labels, ns, kubeconfig); err != nil { + return fmt.Errorf("failed updating namespace %q with labels for component %q: %w", ns, name, err) + } + actionConfig, err := HelmActionConfig(ns, kubeconfig) if err != nil { return fmt.Errorf("failed preparing helm client: %w", err)