Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 192 additions & 0 deletions .github/workflows/olm-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
name: OLM E2E

on:
pull_request:
workflow_dispatch:

jobs:
olm-e2e:
name: OLM bundle, catalog, deploy, scorecard
runs-on: ubuntu-latest
env:
REGISTRY: localhost:5001
NAMESPACE: cass-operator
CHANNELS: dev
DEFAULT_CHANNEL: dev
steps:
- name: Free diskspace by removing unused packages
shell: bash
run: |
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: false
- name: Install yq
run: |
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
# The runners already have the latest versions of tools, no need to reinstall them
- name: Link tools
shell: bash
run: |
mkdir bin
ln -s /usr/local/bin/kustomize bin/kustomize
- name: Create kind cluster
shell: bash
run: |
hack/cluster.sh
- name: Build and push operator images to local registry
run: |
make REGISTRY=${{ env.REGISTRY }} ORG=localhost:5001/k8ssandra docker-build docker-logger-build docker-push docker-logger-push
- name: Generate OLM bundle
run: |
make REGISTRY=${{ env.REGISTRY }} ORG=localhost:5001/k8ssandra bundle
bin/operator-sdk bundle validate ./bundle --select-optional suite=operatorframework
- name: Build and push bundle image to local registry
run: |
make ORG=localhost:5001/k8ssandra bundle-build bundle-push
- name: Build and push catalog (index) image to local registry
run: |
make ORG=localhost:5001/k8ssandra catalog-build catalog-push
- name: Install OLM
run: |
bin/operator-sdk olm install --timeout 5m
kubectl get pods -n olm
- name: Run OLM deployment from bundle image
run: |
BUNDLE_IMG=${{ env.REGISTRY }}/k8ssandra/cass-operator-bundle:v$(make version)
kubectl create ns ${{ env.NAMESPACE }} || true
bin/operator-sdk run bundle $BUNDLE_IMG --namespace ${{ env.NAMESPACE }} --timeout 10m --use-http --verbose
# Wait for CSV to succeed
kubectl -n ${{ env.NAMESPACE }} wait --for=jsonpath='{.status.phase}'=Succeeded csv --all --timeout=300s
kubectl -n ${{ env.NAMESPACE }} get csv
kubectl -n ${{ env.NAMESPACE }} get deploy,po
- name: Run scorecard (olm suite)
run: |
bin/operator-sdk scorecard ./bundle --selector=suite=olm --verbose
- name: Red Hat static checks (bundle)
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install operator static tests
run: |
python -m pip install --upgrade pip
python -m pip install git+https://github.com/redhat-openshift-ecosystem/operator-pipelines.git

