Skip to content

Commit 1fcfebb

Browse files
authored
feat: Use OCM cli to submit OCM components in KLM e2e (#2863)
feat(e2e): add OCM CLI support and improve template-operator e2e deployment - Add install-ocm-cli action (.github/actions/install-ocm-cli/action.yml) to install OCM CLI with checksum verification. - Expose ocm_cli_version and template_operator_version outputs in get-configuration action and wire them into workflows. - Install ocm-cli from setup-tools and pass ocm_cli_version to the setup step. - Checkout template-operator using template_operator_version and pass module_version into the deploy action. - Enhance deploy-template-operator-with-modulereleasemeta: - Read module version from versions.yaml, set image tags with yq and build manifests. - Use modulectl to generate component constructor and OCM CLI to create/transfer CTF to registries (support local & private registries). - Add debug checks for ModuleTemplate / ModuleReleaseMeta and registry contents. - Pass both the OCM release version and the actual deployable image version to deploy_moduletemplate. - Update deploy_moduletemplate.sh: - Add required DEPLOYABLE_IMAGE_VERSION parameter and input validation. - Use modulectl + ocm to generate/push component versions, patch manifests, apply ModuleTemplate, and clean up temp files. - Improve logging and error handling. - Add ocm-config-local-registry.yaml and ocm-config-private-registry.yaml under scripts/tests. - Add contributor documentation for creating ModuleTemplate with modulectl + OCM CLI and link it from ModuleTemplate docs. - Improve teardown/debug scripts output for easier troubleshooting. - Bump tooling in versions.yaml: modulectl -> 2.5.0, add ocm-cli 0.32.0, add template-operator version. - Minor formatting and reliability improvements across workflows and scripts. - No breaking API changes; this improves e2e reliability by aligning deployed images with versions.yaml and pushing component descriptors via OCM.
1 parent aae65b0 commit 1fcfebb

File tree

15 files changed

+477
-45
lines changed

15 files changed

+477
-45
lines changed

.github/actions/deploy-template-operator-with-modulereleasemeta/action.yml

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ name: Deploy template-operator With ModuleReleaseMeta
22
description: Deploys a test-specific template-operator and corresponding ModuleReleaseMeta.
33
inputs:
44
module_version:
5-
description: "Version of the template operator to be deployed, should be aligned with the latest version released in github."
5+
description: "Version of the template operator to be deployed, should be aligned with the version in versions.yaml"
66
required: true
7-
default: "1.0.4"
87
runs:
98
using: composite
109
steps:
@@ -22,6 +21,8 @@ runs:
2221
cp ../lifecycle-manager/scripts/tests/deploy_moduletemplate.sh .
2322
cp ../lifecycle-manager/scripts/tests/deploy_modulereleasemeta.sh .
2423
cp ../lifecycle-manager/scripts/tests/deploy_mandatory_modulereleasemeta.sh .
24+
cp ../lifecycle-manager/scripts/tests/ocm-config-local-registry.yaml .
25+
cp ../lifecycle-manager/scripts/tests/ocm-config-private-registry.yaml .
2526
- name: Create and apply Template Operator ModuleTemplate from the latest release
2627
working-directory: template-operator
2728
if: ${{ matrix.e2e-test != 'mandatory-module' &&
@@ -31,10 +32,9 @@ runs:
3132
}}
3233
shell: bash
3334
run: |
34-
modulectl create --config-file ./module-config.yaml --registry http://localhost:5111 --insecure
35-
sed -i 's/localhost:5111/k3d-kcp-registry.localhost:5000/g' ./template.yaml
36-
kubectl get crds
37-
kubectl apply -f template.yaml
35+
yq eval '.images[0].newTag = "${{ inputs.module_version }}"' -i config/manager/deployment/kustomization.yaml
36+
make build-manifests
37+
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ inputs.module_version }} ${{ inputs.module_version }} true false true false
3838
- name: Create and apply Template Operator ModuleTemplate with ModuleDeploymentNameInOlderVersion
3939
working-directory: template-operator
4040
if: ${{ matrix.e2e-test != 'mandatory-module' &&
@@ -44,9 +44,10 @@ runs:
4444
}}
4545
shell: bash
4646
run: |
47+
yq eval '.images[0].newTag = "${{ env.OlderVersion }}"' -i config/manager/deployment/kustomization.yaml
4748
make build-manifests
4849
yq eval '(. | select(.kind == "Deployment") | .metadata.name) = "${{ env.ModuleDeploymentNameInOlderVersion }}"' -i template-operator.yaml
49-
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ env.OlderVersion }}
50+
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ env.OlderVersion }} ${{ inputs.module_version }} true false true false
5051
- name: Create and apply Template Operator ModuleTemplate with ModuleDeploymentNameInNewerVersion
5152
working-directory: template-operator
5253
if: ${{ matrix.e2e-test != 'mandatory-module' &&
@@ -67,18 +68,44 @@ runs:
6768
REQUIRE_DOWNTIME=false
6869
fi
6970
71+
yq eval '.images[0].newTag = "${{ env.NewerVersion }}"' -i config/manager/deployment/kustomization.yaml
7072
make build-manifests
7173
yq eval '(. | select(.kind == "Deployment") | .metadata.name) = "${{ env.ModuleDeploymentNameInNewerVersion }}"' -i template-operator.yaml
72-
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ env.NewerVersion }} $INCLUDE_DEFAULT_CR $MANDATORY $DEPLOY_MODULETEMPLATE $REQUIRE_DOWNTIME
74+
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ env.NewerVersion }} ${{ inputs.module_version }} $INCLUDE_DEFAULT_CR $MANDATORY $DEPLOY_MODULETEMPLATE $REQUIRE_DOWNTIME
7375
- name: Create and apply Template Operator ModuleTemplate in private registry
7476
working-directory: template-operator
7577
if: ${{ matrix.e2e-test == 'oci-reg-cred-secret' }}
7678
shell: bash
7779
run: |
78-
modulectl create --config-file ./module-config.yaml --registry http://k3d-private-oci-reg.localhost:5001 --registry-credentials myuser:mypass --insecure
79-
sed -i 's/k3d-private-oci-reg.localhost:5001/private-oci-reg.localhost:5000/g' ./template.yaml
80+
MODULE_CONFIG="./module-config.yaml"
81+
REGISTRY_URL="k3d-private-oci-reg.localhost:5001"
82+
REGISTRY_CREDS="myuser:mypass"
83+
COMPONENT_CONSTRUCTOR_FILE="./component-constructor.yaml"
84+
CTF_DIR="./component-ctf"
85+
TEMPLATE_FILE="./template.yaml"
86+
TARGET_REGISTRY="private-oci-reg.localhost:5000"
87+
OCM_CONFIG="./ocm-config-private-registry.yaml"
88+
89+
echo "creating ModuleTemplate"
90+
modulectl create \
91+
--config-file "${MODULE_CONFIG}" \
92+
--disable-ocm-registry-push \
93+
--output-constructor-file "${COMPONENT_CONSTRUCTOR_FILE}"
94+
95+
echo "pushing OCM components..."
96+
ocm --config "${OCM_CONFIG}" add componentversions --create --file "${CTF_DIR}" --skip-digest-generation "${COMPONENT_CONSTRUCTOR_FILE}"
97+
ocm --config "${OCM_CONFIG}" transfer ctf \
98+
--overwrite \
99+
--no-update \
100+
"${CTF_DIR}" \
101+
"http://${REGISTRY_URL}"
102+
103+
echo "Verifying component in private registry..."
104+
curl -s -u myuser:mypass "http://${REGISTRY_URL}/v2/_catalog" || echo "Warning: Could not verify registry catalog"
105+
106+
echo "No baseUrl patching needed for private registry..."
80107
kubectl get crds
81-
kubectl apply -f template.yaml
108+
kubectl apply -f <(yq eval '.metadata.namespace = "kcp-system"' "${TEMPLATE_FILE}")
82109
- name: Create and apply ModuleReleaseMeta from the template-operator repo
83110
working-directory: template-operator
84111
if: ${{ matrix.e2e-test == 'kyma-metrics' ||
@@ -126,9 +153,10 @@ runs:
126153
}}
127154
shell: bash
128155
run: |
156+
yq eval '.images[0].newTag = "${{ env.OlderVersionForMandatoryModule }}"' -i config/manager/deployment/kustomization.yaml
129157
make build-manifests
130158
yq eval '(. | select(.kind == "Deployment") | .metadata.name) = "${{ env.ModuleDeploymentNameInOlderVersion }}"' -i template-operator.yaml
131-
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ env.OlderVersionForMandatoryModule }} true true false
159+
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ env.OlderVersionForMandatoryModule }} ${{ inputs.module_version }} true true false false
132160
yq eval 'del(.spec.mandatory)' -i template.yaml
133161
kubectl apply -f template.yaml
134162
rm -f template.yaml
@@ -140,9 +168,10 @@ runs:
140168
working-directory: template-operator
141169
shell: bash
142170
run: |
171+
yq eval '.images[0].newTag = "${{ env.NewerVersionForMandatoryModule }}"' -i config/manager/deployment/kustomization.yaml
143172
make build-manifests
144173
yq eval '(. | select(.kind == "Deployment") | .metadata.name) = "${{ env.ModuleDeploymentNameInNewerVersion }}"' -i template-operator.yaml
145-
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ env.NewerVersionForMandatoryModule }} true true false
174+
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ env.NewerVersionForMandatoryModule }} ${{ inputs.module_version }} true true false false
146175
yq eval 'del(.spec.mandatory)' -i template.yaml
147176
cp template.yaml ../lifecycle-manager/tests/e2e/mandatory_template_v2.yaml
148177
- name: Create and apply ModuleReleaseMeta Template Operator with newer version in fast channel and older version in regular channel
@@ -157,14 +186,16 @@ runs:
157186
shell: bash
158187
run: |
159188
# Create and apply ModuleReleaseMeta with version when deployment is in warning state
189+
yq eval '.images[0].newTag = "${{ env.VersionForDeploymentInWarning }}"' -i config/manager/deployment/kustomization.yaml
160190
make build-manifests
161191
yq eval '(. | select(.kind == "Deployment") | .spec.template.spec.containers[0].args) = ["--leader-elect", "--final-state=Warning", "--final-deletion-state=Warning"]' -i template-operator.yaml
162-
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ env.VersionForDeploymentInWarning }}
192+
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ env.VersionForDeploymentInWarning }} ${{ inputs.module_version }} true false true false
163193
./deploy_modulereleasemeta.sh ${{ env.ModuleName }} regular:${{ env.VersionForDeploymentInWarning }}
164194
165195
# Create and apply ModuleReleaseMeta with version when deployment is misconfigured
196+
yq eval '.images[0].newTag = "${{ env.VersionForMisconfiguredDeploymentImage }}"' -i config/manager/deployment/kustomization.yaml
166197
make build-manifests
167-
yq eval '(. | select(.kind == "Deployment") | .spec.template.spec.containers[0].image) = "non-working/path:001"' -i template-operator.yaml
198+
yq eval '(. | select(.kind == "Deployment") | .spec.template.spec.containers[0].image) = "non-working/path:0.0.1"' -i template-operator.yaml
168199
yq eval '(. | select(.kind == "Deployment") | .spec.progressDeadlineSeconds) = 60' -i template-operator.yaml
169200
yq eval '(. | select(.kind == "Deployment") | .spec.template.spec.containers[0].livenessProbe) = {
170201
"httpGet": {"path": "/healthz", "port": 8081},
@@ -174,31 +205,34 @@ runs:
174205
"httpGet": {"path": "/readyz", "port": 8081},
175206
"initialDelaySeconds": 5, "periodSeconds": 5, "failureThreshold": 1
176207
}' -i template-operator.yaml
177-
./deploy_moduletemplate.sh ${{ env.MisconfiguredModuleName }} ${{ env.VersionForMisconfiguredDeploymentImage }}
208+
./deploy_moduletemplate.sh ${{ env.MisconfiguredModuleName }} ${{ env.VersionForMisconfiguredDeploymentImage }} ${{ inputs.module_version }} true false true false
178209
./deploy_modulereleasemeta.sh ${{ env.MisconfiguredModuleName }} regular:${{ env.VersionForMisconfiguredDeploymentImage }}
179210
- name: Create ModuleTemplate and ModuleReleaseMeta for Module Status test with StatefulSet
180211
working-directory: template-operator
181212
if: ${{ matrix.e2e-test == 'module-status-decoupling-with-statefulset'}}
182213
shell: bash
183214
run: |
184215
# Create and apply ModuleReleaseMeta with version when statefulset is in warning state
216+
yq eval '.images[0].newTag = "${{ env.VersionForStatefulSetInWarning }}"' -i config/manager/statefulset/kustomization.yaml
185217
make build-statefulset-manifests
186218
yq eval '(. | select(.kind == "StatefulSet") | .spec.template.spec.containers[0].args) = ["--leader-elect", "--final-state=Warning", "--final-deletion-state=Warning"]' -i template-operator.yaml
187-
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ env.VersionForStatefulSetInWarning }}
219+
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ env.VersionForStatefulSetInWarning }} ${{ inputs.module_version }} true false true false
188220
./deploy_modulereleasemeta.sh ${{ env.ModuleName }} regular:${{ env.VersionForStatefulSetInWarning }}
189221
190222
# Create and apply ModuleReleaseMeta with version when statefulset is misconfigured
223+
yq eval '.images[0].newTag = "${{ env.VersionForMisconfiguredStatefulSetImage }}"' -i config/manager/statefulset/kustomization.yaml
191224
make build-statefulset-manifests
192-
yq eval '(. | select(.kind == "StatefulSet") | .spec.template.spec.containers[0].image) = "non-working/path:002"' -i template-operator.yaml
193-
./deploy_moduletemplate.sh ${{ env.MisconfiguredModuleName }} ${{ env.VersionForMisconfiguredStatefulSetImage }}
225+
yq eval '(. | select(.kind == "StatefulSet") | .spec.template.spec.containers[0].image) = "non-working/path:0.0.2"' -i template-operator.yaml
226+
./deploy_moduletemplate.sh ${{ env.MisconfiguredModuleName }} ${{ env.VersionForMisconfiguredStatefulSetImage }} ${{ inputs.module_version }} true false true false
194227
./deploy_modulereleasemeta.sh ${{ env.MisconfiguredModuleName }} regular:${{ env.VersionForMisconfiguredStatefulSetImage }}
195228
- name: Create Template Operator Module without default CR and apply ModuleReleaseMeta
196229
working-directory: template-operator
197230
if: ${{ matrix.e2e-test == 'module-without-default-cr' }}
198231
shell: bash
199232
run: |
233+
yq eval '.images[0].newTag = "${{ env.VersionForNoDefaultCR }}"' -i config/manager/deployment/kustomization.yaml
200234
make build-manifests
201-
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ env.VersionForNoDefaultCR }} false
235+
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ env.VersionForNoDefaultCR }} ${{ inputs.module_version }} false false true false
202236
./deploy_modulereleasemeta.sh ${{ env.ModuleName }} regular:${{ env.VersionForNoDefaultCR }}
203237
- name: Apply ModuleReleaseMeta with ModuleTemplate with name <modulename>-<channel>
204238
working-directory: template-operator
@@ -220,3 +254,21 @@ runs:
220254
shell: bash
221255
run: |
222256
kubectl apply -f tests/e2e/moduletemplate/moduletemplate_template_operator_transferred.yaml
257+
- name: Debug - Check ModuleTemplate and Component Status
258+
working-directory: lifecycle-manager
259+
shell: bash
260+
run: |
261+
echo "=== Checking ModuleTemplates in kcp-system ==="
262+
kubectl get moduletemplates -n kcp-system -o wide || echo "Failed to get ModuleTemplates"
263+
264+
echo ""
265+
echo "=== Checking ModuleReleaseMeta ==="
266+
kubectl get modulereleasemeta -n kcp-system -o wide || echo "Failed to get ModuleReleaseMeta"
267+
268+
echo ""
269+
echo "=== Checking if components are in registry ==="
270+
curl -s "http://localhost:5111/v2/_catalog" || echo "Warning: Could not query registry catalog"
271+
272+
echo ""
273+
echo "=== Checking if component version exists ==="
274+
curl -s "http://localhost:5111/v2/component-descriptors/kyma-project.io/module/template-operator/tags/list" || echo "Warning: Could not list component tags"

