Helm Operator for DirectPV - cniackz/public GitHub Wiki

Objective:

To document how to get Helm Operator working to install DirectPV in any given cluster.

Documentation:

Steps:

  1. Start by having a fresh new cluster of k8s or OpenShift:
  1. Create a new project:
rm -rf ~/directpv-operator
mkdir ~/directpv-operator
cd ~/directpv-operator
operator-sdk init --plugins helm --domain quay.io --helm-chart /Users/cniackz/minio/directpv-workdir/directpv-chart
  1. Edit below values in generated Makefile
  • Version should point to our latest version:
VERSION ?= 4.0.6
  • Image base to some registry that you have access to:
IMAGE_TAG_BASE ?= quay.io/cniackz4/directpv-operator
  • And use that for the image:
IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
  • Finally if you are on Mac M1 or M2 Chip, use buildx accordingly:
.PHONY: docker-build
docker-build: ## Build docker image with the manager.
	docker buildx build --platform linux/amd64 -t ${IMG} .
  1. Then, change the RBAC permissions to allow Operator control the different resources:
  1. Then, Build docker image:
make docker-build docker-push
  1. Install OLM
operator-sdk olm install
  1. Build operator bundle docker image
make bundle bundle-build bundle-push

Expected:

$ make bundle bundle-build bundle-push
operator-sdk generate kustomize manifests -q

Display name for the operator (required): 
> directpv

Description for the operator (required): 
> directpv

Provider's name for the operator (required): 
> directpv

Any relevant URL for the provider name (optional): 
> 

Comma-separated list of keywords for your operator (required): 
> directpv

Comma-separated list of maintainers and their emails (e.g. 'name1:email1, name2:email2') (required): 
> celis:[email protected]            
cd config/manager && /opt/homebrew/bin/kustomize edit set image controller=quay.io/cniackz4/directpv-operator:4.0.6
/opt/homebrew/bin/kustomize build config/manifests | operator-sdk generate bundle -q --overwrite --version 4.0.6  
INFO[0000] Creating bundle.Dockerfile                   
INFO[0000] Creating bundle/metadata/annotations.yaml    
INFO[0000] Bundle metadata generated successfully       
operator-sdk bundle validate ./bundle
INFO[0000] All validation tests have completed successfully 
docker build -f bundle.Dockerfile -t quay.io/cniackz4/directpv-operator-bundle:v4.0.6 .
[+] Building 0.1s (7/7) FINISHED                                                                                              docker:desktop-linux
 => [internal] load build definition from bundle.Dockerfile                                                                                   0.0s
 => => transferring dockerfile: 976B                                                                                                          0.0s
 => [internal] load .dockerignore                                                                                                             0.0s
 => => transferring context: 2B                                                                                                               0.0s
 => [internal] load build context                                                                                                             0.0s
 => => transferring context: 15.01kB                                                                                                          0.0s
 => [1/3] COPY bundle/manifests /manifests/                                                                                                   0.0s
 => [2/3] COPY bundle/metadata /metadata/                                                                                                     0.0s
 => [3/3] COPY bundle/tests/scorecard /tests/scorecard/                                                                                       0.0s
 => exporting to image                                                                                                                        0.0s
 => => exporting layers                                                                                                                       0.0s
 => => writing image sha256:b4f2d5e46b98c021dead7e1c83b782dfe9a2ef66ec9359351d33e0d42ccf0da4                                                  0.0s
 => => naming to quay.io/cniackz4/directpv-operator-bundle:v4.0.6                                                                             0.0s

What's Next?
  View summary of image vulnerabilities and recommendations → docker scout quickview
/Applications/Xcode.app/Contents/Developer/usr/bin/make docker-push IMG=quay.io/cniackz4/directpv-operator-bundle:v4.0.6
docker push quay.io/cniackz4/directpv-operator-bundle:v4.0.6
The push refers to repository [quay.io/cniackz4/directpv-operator-bundle]
64c54d94d931: Pushed 
6efcbf55ff0b: Pushed 
918fa96d7eea: Pushed 
v4.0.6: digest: sha256:7b10cca08c61de43dce0ff858f0f78975227146d5d599c839a68d85e87bf7ecd size: 939
  1. Run bundle on your openshift
  • This will install the operator
operator-sdk run bundle quay.io/cniackz4/directpv-operator-bundle:v4.0.6

Expected:

$ operator-sdk run bundle quay.io/cniackz4/directpv-operator-bundle:v4.0.6
INFO[0016] Creating a File-Based Catalog of the bundle "quay.io/cniackz4/directpv-operator-bundle:v4.0.6" 
INFO[0017] Generated a valid File-Based Catalog         
INFO[0022] Created registry pod: quay-io-cniackz4-directpv-operator-bundle-v4-0-6 
INFO[0022] Created CatalogSource: directpv-operator-catalog 
INFO[0022] OperatorGroup "operator-sdk-og" created      
INFO[0022] Created Subscription: directpv-operator-v4-0-6-sub 
INFO[0037] Approved InstallPlan install-zfj8b for the Subscription: directpv-operator-v4-0-6-sub 
INFO[0037] Waiting for ClusterServiceVersion "default/directpv-operator.v4.0.6" to reach 'Succeeded' phase 
INFO[0037]   Waiting for ClusterServiceVersion "default/directpv-operator.v4.0.6" to appear 
INFO[0039]   Found ClusterServiceVersion "default/directpv-operator.v4.0.6" phase: Pending 
INFO[0042]   Found ClusterServiceVersion "default/directpv-operator.v4.0.6" phase: InstallReady 
INFO[0043]   Found ClusterServiceVersion "default/directpv-operator.v4.0.6" phase: Installing 
INFO[0063]   Found ClusterServiceVersion "default/directpv-operator.v4.0.6" phase: Succeeded 
INFO[0063] OLM has successfully installed "directpv-operator.v4.0.6"
  1. Run your directpv:
kubectl apply -f my-directpv.yaml

Expected:

Screenshot 2023-08-03 at 3 07 14 PM