- name: Prepare bundle for static checks
id: prep_static
run: |
OP_NAME=$(yq -r '."operators.operatorframework.io.bundle.package.v1"' bundle/metadata/annotations.yaml)
CSV_VERSION=$(yq -r '.spec.version' bundle/manifests/*.clusterserviceversion.yaml)
echo "op_name=${OP_NAME}" >> $GITHUB_OUTPUT
echo "csv_version=${CSV_VERSION}" >> $GITHUB_OUTPUT
mkdir -p /tmp/community-operators-prod/operators/${OP_NAME}/${CSV_VERSION}
cp -r bundle/manifests /tmp/community-operators-prod/operators/${OP_NAME}/${CSV_VERSION}/
cp -r bundle/metadata /tmp/community-operators-prod/operators/${OP_NAME}/${CSV_VERSION}/
echo "Prepared repo structure at /tmp/community-operators-prod"

- name: Run static checks
run: |
static-tests \
--repo-path /tmp/community-operators-prod \
--suites operatorcert.static_tests.community \
--output-file /tmp/operator-static.json \
--verbose \
${{ steps.prep_static.outputs.op_name }} ${{ steps.prep_static.outputs.csv_version }}
echo "Static checks output:"
cat /tmp/operator-static.json || true

- name: Cleanup bundle install (pre-catalog)
if: always()
run: |
set +e
# Remove the operator deployed via run bundle
bin/operator-sdk cleanup cass-operator --namespace ${{ env.NAMESPACE }} || true
# Ensure namespace is clean for catalog stage
kubectl delete csv --all -n ${{ env.NAMESPACE }} || true
kubectl delete deploy --all -n ${{ env.NAMESPACE }} || true
kubectl delete po --all -n ${{ env.NAMESPACE }} || true

- name: Create CatalogSource for local catalog
run: |
cat <<EOF | kubectl apply -f -
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: cass-operator-local
namespace: olm
spec:
displayName: Cass Operator Local
publisher: k8ssandra
sourceType: grpc
image: ${{ steps.vars.outputs.catalog_img }}
updateStrategy:
registryPoll:
interval: 1m
EOF
kubectl -n olm rollout status deploy/catalog-operator --timeout=120s || true
# Wait for the CatalogSource to be ready
kubectl -n olm wait --for=condition=READY catalogsource/cass-operator-local --timeout=120s || true

- name: Create OperatorGroup and Subscription
run: |
# OperatorGroup in target namespace
cat <<EOF | kubectl apply -f -
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: cass-operator-og
namespace: ${{ env.NAMESPACE }}
spec:
targetNamespaces:
- ${{ env.NAMESPACE }}
EOF

# Subscription referencing local CatalogSource and dev channel
cat <<EOF | kubectl apply -f -
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: cass-operator
namespace: ${{ env.NAMESPACE }}
spec:
channel: dev
name: cass-operator-community
source: cass-operator-local
sourceNamespace: olm
installPlanApproval: Automatic
EOF

- name: Wait for catalog-based install to succeed
run: |
# Wait for a CSV to appear in the namespace
end=$((SECONDS+600))
while [ $SECONDS -lt $end ]; do
CSV=$(kubectl -n ${{ env.NAMESPACE }} get csv -o jsonpath='{.items[0].metadata.name}' || true)
if [ -n "$CSV" ]; then
echo "Found CSV: $CSV"; break;
fi
echo "Waiting for CSV to appear..."; sleep 5;
done
kubectl -n ${{ env.NAMESPACE }} wait --for=jsonpath='{.status.phase}'=Succeeded csv --all --timeout=600s
kubectl -n ${{ env.NAMESPACE }} get csv
kubectl -n ${{ env.NAMESPACE }} get deploy,po

- name: Cleanup catalog and OLM
if: always()
run: |
set +e
# Delete Subscription and CSVs from the namespace
kubectl -n ${{ env.NAMESPACE }} delete subscription cass-operator --ignore-not-found
kubectl -n ${{ env.NAMESPACE }} delete csv --all --ignore-not-found
kubectl -n ${{ env.NAMESPACE }} delete operatorgroup cass-operator-og --ignore-not-found
kubectl -n olm delete catalogsource cass-operator-local --ignore-not-found
kubectl delete ns ${{ env.NAMESPACE }} --ignore-not-found
bin/operator-sdk olm uninstall || true
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ OPM ?= $(LOCALBIN)/opm
CERT_MANAGER_VERSION ?= v1.18.1
KUSTOMIZE_VERSION ?= v5.6.0
CONTROLLER_TOOLS_VERSION ?= v0.18.0
OPERATOR_SDK_VERSION ?= 1.40.0
OPERATOR_SDK_VERSION ?= 1.41.1
HELM_VERSION ?= 3.18.3
OPM_VERSION ?= 1.55.0
GOLANGCI_LINT_VERSION ?= v2.4.0
Expand Down Expand Up @@ -366,7 +366,7 @@ endif
bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files.
$(OPERATOR_SDK) generate kustomize manifests --interactive=false -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build --load-restrictor LoadRestrictionsNone config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(BUNDLE_GEN_FLAGS)
$(KUSTOMIZE) build --load-restrictor LoadRestrictionsNone config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
scripts/postprocess-bundle.sh $(REGISTRY)
$(OPERATOR_SDK) bundle validate ./bundle --select-optional suite=operatorframework

Expand Down
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion config/scorecard/patches/basic.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
entrypoint:
- scorecard-test
- basic-check-spec
image: quay.io/operator-framework/scorecard-test:v1.34.0
image: quay.io/operator-framework/scorecard-test:v1.41.0
labels:
suite: basic
test: basic-check-spec-test
10 changes: 5 additions & 5 deletions config/scorecard/patches/olm.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
entrypoint:
- scorecard-test
- olm-bundle-validation
image: quay.io/operator-framework/scorecard-test:v1.34.0
image: quay.io/operator-framework/scorecard-test:v1.41.0
labels:
suite: olm
test: olm-bundle-validation-test
Expand All @@ -14,7 +14,7 @@
entrypoint:
- scorecard-test
- olm-crds-have-validation
image: quay.io/operator-framework/scorecard-test:v1.34.0
image: quay.io/operator-framework/scorecard-test:v1.41.0
labels:
suite: olm
test: olm-crds-have-validation-test
Expand All @@ -24,7 +24,7 @@
entrypoint:
- scorecard-test
- olm-crds-have-resources
image: quay.io/operator-framework/scorecard-test:v1.34.0
image: quay.io/operator-framework/scorecard-test:v1.41.0
labels:
suite: olm
test: olm-crds-have-resources-test
Expand All @@ -34,7 +34,7 @@
entrypoint:
- scorecard-test
- olm-spec-descriptors
image: quay.io/operator-framework/scorecard-test:v1.34.0
image: quay.io/operator-framework/scorecard-test:v1.41.0
labels:
suite: olm
test: olm-spec-descriptors-test
Expand All @@ -44,7 +44,7 @@
entrypoint:
- scorecard-test
- olm-status-descriptors
image: quay.io/operator-framework/scorecard-test:v1.34.0
image: quay.io/operator-framework/scorecard-test:v1.41.0
labels:
suite: olm
test: olm-status-descriptors-test
Loading