From 111a0de90b575fab1842d487492f01a316c944e9 Mon Sep 17 00:00:00 2001 From: Cecile Robert-Michon Date: Fri, 18 Sep 2020 09:45:00 -0700 Subject: [PATCH] :wrench: Apply calico ClusterResourceSet to tilt and dev clusters --- Makefile | 14 ++++++++-- Tiltfile | 8 ++++++ templates/addons/calico-resource-set.yaml | 27 +++++++++++++++++++ templates/cluster-template-ephemeral.yaml | 2 ++ ...ster-template-external-cloud-provider.yaml | 2 ++ templates/cluster-template-ipv6.yaml | 2 ++ templates/cluster-template-machinepool.yaml | 2 ++ ...ter-template-system-assigned-identity.yaml | 2 ++ ...uster-template-user-assigned-identity.yaml | 2 ++ templates/cluster-template.yaml | 2 ++ templates/flavors/base/cluster-template.yaml | 2 ++ templates/flavors/ipv6/patches/ipv6.yaml | 2 ++ ...template-prow-machine-pool-ci-version.yaml | 23 ++++++++++++++++ .../cluster-template-prow-machine-pool.yaml | 23 ++++++++++++++++ .../prow-machine-pool/cni-resource-set.yaml | 21 +++++++++++++++ .../test/prow-machine-pool/kustomization.yaml | 2 ++ 16 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 templates/addons/calico-resource-set.yaml create mode 100644 templates/test/prow-machine-pool/cni-resource-set.yaml diff --git a/Makefile b/Makefile index 4ae335f81c4..cf2cfd8203d 100644 --- a/Makefile +++ b/Makefile @@ -430,6 +430,11 @@ create-management-cluster: $(KUSTOMIZE) $(ENVSUBST) kubectl wait --for=condition=Available --timeout=5m -n capi-kubeadm-bootstrap-system deployment -l cluster.x-k8s.io/provider=bootstrap-kubeadm kubectl wait --for=condition=Available --timeout=5m -n capi-kubeadm-control-plane-system deployment -l cluster.x-k8s.io/provider=control-plane-kubeadm + # apply CNI ClusterResourceSets + kubectl create configmap calico-addon --from-file=templates/addons/calico.yaml + kubectl create configmap calico-ipv6-addon --from-file=templates/addons/calico-ipv6.yaml + kubectl apply -f templates/addons/calico-resource-set.yaml + # Wait for CAPZ deployments kubectl wait --for=condition=Available --timeout=5m -n capz-system deployment -l cluster.x-k8s.io/provider=infrastructure-azure @@ -473,7 +478,12 @@ create-aks-cluster: $(KUSTOMIZE) $(ENVSUBST) .PHONY: create-cluster -create-cluster: create-management-cluster create-workload-cluster ## Create a workload development Kubernetes cluster on Azure in a kind management cluster. +create-cluster: ## Create a workload development Kubernetes cluster on Azure in a kind management cluster. + EXP_CLUSTER_RESOURCE_SET=true \ + EXP_AKS=true \ + EXP_MACHINE_POOL=true \ + $(MAKE) create-management-cluster \ + $(MAKE) create-workload-cluster .PHONY: delete-workload-cluster delete-workload-cluster: ## Deletes the example workload Kubernetes cluster @@ -490,7 +500,7 @@ kind-create: ## create capz kind cluster if needed .PHONY: tilt-up tilt-up: $(ENVSUBST) $(KUSTOMIZE) kind-create ## start tilt and build kind cluster if needed - tilt up + EXP_CLUSTER_RESOURCE_SET=true EXP_AKS=true EXP_MACHINE_POOL=true tilt up .PHONY: delete-cluster delete-cluster: delete-workload-cluster ## Deletes the example kind cluster "capz" diff --git a/Tiltfile b/Tiltfile index 0aaaeb2179c..7b03425a50e 100644 --- a/Tiltfile +++ b/Tiltfile @@ -258,6 +258,12 @@ def capz(): k8s_yaml(blob(yaml)) +def calico_crs(): + local("kubectl delete configmaps calico-addon --ignore-not-found=true") + local("kubectl create configmap calico-addon --from-file=templates/addons/calico.yaml") + local("kubectl delete configmaps calico-ipv6-addon --ignore-not-found=true") + local("kubectl create configmap calico-ipv6-addon --from-file=templates/addons/calico-ipv6.yaml") + local("kubectl apply -f templates/addons/calico-resource-set.yaml") # run worker clusters specified from 'tilt up' or in 'tilt_config.json' def flavors(): @@ -385,4 +391,6 @@ deploy_capi() capz() +calico_crs() + flavors() diff --git a/templates/addons/calico-resource-set.yaml b/templates/addons/calico-resource-set.yaml new file mode 100644 index 00000000000..29aef09114e --- /dev/null +++ b/templates/addons/calico-resource-set.yaml @@ -0,0 +1,27 @@ +apiVersion: addons.cluster.x-k8s.io/v1alpha3 +kind: ClusterResourceSet +metadata: + name: crs-calico + namespace: default +spec: + strategy: "ApplyOnce" + clusterSelector: + matchLabels: + cni: calico + resources: + - name: calico-addon + kind: ConfigMap +--- +apiVersion: addons.cluster.x-k8s.io/v1alpha3 +kind: ClusterResourceSet +metadata: + name: crs-calico-ipv6 + namespace: default +spec: + strategy: "ApplyOnce" + clusterSelector: + matchLabels: + cni: calico-ipv6 + resources: + - name: calico-ipv6-addon + kind: ConfigMap diff --git a/templates/cluster-template-ephemeral.yaml b/templates/cluster-template-ephemeral.yaml index 65bd7bce0fc..298e4c2f106 100644 --- a/templates/cluster-template-ephemeral.yaml +++ b/templates/cluster-template-ephemeral.yaml @@ -1,6 +1,8 @@ apiVersion: cluster.x-k8s.io/v1alpha3 kind: Cluster metadata: + labels: + cni: calico name: ${CLUSTER_NAME} namespace: default spec: diff --git a/templates/cluster-template-external-cloud-provider.yaml b/templates/cluster-template-external-cloud-provider.yaml index cdca1cff1cb..e9505e65f2a 100644 --- a/templates/cluster-template-external-cloud-provider.yaml +++ b/templates/cluster-template-external-cloud-provider.yaml @@ -1,6 +1,8 @@ apiVersion: cluster.x-k8s.io/v1alpha3 kind: Cluster metadata: + labels: + cni: calico name: ${CLUSTER_NAME} namespace: default spec: diff --git a/templates/cluster-template-ipv6.yaml b/templates/cluster-template-ipv6.yaml index 0aa89b5759e..541a4d59ee3 100644 --- a/templates/cluster-template-ipv6.yaml +++ b/templates/cluster-template-ipv6.yaml @@ -1,6 +1,8 @@ apiVersion: cluster.x-k8s.io/v1alpha3 kind: Cluster metadata: + labels: + cni: calico-ipv6 name: ${CLUSTER_NAME} namespace: default spec: diff --git a/templates/cluster-template-machinepool.yaml b/templates/cluster-template-machinepool.yaml index 8e6746bec8f..7f26998b783 100644 --- a/templates/cluster-template-machinepool.yaml +++ b/templates/cluster-template-machinepool.yaml @@ -1,6 +1,8 @@ apiVersion: cluster.x-k8s.io/v1alpha3 kind: Cluster metadata: + labels: + cni: calico name: ${CLUSTER_NAME} namespace: default spec: diff --git a/templates/cluster-template-system-assigned-identity.yaml b/templates/cluster-template-system-assigned-identity.yaml index c286d61868d..033287d2066 100644 --- a/templates/cluster-template-system-assigned-identity.yaml +++ b/templates/cluster-template-system-assigned-identity.yaml @@ -1,6 +1,8 @@ apiVersion: cluster.x-k8s.io/v1alpha3 kind: Cluster metadata: + labels: + cni: calico name: ${CLUSTER_NAME} namespace: default spec: diff --git a/templates/cluster-template-user-assigned-identity.yaml b/templates/cluster-template-user-assigned-identity.yaml index f756f8f561a..6ca2990ab84 100644 --- a/templates/cluster-template-user-assigned-identity.yaml +++ b/templates/cluster-template-user-assigned-identity.yaml @@ -1,6 +1,8 @@ apiVersion: cluster.x-k8s.io/v1alpha3 kind: Cluster metadata: + labels: + cni: calico name: ${CLUSTER_NAME} namespace: default spec: diff --git a/templates/cluster-template.yaml b/templates/cluster-template.yaml index 1e9f1160f63..ab2bf7c478e 100644 --- a/templates/cluster-template.yaml +++ b/templates/cluster-template.yaml @@ -1,6 +1,8 @@ apiVersion: cluster.x-k8s.io/v1alpha3 kind: Cluster metadata: + labels: + cni: calico name: ${CLUSTER_NAME} namespace: default spec: diff --git a/templates/flavors/base/cluster-template.yaml b/templates/flavors/base/cluster-template.yaml index 85091a737e2..32c10a56125 100644 --- a/templates/flavors/base/cluster-template.yaml +++ b/templates/flavors/base/cluster-template.yaml @@ -3,6 +3,8 @@ apiVersion: cluster.x-k8s.io/v1alpha3 kind: Cluster metadata: name: ${CLUSTER_NAME} + labels: + cni: "calico" spec: clusterNetwork: pods: diff --git a/templates/flavors/ipv6/patches/ipv6.yaml b/templates/flavors/ipv6/patches/ipv6.yaml index 1b6d95c4215..a4739a9aaa4 100644 --- a/templates/flavors/ipv6/patches/ipv6.yaml +++ b/templates/flavors/ipv6/patches/ipv6.yaml @@ -3,6 +3,8 @@ apiVersion: cluster.x-k8s.io/v1alpha3 kind: Cluster metadata: name: ${CLUSTER_NAME} + labels: + cni: "calico-ipv6" spec: clusterNetwork: pods: diff --git a/templates/test/cluster-template-prow-machine-pool-ci-version.yaml b/templates/test/cluster-template-prow-machine-pool-ci-version.yaml index e0f48b512dc..5316ed70803 100644 --- a/templates/test/cluster-template-prow-machine-pool-ci-version.yaml +++ b/templates/test/cluster-template-prow-machine-pool-ci-version.yaml @@ -1,6 +1,8 @@ apiVersion: cluster.x-k8s.io/v1alpha3 kind: Cluster metadata: + labels: + cni: ${CLUSTER_NAME}-crs-0 name: ${CLUSTER_NAME} namespace: default spec: @@ -358,3 +360,24 @@ spec: preKubeadmCommands: - bash -c /tmp/kubeadm-bootstrap.sh useExperimentalRetryJoin: true +--- +apiVersion: v1 +data: ${CNI_RESOURCES} +kind: ConfigMap +metadata: + name: cni-${CLUSTER_NAME}-crs-0 + namespace: default +--- +apiVersion: addons.cluster.x-k8s.io/v1alpha3 +kind: ClusterResourceSet +metadata: + name: ${CLUSTER_NAME}-crs-0 + namespace: default +spec: + clusterSelector: + matchLabels: + cni: ${CLUSTER_NAME}-crs-0 + resources: + - kind: ConfigMap + name: cni-${CLUSTER_NAME}-crs-0 + strategy: ApplyOnce diff --git a/templates/test/cluster-template-prow-machine-pool.yaml b/templates/test/cluster-template-prow-machine-pool.yaml index b7911469e01..b05a17ea88b 100644 --- a/templates/test/cluster-template-prow-machine-pool.yaml +++ b/templates/test/cluster-template-prow-machine-pool.yaml @@ -1,6 +1,8 @@ apiVersion: cluster.x-k8s.io/v1alpha3 kind: Cluster metadata: + labels: + cni: ${CLUSTER_NAME}-crs-0 name: ${CLUSTER_NAME} namespace: default spec: @@ -193,3 +195,24 @@ spec: cloud-provider: azure name: '{{ ds.meta_data["local_hostname"] }}' useExperimentalRetryJoin: true +--- +apiVersion: v1 +data: ${CNI_RESOURCES} +kind: ConfigMap +metadata: + name: cni-${CLUSTER_NAME}-crs-0 + namespace: default +--- +apiVersion: addons.cluster.x-k8s.io/v1alpha3 +kind: ClusterResourceSet +metadata: + name: ${CLUSTER_NAME}-crs-0 + namespace: default +spec: + clusterSelector: + matchLabels: + cni: ${CLUSTER_NAME}-crs-0 + resources: + - kind: ConfigMap + name: cni-${CLUSTER_NAME}-crs-0 + strategy: ApplyOnce diff --git a/templates/test/prow-machine-pool/cni-resource-set.yaml b/templates/test/prow-machine-pool/cni-resource-set.yaml new file mode 100644 index 00000000000..4dbde1c6f63 --- /dev/null +++ b/templates/test/prow-machine-pool/cni-resource-set.yaml @@ -0,0 +1,21 @@ +--- +apiVersion: v1 +data: ${CNI_RESOURCES} +kind: ConfigMap +metadata: + name: cni-${CLUSTER_NAME}-crs-0 + namespace: default +--- +apiVersion: addons.cluster.x-k8s.io/v1alpha3 +kind: ClusterResourceSet +metadata: + name: ${CLUSTER_NAME}-crs-0 + namespace: default +spec: + clusterSelector: + matchLabels: + cni: ${CLUSTER_NAME}-crs-0 + resources: + - kind: ConfigMap + name: cni-${CLUSTER_NAME}-crs-0 + strategy: ApplyOnce \ No newline at end of file diff --git a/templates/test/prow-machine-pool/kustomization.yaml b/templates/test/prow-machine-pool/kustomization.yaml index 4b004f9bd90..ef6dda292a8 100644 --- a/templates/test/prow-machine-pool/kustomization.yaml +++ b/templates/test/prow-machine-pool/kustomization.yaml @@ -3,5 +3,7 @@ kind: Kustomization namespace: default resources: - ../../flavors/machinepool + - cni-resource-set.yaml patchesStrategicMerge: - ../patches/tags.yaml + - ../patches/cni-resource-set.yaml