.github/actions/get-configuration/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ outputs:
1010
k3d_version:
1111
description: The version of k3d to install. For example, 5.6.0.
1212
value: ${{ steps.define-variables.outputs.k3d_version }}
13+
ocm_cli_version:
14+
description: The version of ocm-cli to install. For example, 0.32.0.
15+
value: ${{ steps.define-variables.outputs.ocm_cli_version }}
1316
modulectl_version:
1417
description: The version of modulectl to install. For example, 1.0.0.
1518
value: ${{ steps.define-variables.outputs.modulectl_version }}
19+
template_operator_version:
20+
description: The version of template-operator to checkout. Defaults to value from versions.yaml.
21+
value: ${{ steps.define-variables.outputs.template_operator_version }}
1622
cert_manager_version:
1723
description: The version of cert-manager to deploy. For example, 1.13.3.
1824
value: ${{ steps.define-variables.outputs.cert_manager_version }}
@@ -42,7 +48,9 @@ runs:
4248
run: |
4349
echo "istio_version=$(yq e '.istio' versions.yaml)" >> $GITHUB_OUTPUT
4450
echo "k3d_version=$(yq e '.k3d' versions.yaml)" >> $GITHUB_OUTPUT
51+
echo "ocm_cli_version=$(yq e '.ocm-cli' versions.yaml)" >> $GITHUB_OUTPUT
4552
echo "modulectl_version=$(yq e '.modulectl' versions.yaml)" >> $GITHUB_OUTPUT
53+
echo "template_operator_version=$(yq e '.template-operator' versions.yaml)" >> $GITHUB_OUTPUT
4654
echo "cert_manager_version=$(yq e '.certManager' versions.yaml)" >> $GITHUB_OUTPUT
4755
echo "gardener_cert_manager_version=$(yq e '.gardenerCertManager' versions.yaml)" >> $GITHUB_OUTPUT
4856
echo "golangci_lint_version=$(yq e '.golangciLint' versions.yaml)" >> $GITHUB_OUTPUT
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Install ocm-cli
2+
description: Installs the OCM CLI binary (Linux amd64) with checksum verification; requires explicit release version.
3+
inputs:
4+
ocm_cli_version:
5+
description: Explicit release tag (e.g. v0.32.0). No 'latest'.
6+
required: true
7+
install_path:
8+
description: Directory to place the binary
9+
required: false
10+
default: $(pwd)/ocm/bin
11+
verify_checksum:
12+
description: "'true' to verify checksum (sha256)"
13+
required: false
14+
default: 'true'
15+
runs:
16+
using: composite
17+
steps:
18+
- name: Validate version input
19+
id: validate
20+
shell: bash
21+
run: |
22+
set -euo pipefail
23+
VERSION=${{ inputs.ocm_cli_version }}
24+
if [ -z "${VERSION}" ]; then
25+
echo "Version input empty; aborting." >&2
26+
exit 1
27+
fi
28+
if [ "${VERSION}" = "latest" ] || [ "${VERSION}" = "main" ]; then
29+
echo "Dynamic versions ('latest'/'main') are not allowed; provide an explicit tag like v0.32.0." >&2
30+
exit 1
31+
fi
32+
if ! echo "${VERSION}" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
33+
echo "Version '${VERSION}' does not match required pattern MAJOR.MINOR.PATCH." >&2
34+
exit 1
35+
fi
36+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
37+
- name: Download ocm-cli (Linux amd64)
38+
shell: bash
39+
run: |
40+
set -euo pipefail
41+
VERSION=${{ steps.validate.outputs.version }}
42+
VERSION_NO_V="${VERSION#v}"
43+
INSTALL_PATH=${{ inputs.install_path }}
44+
mkdir -p "${INSTALL_PATH}"
45+
46+
ARCHIVE="ocm-${VERSION_NO_V}-linux-amd64.tar.gz"
47+
BINARY_URL="https://github.com/open-component-model/ocm/releases/download/v${VERSION}/${ARCHIVE}"
48+
SHA_URL="${BINARY_URL}.sha256"
49+
50+
echo "Downloading ${ARCHIVE}"
51+
curl -sSfL "${BINARY_URL}" -o "/tmp/${ARCHIVE}"
52+
53+
if [ "${{ inputs.verify_checksum }}" = "true" ]; then
54+
echo "Verifying checksum"
55+
curl -sSfL "${SHA_URL}" -o "/tmp/${ARCHIVE}.sha256"
56+
EXPECTED_SHA="$(cat /tmp/${ARCHIVE}.sha256 | tr -d '\n\r')"
57+
echo "${EXPECTED_SHA} /tmp/${ARCHIVE}" | sha256sum -c -
58+
else
59+
echo "Checksum verification skipped"
60+
fi
61+
62+
tar -xzf "/tmp/${ARCHIVE}" -C "${INSTALL_PATH}"
63+
if [ ! -x "${INSTALL_PATH}/ocm" ]; then
64+
echo "ocm binary not found after extraction" >&2
65+
exit 1
66+
fi
67+
echo "${INSTALL_PATH}" >> "$GITHUB_PATH"
68+
- name: Test ocm installation
69+
shell: bash
70+
run: |
71+
set -euo pipefail
72+
INSTALLED_VERSION="$(ocm version | yq -p json -oy '.GitVersion')"
73+
echo "OCM CLI version: ${INSTALLED_VERSION}"
74+
ocm help >/dev/null

.github/actions/setup-tools/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ inputs:
1010
k3d_version:
1111
description: The version of k3d to install. For example, 5.6.0.
1212
required: true
13+
ocm_cli_version:
14+
description: The version of ocm-cli to install. For example, 0.32.0.
1315
modulectl_version:
1416
description: The version of modulectl to install. For example, 1.0.0.
1517
required: true
@@ -28,6 +30,9 @@ runs:
2830
- uses: ./lifecycle-manager/.github/actions/install-istioctl
2931
with:
3032
istio_version: ${{ inputs.istio_version }}
33+
- uses: ./lifecycle-manager/.github/actions/install-ocm-cli
34+
with:
35+
ocm_cli_version: ${{ inputs.ocm_cli_version }}
3136
- uses: ./lifecycle-manager/.github/actions/install-modulectl
3237
with:
3338
modulectl_version: ${{ inputs.modulectl_version }}

0 commit comments

Comments
 (0)