Skip to content

Commit

Permalink
feat: Use ModuleReleaseMeta in Kyma reconciliation loop instead of mo…
Browse files Browse the repository at this point in the history
…duletemplate.channel (#1947)

* Add implementation

* Add unit test

* Adjust test

* Adjust test

* Fix linting issue

* Fix linting issue

* Add rbac for modulereleasemeta

* Fix rbac

* Fix unit tests

* Fix role

* Fix linting

* Fix unit test

* Fix role

* Add E2E for ModuleReleaseMeta

* Fix E2E test

* Fix E2E test

* Your commit message here

* Add documentation

* Fix non-blocking deletion test

* Debug test

* Debug test

* Add test case for old moduletemplate name with modulereleasemeta

* Xin's comments

* Xin's comments

* Fix E2E test

* Update docs/contributor/02-controllers.md

Co-authored-by: Małgorzata Świeca <malgorzata.swieca@sap.com>

* Enhance doc

* Update docs/contributor/02-controllers.md

Co-authored-by: Małgorzata Świeca <malgorzata.swieca@sap.com>

* Update docs/contributor/02-controllers.md

Co-authored-by: Małgorzata Świeca <malgorzata.swieca@sap.com>

---------

Co-authored-by: Małgorzata Świeca <malgorzata.swieca@sap.com>
  • Loading branch information
nesmabadr and mmitoraj authored Oct 16, 2024
1 parent 62d0de9 commit 9491cf4
Show file tree
Hide file tree
Showing 20 changed files with 1,035 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
name: Deploy template-operator With ModuleReleaseMeta
description: Deploys a test-specific template-operator and corresponding ModuleReleaseMeta.
runs:
using: composite
steps:
- name: Create Template Operator Module and apply ModuleTemplate and ModuleReleaseMeta
working-directory: template-operator
if: ${{ matrix.e2e-test == 'kyma-metrics' ||
matrix.e2e-test == 'non-blocking-deletion' ||
matrix.e2e-test == 'purge-controller' ||
matrix.e2e-test == 'purge-metrics' ||
matrix.e2e-test == 'kyma-deprovision-with-foreground-propagation' ||
matrix.e2e-test == 'kyma-deprovision-with-background-propagation' ||
matrix.e2e-test == 'module-consistency' ||
matrix.e2e-test == 'skip-manifest-reconciliation' ||
matrix.e2e-test == 'misconfigured-kyma-secret' ||
matrix.e2e-test == 'unmanage-module'
}}
shell: bash
run: |
make build-manifests
kyma alpha create module --module-config-file ./module-config.yaml --path . --registry localhost:5111 --insecure
sed -i 's/localhost:5111/k3d-kcp-registry.localhost:5000/g' ./template.yaml
sed -i 's/template-operator-regular/template-operator-1.0.1/g' ./template.yaml
kubectl get crds
kubectl apply -f template.yaml
kubectl apply -f module-release-meta.yaml
- name: Apply Template Operator Module and ModuleReleaseMeta for regular and fast channels
working-directory: lifecycle-manager
if: ${{ matrix.e2e-test == 'module-upgrade-channel-switch' ||
matrix.e2e-test == 'module-upgrade-new-version' ||
matrix.e2e-test == 'upgrade-under-deletion'
}}
shell: bash
run: |
sed -i 's/template-operator-fast/template-operator-2.4.2-e2e-test/g' tests/moduletemplates/moduletemplate_template_operator_v2_fast.yaml
sed -i 's/template-operator-regular/template-operator-1.1.1-e2e-test/g' tests/moduletemplates/moduletemplate_template_operator_v1_regular.yaml
sed -i 's/template-operator-regular/template-operator-2.4.2-e2e-test/g' tests/moduletemplates/moduletemplate_template_operator_v2_regular_new_version.yaml
kubectl apply -f tests/moduletemplates/moduletemplate_template_operator_v2_fast.yaml
kubectl apply -f tests/moduletemplates/moduletemplate_template_operator_v1_regular.yaml
cat <<EOF > mrm.yaml
apiVersion: operator.kyma-project.io/v1beta2
kind: ModuleReleaseMeta
metadata:
name: template-operator
namespace: kcp-system
spec:
channels:
- channel: fast
version: 2.4.2-e2e-test
- channel: regular
version: 1.1.1-e2e-test
moduleName: template-operator
EOF
kubectl apply -f mrm.yaml
- name: Create Template Operator Module for installation by version
working-directory: lifecycle-manager
if: ${{ matrix.e2e-test == 'module-install-by-version' }}
shell: bash
run: |
kubectl apply -f tests/moduletemplates/moduletemplate_template_operator_v2_fast.yaml
kubectl apply -f tests/moduletemplates/moduletemplate_template_operator_v1_regular.yaml
kubectl apply -f tests/moduletemplates/moduletemplate_template_operator_v2_direct_version.yaml
- name: Create Template Operator Module as Mandatory Module
working-directory: lifecycle-manager
if: ${{ matrix.e2e-test == 'mandatory-module' ||
matrix.e2e-test == 'mandatory-module-metrics'
}}
shell: bash
run: |
kubectl apply -f tests/moduletemplates/mandatory_moduletemplate_template_operator_v1.yaml
- name: Apply Template Operator Module V2 and ModuleReleaseMeta, fast channel
working-directory: ./lifecycle-manager
if: ${{ matrix.e2e-test == 'non-blocking-deletion' }}
shell: bash
run: |
sed -i 's/template-operator-fast/template-operator-2.4.2-e2e-test/g' tests/moduletemplates/moduletemplate_template_operator_v2_fast.yaml
kubectl apply -f tests/moduletemplates/moduletemplate_template_operator_v2_fast.yaml
cat <<EOF > mrm.yaml
apiVersion: operator.kyma-project.io/v1beta2
kind: ModuleReleaseMeta
metadata:
name: template-operator
namespace: kcp-system
spec:
channels:
- channel: fast
version: 2.4.2-e2e-test
- channel: regular
version: 1.0.1
moduleName: template-operator
EOF
kubectl apply -f mrm.yaml
- name: Create Template Operator Module with Deployment, with final state and final deletion state as `Warning` and apply
working-directory: template-operator
if: ${{ matrix.e2e-test == 'module-status-decoupling-with-deployment'}}
shell: bash
run: |
pushd config/overlays/deployment
echo \
"- op: replace
path: /spec/template/spec/containers/0/args/1
value: --final-state=Warning
- op: replace
path: /spec/template/spec/containers/0/args/2
value: --final-deletion-state=Warning" >> warning_patch.yaml
cat warning_patch.yaml
kustomize edit add patch --path warning_patch.yaml --kind Deployment
popd
make build-manifests
kyma alpha create module --module-config-file ./module-config.yaml --path . --registry localhost:5111 --insecure
sed -i 's/localhost:5111/k3d-kcp-registry.localhost:5000/g' ./template.yaml
sed -i 's/template-operator-regular/template-operator-1.0.1/g' ./template.yaml
kubectl get crds
kubectl apply -f template.yaml
kubectl apply -f module-release-meta.yaml
- name: Create Template Operator Module with StatefulSet, with final state and final deletion state as `Warning` and apply
working-directory: template-operator
if: ${{ matrix.e2e-test == 'module-status-decoupling-with-statefulset'}}
shell: bash
run: |
pushd config/overlays/statefulset
echo \
"- op: replace
path: /spec/template/spec/containers/0/args/1
value: --final-state=Warning
- op: replace
path: /spec/template/spec/containers/0/args/2
value: --final-deletion-state=Warning" >> warning_patch.yaml
cat warning_patch.yaml
kustomize edit add patch --path warning_patch.yaml --kind StatefulSet
popd
make build-statefulset-manifests
kyma alpha create module --module-config-file ./module-config.yaml --path . --registry localhost:5111 --insecure
sed -i 's/localhost:5111/k3d-kcp-registry.localhost:5000/g' ./template.yaml
sed -i 's/template-operator-regular/template-operator-1.0.1/g' ./template.yaml
kubectl get crds
kubectl apply -f template.yaml
kubectl apply -f module-release-meta.yaml
- name: Create non-working image patch for Template Operator Module and create associated module config file and applying ModuleReleaseMeta
working-directory: template-operator
if: ${{ matrix.e2e-test == 'module-status-decoupling-with-deployment'||
matrix.e2e-test == 'module-status-decoupling-with-statefulset'}}
shell: bash
run: |
echo "name: kyma-project.io/module/template-operator-misconfigured
channel: regular
version: v1.1.1
manifest: template-operator.yaml
security: sec-scanners-config.yaml
defaultCR: ./config/samples/default-sample-cr.yaml
annotations:
operator.kyma-project.io/doc-url: https://kyma-project.io" >> misconfigured-module-config.yaml
cat <<EOF > mrm.yaml
apiVersion: operator.kyma-project.io/v1beta2
kind: ModuleReleaseMeta
metadata:
name: template-operator-misconfigured
namespace: kcp-system
spec:
channels:
- channel: regular
version: 1.1.1
moduleName: template-operator-misconfigured
EOF
kubectl apply -f mrm.yaml
- name: Create Template Operator Module with Deployment, with non-working image and apply
working-directory: template-operator
if: ${{ matrix.e2e-test == 'module-status-decoupling-with-deployment'}}
shell: bash
run: |
pushd config/overlays/deployment
echo \
"- op: replace
path: /spec/template/spec/containers/0/image
value: non-working-path" >> image_patch.yaml
cat image_patch.yaml
kustomize edit add patch --path image_patch.yaml --kind Deployment
popd
make build-manifests
kyma alpha create module --module-config-file ./misconfigured-module-config.yaml --path . --registry localhost:5111 --insecure
sed -i 's/localhost:5111/k3d-kcp-registry.localhost:5000/g' ./template.yaml
sed -i 's/template-operator-misconfigured-regular/template-operator-misconfigured-1.1.1/g' ./template.yaml
kubectl get crds
kubectl apply -f template.yaml
- name: Create Template Operator Module with StatefulSet, with non-working image and apply
working-directory: template-operator
if: ${{ matrix.e2e-test == 'module-status-decoupling-with-statefulset'}}
shell: bash
run: |
pushd config/overlays/statefulset
echo \
"- op: replace
path: /spec/template/spec/containers/0/image
value: non-working-path" >> image_patch.yaml
cat image_patch.yaml
kustomize edit add patch --path image_patch.yaml --kind StatefulSet
popd
make build-statefulset-manifests
kyma alpha create module --module-config-file ./misconfigured-module-config.yaml --path . --registry localhost:5111 --insecure
sed -i 's/localhost:5111/k3d-kcp-registry.localhost:5000/g' ./template.yaml
sed -i 's/template-operator-misconfigured-regular/template-operator-misconfigured-1.1.1/g' ./template.yaml
kubectl get crds
kubectl apply -f template.yaml
- name: Create Template Operator Module without default CR and apply ModuleReleaseMeta
working-directory: template-operator
if: ${{ matrix.e2e-test == 'module-without-default-cr' }}
shell: bash
run: |
make build-manifests
echo "name: kyma-project.io/module/template-operator
channel: regular
version: v1.0.0
manifest: template-operator.yaml
security: sec-scanners-config.yaml
annotations:
operator.kyma-project.io/doc-url: https://kyma-project.io" >> module-config-no-cr.yaml
kyma alpha create module \
--module-config-file ./module-config-no-cr.yaml \
--path . \
--registry localhost:5111 \
--insecure
sed -i 's/localhost:5111/k3d-kcp-registry.localhost:5000/g' ./template.yaml
sed -i 's/template-operator-regular/template-operator-1.0.0/g' ./template.yaml
kubectl get crds
kubectl apply -f template.yaml
cat <<EOF > mrm.yaml
apiVersion: operator.kyma-project.io/v1beta2
kind: ModuleReleaseMeta
metadata:
name: template-operator
namespace: kcp-system
spec:
channels:
- channel: regular
version: 1.0.0
moduleName: template-operator
EOF
kubectl apply -f mrm.yaml
- name: Apply ModuleReleaseMeta and Template Operator Module in OCM format
working-directory: ./lifecycle-manager
if: ${{ matrix.e2e-test == 'ocm-compatible-module-template' }}
shell: bash
run: |
sed -i 's/template-operator-regular/template-operator-1.0.0-new-ocm-format/g' tests/moduletemplates/moduletemplate_template_operator_regular_new_ocm.yaml
kubectl apply -f tests/moduletemplates/moduletemplate_template_operator_regular_new_ocm.yaml
cat <<EOF > mrm.yaml
apiVersion: operator.kyma-project.io/v1beta2
kind: ModuleReleaseMeta
metadata:
name: template-operator
namespace: kcp-system
spec:
channels:
- channel: regular
version: 1.0.0-new-ocm-format
moduleName: template-operator
EOF
kubectl apply -f mrm.yaml
- name: Apply ModuleReleaseMeta with ModuleTemplate with name <modulename>-<channel>
working-directory: template-operator
if: ${{ matrix.e2e-test == 'modulereleasemeta-with-obsolete-moduletemplate' }}
shell: bash
run: |
make build-manifests
kyma alpha create module --module-config-file ./module-config.yaml --path . --registry localhost:5111 --insecure
sed -i 's/localhost:5111/k3d-kcp-registry.localhost:5000/g' ./template.yaml
kubectl apply -f template.yaml
kubectl apply -f module-release-meta.yaml

104 changes: 104 additions & 0 deletions .github/workflows/test-e2e-with-modulereleasemeta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: TestSuite E2E with ModuleReleaseMeta

env:
IMAGE_REPO: europe-docker.pkg.dev/kyma-project/dev/lifecycle-manager
on:
workflow_dispatch:
inputs:
k8s_version:
description: With Kubernetes version
required: false
pull_request:
types: [ opened, edited, synchronize, reopened, ready_for_review ]
jobs:
wait-for-image-build:
name: Wait for image build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Wait for the Docker image
timeout-minutes: 20
env:
ITERATIONS: 40
SLEEP_SECONDS: 30
run: ./.github/scripts/release/wait_for_image.sh ${{ env.IMAGE_REPO }}:${{ github.event.pull_request.head.sha }} ${{ env.ITERATIONS }} ${{ env.SLEEP_SECONDS}}
e2e-integration:
name: E2E With ModuleReleaseMeta
needs: wait-for-image-build
strategy:
fail-fast: false
matrix:
e2e-test:
- watcher-enqueue
- kyma-deprovision-with-foreground-propagation
- kyma-deprovision-with-background-propagation
- module-status-decoupling-with-statefulset
- module-status-decoupling-with-deployment
- kyma-metrics
- module-without-default-cr
- module-consistency
- non-blocking-deletion
- upgrade-under-deletion
- purge-controller
- purge-metrics
- module-upgrade-channel-switch
- module-upgrade-new-version
- unmanage-module
- skip-manifest-reconciliation
- ca-certificate-rotation
- self-signed-certificate-rotation
- mandatory-module
- mandatory-module-metrics
- misconfigured-kyma-secret
- rbac-privileges
- ocm-compatible-module-template
- modulereleasemeta-with-obsolete-moduletemplate
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout lifecycle-manager
uses: actions/checkout@v4
with:
path: lifecycle-manager

- name: Checkout template-operator
uses: actions/checkout@v4
with:
repository: kyma-project/template-operator
path: template-operator

- name: Get configuration
uses: ./lifecycle-manager/.github/actions/get-configuration
id: configuration

- name: Setup tools
uses: ./lifecycle-manager/.github/actions/setup-tools
with:
k8s_version: ${{ steps.configuration.outputs.k8s_version }}
istio_version: ${{ steps.configuration.outputs.istio_version }}
k3d_version: ${{ steps.configuration.outputs.k3d_version }}
go-version-file: lifecycle-manager/go.mod
cache-dependency-path: lifecycle-manager/go.sum

- name: Setup test clusters
uses: ./lifecycle-manager/.github/actions/setup-test-clusters
with:
k8s_version: ${{ steps.configuration.outputs.k8s_version }}
cert_manager_version: ${{ steps.configuration.outputs.cert_manager_version }}

- name: Deploy lifecycle-manager
uses: ./lifecycle-manager/.github/actions/deploy-lifecycle-manager-e2e
with:
klm_version_tag: ${{ steps.configuration.outputs.klm_version_tag }}
klm_image_repo: ${{ steps.configuration.outputs.klm_image_repo }}

- name: Deploy template-operator
uses: ./lifecycle-manager/.github/actions/deploy-template-operator-with-modulereleasemeta

- name: Run '${{ matrix.e2e-test }}' test
working-directory: lifecycle-manager
run: |
make -C tests/e2e ${{ matrix.e2e-test }}
Loading

0 comments on commit 9491cf4

Please sign in to comment.