Test OLM Bundles

Pre-requisites

Versions listed are the ones known to work, lower versions may work but were not tested

  • task-3.17.0 (asdf)
  • operator-sdk-1.32.0 (asdf)
  • kubectl-1.25.3 (asdf)
  • helm-3.10.1 (asdf)
  • kustomize-4.5.7 (asdf)
  • yq-4.29.2 (asdf)
  • opm-1.26.2 (is auto-downloaded by script, or can be installed via asdf using asdf-opm plugin)
  • kind-0.17.0 (asdf)
  • docker (could be replaced by podman via DOCKER="podman")
  • podman (some of the OperatorSDK toolchain use podman)
  • k9s-0.26.7 (asdf OPTIONAL)

Set up environment

Set up Podman

podman login registry.gitlab.com

Set up Docker

If you’re not using podman for all tasks, authorize Docker to access registry.gitlab.com:

docker login registry.gitlab.com

Set up Git

Ensure user.name and user.email are configured in Git.

Set up environment

variable namerequireddefaultdescription
OPERATOR_VERSIONyes Version of Operator to upgrade to
PREVIOUS_OPERATOR_VERSIONyes Version of Operator to upgrade from
LOCAL_IPyes127.0.0.1Local machine IP, needed for GITLAB_OPERATOR_DOMAIN. When GITLAB_OPERATOR_DOMAIN is provided - LOCAL_IP can be omitted
GITLAB_OPERATOR_OLM_REGISTRYyesregistry.gitlab.com/gitlab-org/cloud-native/gitlab-operator/bundleOLM Bundles and Catalogs Registry with released bundles and catalogs
BUNDLE_REGISTRYyes Staging container registry to publish intermediary OLM Bundles and Catalogs to
OLM_TESTING_ENVIRONMENTno./test_olm.envFile containing environment variables necessary for test runs
OPERATOR_TAGno$OPERATOR_VERSIONOperator Container tag to test
OLM_BUNDLE_SHnoscripts/olm_bundle.shPath to underlying olm_bundle.sh script
PROVISION_AND_DEPLOY_SHnoscripts/provision_and_deploy.shPath to underlying provision_and_deploy.sh script
YQnoyqPath to yq utility
OPM_VERSIONno1.26.2 opm version to automatically fetch if no binary specified in OPM
OPMno.build/opmPath to opm binary. Auto-fetched if empty (using OPM_VERSION )
OSDK_BASE_DIRno.build/operatorhub-ioDirectory for intermediate OLM Bundling artifacts storage
OLM_PACKAGE_VERSIONno$OPERATOR_TAGVersion to apply to OLM package
KUBERNETES_TIMEOUTno120sTimeout for Kubernetes operations
DO_NOT_PUBLISHno""Controls whether to compile and publish current bundle/catalog (to a temporary registry) or use already published ones from public registry
BUNDLE_VERSIONno$OPERATOR_VERSIONVersion of the bundle to upgrade to
PREVIOUS_BUNDLE_VERSIONno$PREVIOUS_OPERATOR_VERSIONVersion of the bundle to upgrade from
PREVIOUS_CHART_VERSIONnoautogeneratedChart version to upgrade from
GITLAB_OPERATOR_DOMAINno${LOCAL_IP}.nip.ioDomain to deploy test GitLab instance to
GITLAB_OPERATOR_DIRno.Directory with GitLab Operator repository
GITLAB_CHART_VERSIONnofirst line in ${GITLAB_OPERATOR_DIR}/CHART_VERSIONS} Chart Version to upgrade to
GITLAB_CHART_REPOnohttps://gitlab.com/gitlab-org/charts/gitlabGitLab Helm Chart repository HTTP URI. Mainly used to fetch default KinD configs.
K8S_VERSIONno1.25.9K8s version to use for cluster setup
KIND_CONFIGno examples/kind/kind-ssl.yaml from GitLab Chart’s default branchKinD configuration file to prepare KinD cluster for GitLab deployment

For additional variables look at Provision and deploy and OperatorHub publishing

Create test_olm.env in Operator’s root dir (or point to a file in a custom location using ${OLM_TESTING_ENVIRONMENT} environment variable)

Make sure to confirm every following customization line reflects your personal setup:

export OPERATOR_VERSION="0.10.2"
export BUNDLE_REGISTRY="registry.gitlab.com/dmakovey/gitlab-operator-bundle"

export PREVIOUS_OPERATOR_VERSION="0.9.1"
export LOCAL_IP="192.168.3.194"
export DO_NOT_PUBLISH="yes" # do not re-compile and publish bundle/catalog
                            # use the ones already published

Prepare KinD Cluster (Optional)

To run tests in KinD cluster with OLM set up:

scripts/test_olm.sh setup_kind_cluster

Otherwise current kubectl context should point to an existing cluster that has OLM pre-installed

Running tests

  1. Setup KinD cluster and deploy Operator there:

    scripts/test_olm.sh upgrade_test_step1
    

    Operator Pod should be up and running. Confirm by running:

    kubectl get pod -n gitlab-system -l control-plane=controller-manager
    
  2. Deploy “old” version of GitLab via Operator:

    scripts/test_olm.sh upgrade_test_step2
    

    Confirm GitLab has been deployed:

    kubectl get -n gitlab-system gitlab
    
  3. Upgrade the Operator:

    scripts/test_olm.sh upgrade_test_step3
    

    Confirm that Operator has been upgraded.

    Wait for the install to roll out before next step

  4. Upgrade GitLab:

    scripts/test_olm.sh upgrade_test_step4
    

    Confirm that GitLab has been upgraded and is functional

    Wait for the upgrade to complete

  5. Confirm GitLab is running:

    scripts/test_olm.sh check_gitlab
    

    above will query Operator for GitLab status, alternatively use

    scripts/test_olm.sh check_gitlab2
    

    which bypasses Operator checks and runs checks against GitLab instance itself.