From 75429db630c46fa55583dace1ee76b3f1c95ce7c Mon Sep 17 00:00:00 2001 From: Matthew Fuller Date: Thu, 27 May 2021 20:40:26 +0000 Subject: [PATCH] Move CAPI resources to target-infra namespace Moves CAPI resources in ephemeral cluster from the 'default' namespace to a new 'target-infra' namespace. Closes: #551 Change-Id: I419a71baa8e05e7b57b38234d15b955b36951b40 --- manifests/function/baremetal-operator/operator.yaml | 2 -- manifests/function/hostgenerator-m3/hosttemplate.yaml | 2 +- manifests/function/k8scontrol/kustomization.yaml | 3 +++ manifests/function/k8scontrol/namespace.yaml | 5 +++++ manifests/function/workers-capm3/kustomization.yaml | 3 +++ manifests/function/workers-capm3/namespace.yaml | 5 +++++ manifests/phases/cluster-map.yaml | 2 +- manifests/phases/executors.yaml | 4 +++- .../site/test-site/ephemeral/bootstrap/kustomization.yaml | 3 +++ .../site/test-site/ephemeral/bootstrap/namespace.yaml | 5 +++++ .../test-site/ephemeral/controlplane/kustomization.yaml | 2 ++ .../site/test-site/target/controlplane/kustomization.yaml | 2 ++ .../target/initinfra-networking/kustomization.yaml | 1 + .../test-site/target/initinfra-networking/namespace.yaml | 5 +++++ .../site/test-site/target/workers/kustomization.yaml | 2 ++ pkg/cluster/checkexpiration/command_test.go | 8 ++++---- pkg/cluster/checkexpiration/testdata/kubeconfig.yaml | 2 +- pkg/cluster/checkexpiration/testdata/tls-secret.yaml | 2 +- pkg/cluster/clustermap/map.go | 2 +- pkg/cluster/status_test.go | 4 ++-- pkg/cluster/testdata/statusmap/legacy-resource.yaml | 2 +- pkg/cluster/testdata/statusmap/missing.yaml | 2 +- pkg/cluster/testdata/statusmap/pending-resource.yaml | 2 +- pkg/cluster/testdata/statusmap/stable-resource.yaml | 2 +- pkg/cluster/testdata/statusmap/unknown.yaml | 2 +- pkg/k8s/applier/testdata/two_cm_bundle/resources.yaml | 4 ++-- pkg/k8s/kubeconfig/builder_test.go | 4 ++-- 27 files changed, 59 insertions(+), 23 deletions(-) create mode 100644 manifests/function/k8scontrol/namespace.yaml create mode 100644 manifests/function/workers-capm3/namespace.yaml create mode 100644 manifests/site/test-site/ephemeral/bootstrap/namespace.yaml create mode 100644 manifests/site/test-site/target/initinfra-networking/namespace.yaml diff --git a/manifests/function/baremetal-operator/operator.yaml b/manifests/function/baremetal-operator/operator.yaml index c551c2bd6..c97a5c911 100644 --- a/manifests/function/baremetal-operator/operator.yaml +++ b/manifests/function/baremetal-operator/operator.yaml @@ -38,8 +38,6 @@ spec: - configMapRef: name: ironic-vars env: - - name: WATCH_NAMESPACE - value: default - name: POD_NAME valueFrom: fieldRef: diff --git a/manifests/function/hostgenerator-m3/hosttemplate.yaml b/manifests/function/hostgenerator-m3/hosttemplate.yaml index 2dbe64b6f..3fb9bba98 100644 --- a/manifests/function/hostgenerator-m3/hosttemplate.yaml +++ b/manifests/function/hostgenerator-m3/hosttemplate.yaml @@ -55,7 +55,7 @@ template: | bootMode: {{ $host.bootMode }} networkData: name: {{ $hostName }}-network-data - namespace: default + namespace: target-infra bmc: address: {{ $host.bmcAddress }} credentialsName: {{ $hostName }}-bmc-secret diff --git a/manifests/function/k8scontrol/kustomization.yaml b/manifests/function/k8scontrol/kustomization.yaml index 4e7ac45f5..f505d1ef7 100644 --- a/manifests/function/k8scontrol/kustomization.yaml +++ b/manifests/function/k8scontrol/kustomization.yaml @@ -1,3 +1,6 @@ resources: + - namespace.yaml - cluster.yaml - controlplane.yaml + +namespace: target-infra diff --git a/manifests/function/k8scontrol/namespace.yaml b/manifests/function/k8scontrol/namespace.yaml new file mode 100644 index 000000000..b32028483 --- /dev/null +++ b/manifests/function/k8scontrol/namespace.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: target-infra diff --git a/manifests/function/workers-capm3/kustomization.yaml b/manifests/function/workers-capm3/kustomization.yaml index 86793bb0b..90ade296a 100644 --- a/manifests/function/workers-capm3/kustomization.yaml +++ b/manifests/function/workers-capm3/kustomization.yaml @@ -1,6 +1,9 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: + - namespace.yaml - kubeadmconfigtemplate.yaml - metal3machinetemplate.yaml - machinedeployment.yaml + +namespace: target-infra diff --git a/manifests/function/workers-capm3/namespace.yaml b/manifests/function/workers-capm3/namespace.yaml new file mode 100644 index 000000000..b32028483 --- /dev/null +++ b/manifests/function/workers-capm3/namespace.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: target-infra diff --git a/manifests/phases/cluster-map.yaml b/manifests/phases/cluster-map.yaml index 3dbacda9b..6ac4d336f 100644 --- a/manifests/phases/cluster-map.yaml +++ b/manifests/phases/cluster-map.yaml @@ -20,7 +20,7 @@ map: clusterAPI: clusterNamespacedName: name: target-cluster - namespace: default + namespace: target-infra ephemeral-cluster: kubeconfigSources: - type: "filesystem" diff --git a/manifests/phases/executors.yaml b/manifests/phases/executors.yaml index da9ffcbd2..1cf8c32c2 100644 --- a/manifests/phases/executors.yaml +++ b/manifests/phases/executors.yaml @@ -44,7 +44,8 @@ apiVersion: airshipit.org/v1alpha1 kind: Clusterctl metadata: name: clusterctl_move -move-options: {} +move-options: + namespace: target-infra action: move --- apiVersion: airshipit.org/v1alpha1 @@ -223,6 +224,7 @@ config: | builder: userDataSelector: kind: Secret + namespace: target-infra labelSelector: airshipit.org/ephemeral-user-data userDataKey: userData networkConfigSelector: diff --git a/manifests/site/test-site/ephemeral/bootstrap/kustomization.yaml b/manifests/site/test-site/ephemeral/bootstrap/kustomization.yaml index 753fbd6e6..05516ad8b 100644 --- a/manifests/site/test-site/ephemeral/bootstrap/kustomization.yaml +++ b/manifests/site/test-site/ephemeral/bootstrap/kustomization.yaml @@ -1,9 +1,12 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: + - namespace.yaml - ../../../../function/ephemeral - ../catalogues +namespace: target-infra + generators: - hostgenerator diff --git a/manifests/site/test-site/ephemeral/bootstrap/namespace.yaml b/manifests/site/test-site/ephemeral/bootstrap/namespace.yaml new file mode 100644 index 000000000..b32028483 --- /dev/null +++ b/manifests/site/test-site/ephemeral/bootstrap/namespace.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: target-infra diff --git a/manifests/site/test-site/ephemeral/controlplane/kustomization.yaml b/manifests/site/test-site/ephemeral/controlplane/kustomization.yaml index 927f23c1b..75dcb3ee6 100644 --- a/manifests/site/test-site/ephemeral/controlplane/kustomization.yaml +++ b/manifests/site/test-site/ephemeral/controlplane/kustomization.yaml @@ -7,5 +7,7 @@ resources: - ../../target/catalogues # NOTE: use target networking for this phase - nodes +namespace: target-infra + transformers: - ../../../../function/k8scontrol/replacements diff --git a/manifests/site/test-site/target/controlplane/kustomization.yaml b/manifests/site/test-site/target/controlplane/kustomization.yaml index 9b13977d3..085fab0d0 100644 --- a/manifests/site/test-site/target/controlplane/kustomization.yaml +++ b/manifests/site/test-site/target/controlplane/kustomization.yaml @@ -7,6 +7,8 @@ resources: - ../../../../function/k8scontrol - ../catalogues +namespace: target-infra + commonLabels: airshipit.org/stage: initinfra diff --git a/manifests/site/test-site/target/initinfra-networking/kustomization.yaml b/manifests/site/test-site/target/initinfra-networking/kustomization.yaml index 25e1bfab6..0381d98a9 100644 --- a/manifests/site/test-site/target/initinfra-networking/kustomization.yaml +++ b/manifests/site/test-site/target/initinfra-networking/kustomization.yaml @@ -1,5 +1,6 @@ resources: - ../../../../composite/infra/ + - namespace.yaml commonLabels: airshipit.org/stage: initinfra diff --git a/manifests/site/test-site/target/initinfra-networking/namespace.yaml b/manifests/site/test-site/target/initinfra-networking/namespace.yaml new file mode 100644 index 000000000..b32028483 --- /dev/null +++ b/manifests/site/test-site/target/initinfra-networking/namespace.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: target-infra diff --git a/manifests/site/test-site/target/workers/kustomization.yaml b/manifests/site/test-site/target/workers/kustomization.yaml index 97810634b..a7ed67f0f 100644 --- a/manifests/site/test-site/target/workers/kustomization.yaml +++ b/manifests/site/test-site/target/workers/kustomization.yaml @@ -5,5 +5,7 @@ resources: - ../../../../function/workers-capm3/ - nodes +namespace: target-infra + transformers: - ../../../../function/workers-capm3/replacements diff --git a/pkg/cluster/checkexpiration/command_test.go b/pkg/cluster/checkexpiration/command_test.go index 4a61cadb0..1748cbe58 100644 --- a/pkg/cluster/checkexpiration/command_test.go +++ b/pkg/cluster/checkexpiration/command_test.go @@ -45,7 +45,7 @@ const ( "tlsSecrets": [ { "name": "test-cluster-etcd", - "namespace": "default", + "namespace": "target-infra", "certificate": { "ca.crt": "2030-08-31 10:12:49 +0000 UTC", "tls.crt": "2030-08-31 10:12:49 +0000 UTC" @@ -55,7 +55,7 @@ const ( "kubeconfs": [ { "secretName": "test-cluster-kubeconfig", - "secretNamespace": "default", + "secretNamespace": "target-infra", "cluster": [ { "name": "workload-cluster", @@ -102,7 +102,7 @@ kubeconfs: expirationDate: 2030-08-31 10:12:48 +0000 UTC name: workload-cluster secretName: test-cluster-kubeconfig - secretNamespace: default + secretNamespace: target-infra user: - certificateName: ClientCertificateData expirationDate: 2021-09-02 10:12:50 +0000 UTC @@ -112,7 +112,7 @@ tlsSecrets: ca.crt: 2030-08-31 10:12:49 +0000 UTC tls.crt: 2030-08-31 10:12:49 +0000 UTC name: test-cluster-etcd - namespace: default + namespace: target-infra nodeCerts: - name: test-node certificate: diff --git a/pkg/cluster/checkexpiration/testdata/kubeconfig.yaml b/pkg/cluster/checkexpiration/testdata/kubeconfig.yaml index 2b800ef58..86b6dec88 100644 --- a/pkg/cluster/checkexpiration/testdata/kubeconfig.yaml +++ b/pkg/cluster/checkexpiration/testdata/kubeconfig.yaml @@ -6,7 +6,7 @@ metadata: labels: cluster.x-k8s.io/cluster-name: workload-cluster name: test-cluster-kubeconfig - namespace: default + namespace: target-infra ownerReferences: - apiVersion: controlplane.cluster.x-k8s.io/v1alpha3 blockOwnerDeletion: true diff --git a/pkg/cluster/checkexpiration/testdata/tls-secret.yaml b/pkg/cluster/checkexpiration/testdata/tls-secret.yaml index 8c3e96520..4e98bd081 100644 --- a/pkg/cluster/checkexpiration/testdata/tls-secret.yaml +++ b/pkg/cluster/checkexpiration/testdata/tls-secret.yaml @@ -8,5 +8,5 @@ metadata: labels: cluster.x-k8s.io/cluster-name: test-cluster name: test-cluster-etcd - namespace: default + namespace: target-infra type: Opaque \ No newline at end of file diff --git a/pkg/cluster/clustermap/map.go b/pkg/cluster/clustermap/map.go index 0f7c1c893..98560b554 100644 --- a/pkg/cluster/clustermap/map.go +++ b/pkg/cluster/clustermap/map.go @@ -24,7 +24,7 @@ import ( ) // DefaultClusterAPIObjNamespace is a default namespace used for cluster-api cluster object -const DefaultClusterAPIObjNamespace = "default" +const DefaultClusterAPIObjNamespace = "target-infra" // WriteOptions has format in which we want to print the output(table/yaml/cluster name) type WriteOptions struct { diff --git a/pkg/cluster/status_test.go b/pkg/cluster/status_test.go index 1b02d3f61..4ce27581e 100644 --- a/pkg/cluster/status_test.go +++ b/pkg/cluster/status_test.go @@ -218,7 +218,7 @@ func TestReadStatus(t *testing.T) { statusMap, err := cluster.NewStatusMap(c) require.NoError(t, err) ctx := context.Background() - resource := object.ObjMetadata{Namespace: "default", + resource := object.ObjMetadata{Namespace: "target-infra", Name: "pending-resource", GroupKind: schema.GroupKind{Group: "example.com", Kind: "Resource"}} result := statusMap.ReadStatus(ctx, resource) assert.Equal(t, "Pending", result.Status.String()) @@ -231,7 +231,7 @@ func makeResource(name, state string) *unstructured.Unstructured { "kind": "Resource", "metadata": map[string]interface{}{ "name": name, - "namespace": "default", + "namespace": "target-infra", }, "status": map[string]interface{}{ "state": state, diff --git a/pkg/cluster/testdata/statusmap/legacy-resource.yaml b/pkg/cluster/testdata/statusmap/legacy-resource.yaml index 2aca6df17..e58b220c3 100644 --- a/pkg/cluster/testdata/statusmap/legacy-resource.yaml +++ b/pkg/cluster/testdata/statusmap/legacy-resource.yaml @@ -4,4 +4,4 @@ apiVersion: "example.com/v1" kind: Legacy metadata: name: stable-legacy - namespace: default + namespace: target-infra diff --git a/pkg/cluster/testdata/statusmap/missing.yaml b/pkg/cluster/testdata/statusmap/missing.yaml index 43729dd45..69eb40628 100644 --- a/pkg/cluster/testdata/statusmap/missing.yaml +++ b/pkg/cluster/testdata/statusmap/missing.yaml @@ -4,4 +4,4 @@ apiVersion: "example.com/v1" kind: Missing metadata: name: missing-resource - namespace: default + namespace: target-infra diff --git a/pkg/cluster/testdata/statusmap/pending-resource.yaml b/pkg/cluster/testdata/statusmap/pending-resource.yaml index b1373a07a..00c1f4223 100644 --- a/pkg/cluster/testdata/statusmap/pending-resource.yaml +++ b/pkg/cluster/testdata/statusmap/pending-resource.yaml @@ -4,4 +4,4 @@ apiVersion: "example.com/v1" kind: Resource metadata: name: pending-resource - namespace: default + namespace: target-infra diff --git a/pkg/cluster/testdata/statusmap/stable-resource.yaml b/pkg/cluster/testdata/statusmap/stable-resource.yaml index a6fff614f..bdfa1d833 100644 --- a/pkg/cluster/testdata/statusmap/stable-resource.yaml +++ b/pkg/cluster/testdata/statusmap/stable-resource.yaml @@ -4,4 +4,4 @@ apiVersion: "example.com/v1" kind: Resource metadata: name: stable-resource - namespace: default + namespace: target-infra diff --git a/pkg/cluster/testdata/statusmap/unknown.yaml b/pkg/cluster/testdata/statusmap/unknown.yaml index 58c65e17f..76c053a45 100644 --- a/pkg/cluster/testdata/statusmap/unknown.yaml +++ b/pkg/cluster/testdata/statusmap/unknown.yaml @@ -5,4 +5,4 @@ apiVersion: "example.com/v1" kind: Resource metadata: name: unknown - namespace: default + namespace: target-infra diff --git a/pkg/k8s/applier/testdata/two_cm_bundle/resources.yaml b/pkg/k8s/applier/testdata/two_cm_bundle/resources.yaml index 39b33f562..cb4d73d85 100644 --- a/pkg/k8s/applier/testdata/two_cm_bundle/resources.yaml +++ b/pkg/k8s/applier/testdata/two_cm_bundle/resources.yaml @@ -25,7 +25,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: first-map - namespace: default + namespace: target-infra labels: cli-utils.sigs.k8s.io/inventory-id: "some id" --- @@ -33,7 +33,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: second-map - namespace: default + namespace: target-infra labels: cli-utils.sigs.k8s.io/inventory-id: "some id" diff --git a/pkg/k8s/kubeconfig/builder_test.go b/pkg/k8s/kubeconfig/builder_test.go index 7bbd8e257..c950c27d4 100644 --- a/pkg/k8s/kubeconfig/builder_test.go +++ b/pkg/k8s/kubeconfig/builder_test.go @@ -179,7 +179,7 @@ func TestBuilderClusterctl(t *testing.T) { ClusterAPI: v1alpha1.KubeconfigSourceClusterAPI{ NamespacedName: v1alpha1.NamespacedName{ Name: childClusterID, - Namespace: "default", + Namespace: "target-infra", }, }, }, @@ -192,7 +192,7 @@ func TestBuilderClusterctl(t *testing.T) { ClusterAPI: v1alpha1.KubeconfigSourceClusterAPI{ NamespacedName: v1alpha1.NamespacedName{ Name: parentClusterID, - Namespace: "default", + Namespace: "target-infra", }, }, },