From ff6e65bb9783f144e73de79f8edbdfc4407e05ff Mon Sep 17 00:00:00 2001 From: Waciuma Wanjohi Date: Mon, 22 Jan 2024 15:35:25 -0500 Subject: [PATCH] Demonstrate ClusterTemplate can consume ClusterDeliveryTemplate output --- .../00-service-account.yaml | 34 +++++ .../00-templates.yaml | 71 +++++++++ .../01-delivery.yaml | 41 +++++ .../02-assert.yaml | 142 ++++++++++++++++++ .../02-deliverable.yaml | 26 ++++ 5 files changed, 314 insertions(+) create mode 100644 tests/kuttl/delivery/cluster-template-after-deployment/00-service-account.yaml create mode 100644 tests/kuttl/delivery/cluster-template-after-deployment/00-templates.yaml create mode 100644 tests/kuttl/delivery/cluster-template-after-deployment/01-delivery.yaml create mode 100644 tests/kuttl/delivery/cluster-template-after-deployment/02-assert.yaml create mode 100644 tests/kuttl/delivery/cluster-template-after-deployment/02-deliverable.yaml diff --git a/tests/kuttl/delivery/cluster-template-after-deployment/00-service-account.yaml b/tests/kuttl/delivery/cluster-template-after-deployment/00-service-account.yaml new file mode 100644 index 000000000..f426e55df --- /dev/null +++ b/tests/kuttl/delivery/cluster-template-after-deployment/00-service-account.yaml @@ -0,0 +1,34 @@ +# Copyright 2021 VMware +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: my-service-account +secrets: + - name: my-service-account-secret + +--- + +apiVersion: v1 +kind: Secret +metadata: + name: my-service-account-secret + annotations: + kubernetes.io/service-account.name: my-service-account +data: + token: "ZXlKaGJHY2lPaUpTVXpJMU5pSXNJbXRwWkNJNklubFNWM1YxVDNSRldESnZVRE4wTUd0R1EzQmlVVlJOVWtkMFNG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0bDl5MzlvUi1KbWh3RUlIcS1hX3BzaVh5WE9EQU44STcybEZpUSU=" +type: kubernetes.io/service-account-token \ No newline at end of file diff --git a/tests/kuttl/delivery/cluster-template-after-deployment/00-templates.yaml b/tests/kuttl/delivery/cluster-template-after-deployment/00-templates.yaml new file mode 100644 index 000000000..3ebee1afd --- /dev/null +++ b/tests/kuttl/delivery/cluster-template-after-deployment/00-templates.yaml @@ -0,0 +1,71 @@ +# Copyright 2021 VMware +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +apiVersion: carto.run/v1alpha1 +kind: ClusterSourceTemplate +metadata: + name: example-source---cluster-template-after-deployment +spec: + template: + apiVersion: v1 + kind: ConfigMap + metadata: + name: example-source-configmap + data: + player_initial_lives: "5" + player_loves: "knitting" + urlPath: data.player_initial_lives + revisionPath: data.player_loves + healthRule: + alwaysHealthy: {} + +--- +apiVersion: carto.run/v1alpha1 +kind: ClusterDeploymentTemplate +metadata: + name: example-deployment---cluster-template-after-deployment +spec: + template: + apiVersion: v1 + kind: ConfigMap + metadata: + name: example-deployment-configmap + data: + favorite_color: $(deployment.url)$ + healthRule: + multiMatch: + healthy: + matchFields: + - key: .data.favorite_color + operator: Exists + messagePath: .metadata.name + unhealthy: + matchFields: + - key: .data.error + operator: Exists + messagePath: .metadata.name +--- +apiVersion: carto.run/v1alpha1 +kind: ClusterTemplate +metadata: + name: example-task---cluster-template-after-deployment +spec: + template: + apiVersion: v1 + kind: ConfigMap + metadata: + name: example-task + data: + some_task: $(deployment.url)$ diff --git a/tests/kuttl/delivery/cluster-template-after-deployment/01-delivery.yaml b/tests/kuttl/delivery/cluster-template-after-deployment/01-delivery.yaml new file mode 100644 index 000000000..5710d0c23 --- /dev/null +++ b/tests/kuttl/delivery/cluster-template-after-deployment/01-delivery.yaml @@ -0,0 +1,41 @@ +# Copyright 2021 VMware +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +apiVersion: carto.run/v1alpha1 +kind: ClusterDelivery +metadata: + name: responsible-ops---cluster-template-after-deployment +spec: + selector: + integration-test: "cluster-template-after-deployment" + resources: + - name: source-provider + templateRef: + kind: ClusterSourceTemplate + name: example-source---cluster-template-after-deployment + + - name: deployer + templateRef: + kind: ClusterDeploymentTemplate + name: example-deployment---cluster-template-after-deployment + deployment: + resource: source-provider + + - name: task + templateRef: + kind: ClusterTemplate + name: example-task---cluster-template-after-deployment + deployment: + resource: deployer diff --git a/tests/kuttl/delivery/cluster-template-after-deployment/02-assert.yaml b/tests/kuttl/delivery/cluster-template-after-deployment/02-assert.yaml new file mode 100644 index 000000000..920066d08 --- /dev/null +++ b/tests/kuttl/delivery/cluster-template-after-deployment/02-assert.yaml @@ -0,0 +1,142 @@ +# Copyright 2021 VMware +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: example-source-configmap +data: + player_initial_lives: "5" + player_loves: "knitting" + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: example-deployment-configmap +data: + favorite_color: "5" + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: example-task +data: + some_task: "5" + +--- +apiVersion: carto.run/v1alpha1 +kind: Deliverable +metadata: + name: petclinic +status: + conditions: + - type: DeliveryReady + status: "True" + reason: Ready + - type: ResourcesSubmitted + status: "True" + reason: ResourceSubmissionComplete + - type: ResourcesHealthy + status: "True" + reason: HealthyConditionRule + - type: Ready + status: "True" + reason: Ready + deliveryRef: + name: responsible-ops---cluster-template-after-deployment + kind: ClusterDelivery + resources: + - name: source-provider + stampedRef: + apiVersion: v1 + kind: ConfigMap + name: example-source-configmap + templateRef: + apiVersion: carto.run/v1alpha1 + kind: ClusterSourceTemplate + name: example-source---cluster-template-after-deployment + outputs: + - name: url + preview: | + "5" + digest: sha256:11fd182657d58787e0e5b61c5da79195f8715fef7f957b9cdba2d8a581b2ca33 + - name: revision + preview: | + knitting + digest: sha256:ccea367d03c124f9594e3ba0aa97e533c35a47694f62757e4dce79039ca361d7 + conditions: + - type: ResourceSubmitted + status: "True" + reason: ResourceSubmissionComplete + - type: Healthy + status: "True" + reason: AlwaysHealthy + - type: Ready + status: "True" + reason: Ready + - name: deployer + stampedRef: + apiVersion: v1 + kind: ConfigMap + name: example-deployment-configmap + templateRef: + apiVersion: carto.run/v1alpha1 + kind: ClusterDeploymentTemplate + name: example-deployment---cluster-template-after-deployment + inputs: + - name: source-provider + outputs: + - name: url + preview: | + "5" + digest: sha256:11fd182657d58787e0e5b61c5da79195f8715fef7f957b9cdba2d8a581b2ca33 + - name: revision + preview: | + knitting + digest: sha256:ccea367d03c124f9594e3ba0aa97e533c35a47694f62757e4dce79039ca361d7 + conditions: + - type: ResourceSubmitted + status: "True" + reason: ResourceSubmissionComplete + - type: Healthy + status: "True" + reason: MatchedField + message: "field value: 5, message: example-deployment-configmap" + - type: Ready + status: "True" + reason: Ready + - name: task + stampedRef: + apiVersion: v1 + kind: ConfigMap + name: example-task + templateRef: + apiVersion: carto.run/v1alpha1 + kind: ClusterTemplate + name: example-task---cluster-template-after-deployment + inputs: + - name: deployer + conditions: + - type: ResourceSubmitted + status: "True" + reason: ResourceSubmissionComplete + - type: Healthy + status: "True" + reason: AlwaysHealthy + - type: Ready + status: "True" + reason: Ready diff --git a/tests/kuttl/delivery/cluster-template-after-deployment/02-deliverable.yaml b/tests/kuttl/delivery/cluster-template-after-deployment/02-deliverable.yaml new file mode 100644 index 000000000..d12b6fcac --- /dev/null +++ b/tests/kuttl/delivery/cluster-template-after-deployment/02-deliverable.yaml @@ -0,0 +1,26 @@ +# Copyright 2021 VMware +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +apiVersion: carto.run/v1alpha1 +kind: Deliverable +metadata: + name: petclinic + labels: + integration-test: "cluster-template-after-deployment" +spec: + serviceAccountName: my-service-account + source: + git: + url: https://github.com/spring-projects/spring-petclinic.git