[CI] Do not delete CRD upon review environment cleanup

Summary

Skips deletion of the CRD during the cleanup jobs only when in CI.

Why: the CRD is a cluster-scoped resource, and at the moment is not name-prefixed like the other cluster-scoped resources (due to complications of having multiple CRDs of the same kind in the same cluster).

Instead, we can simply skip deletion. Changes to the CRD are still tested because any changes will take effect during the review jobs, which will kubectl apply the CRD.

In a future iteration, we'll look into better isolating CRD updates using the resource version.

Closes #597 (closed)

Testing

In CI

https://gitlab.com/gitlab-org/cloud-native/gitlab-operator/-/jobs/2213290170

Confirmed that CRD is not deleted by checking through logs.

Manually

# Add YQ plugin
asdf plugin add yq

# Install YQ version matching what's used in CI
# https://gitlab.com/gitlab-org/gitlab-build-images/blob/d2d1b8834eff691331df1be6e7e8a8c200060425/Dockerfile.gitlab-operator-build-base#L54
asdf install yq 4.7.0

# Confirm YQ version
yq --version

# Collect manifest artifact from recent `review` job
# https://gitlab.com/gitlab-org/cloud-native/gitlab-operator/-/jobs/2211502965/artifacts/file/.install/glop-82c91ac8-master.gitlab-operator.k8s-ft.win.yaml
wget https://gitlab.com/gitlab-org/cloud-native/gitlab-operator/-/jobs/2211502965/artifacts/raw/.install/glop-82c91ac8-master.gitlab-operator.k8s-ft.win.yaml

# Test updated command, confirming output is the same but without the CRD listed
yq eval 'select(documentIndex != 0)' glop-82c91ac8-master.gitlab-operator.k8s-ft.win.yaml

# Create KinD cluster
kind create cluster

# Install manifests
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.7.1/cert-manager.yaml
kubectl apply -f glop-82c91ac8-master.gitlab-operator.k8s-ft.win.yaml

# Confirm CRD exists
kubectl get crd gitlabs.apps.gitlab.com

# Delete manifests (except CRD)
yq eval 'select(documentIndex != 0)' glop-82c91ac8-master.gitlab-operator.k8s-ft.win.yaml | kubectl delete -f -

# Confirm CRD still exists
kubectl get crd gitlabs.apps.gitlab.com

Closes #597 (closed)

Edited by Mitchell Nielsen

Merge request reports

Loading