github.com/argoproj-labs/argocd-operator@v0.10.0/tests/olm/README.md (about) 1 ## OLM Installed Operator 2 3 This folder contains tests which need operator installed via OLM 4 5 #### Steps for local testing via OLM 6 7 ##### Setup local k8s cluster 8 9 ```bash 10 # create local image registry 11 k3d registry create registry.localhost --port 12345 12 13 # ensure that below "k3d-registry.localhost" entry is present in your /etc/hosts file for registry domain resolution 14 $ cat /etc/hosts 15 ...... 16 ...... 17 ...... 18 127.0.0.1 k3d-registry.localhost 19 20 # create a new cluster that uses this registry 21 k3d cluster create test --registry-use k3d-registry.localhost:12345 22 ``` 23 24 ##### Build and install the operator 25 26 ```bash 27 # install olm on target cluster 28 operator-sdk olm install 29 30 # env setup 31 export REGISTRY="k3d-registry.localhost:12345" 32 export ORG="local" 33 export CONTROLLER_IMAGE="argocd-operator:test" 34 export BUNDLE_IMAGE="argocd-operator-bundle:test" 35 export VERSION="0.7.0" 36 export CATALOG_IMAGE=argocd-operator-catalog 37 export CATALOG_TAG=v0.7.0 38 39 # build and push operator image 40 make generate 41 make manifests 42 make docker-build IMG="$REGISTRY/$ORG/$CONTROLLER_IMAGE" 43 docker push "$REGISTRY/$ORG/$CONTROLLER_IMAGE" 44 45 # build and push bundle image 46 make bundle IMG="$REGISTRY/$ORG/$CONTROLLER_IMAGE" 47 make bundle-build BUNDLE_IMG="$REGISTRY/$ORG/$BUNDLE_IMAGE" 48 docker push "$REGISTRY/$ORG/$BUNDLE_IMAGE" 49 50 # validate bundle 51 operator-sdk bundle validate "$REGISTRY/$ORG/$BUNDLE_IMAGE" 52 53 # skip catalog and install operator on target cluster via operator-sdk 54 #operator-sdk run bundle "$REGISTRY/$ORG/$BUNDLE_IMAGE" -n operators 55 56 # build and push catalog image 57 make catalog-build CATALOG_IMG="$REGISTRY/$ORG/$CATALOG_IMAGE:$CATALOG_TAG" BUNDLE_IMGS="$REGISTRY/$ORG/$BUNDLE_IMAGE" 58 docker push "$REGISTRY/$ORG/$CATALOG_IMAGE:$CATALOG_TAG" 59 60 # install catalog 61 sed "s/image:.*/image: $REGISTRY\/$ORG\/$CATALOG_IMAGE:$CATALOG_TAG/" deploy/catalog_source.yaml | kubectl apply -n operators -f - 62 63 # create subscription 64 sed "s/sourceNamespace:.*/sourceNamespace: operators/" deploy/subscription.yaml | kubectl apply -n operators -f - 65 ``` 66 67 ##### Run tests 68 69 ```bash 70 # wait till argocd-operator-controller-manager pod is in running state 71 kubectl -n operators get all 72 73 kubectl kuttl test ./tests/olm --config ./tests/kuttl-tests.yaml 74 ``` 75 76 ##### Cleanup 77 78 ```bash 79 operator-sdk cleanup argocd-operator -n operators 80 kubectl delete clusterserviceversion/argocd-operator.v0.7.0 -n operators 81 make uninstall 82 83 k3d cluster delete test 84 k3d registry delete registry.localhost 85 ```