Helm Operator for Private DirectPV for RedHat Certification2 - cniackz/public GitHub Wiki
Objective:
To document how to get DirectPV Helm Operator working to install Private DirectPV in any given cluster. This is for RedHat Certification process
Documentation:
Steps:
- Start by having a fresh new cluster of k8s or OpenShift:
createcluster
-
NOTE: Beware
Colima
does not support olm install as is single node cluster:
INFO[0040] Waiting for Deployment "olm/packageserver" to rollout: 1 of 2 updated replicas are available
FATA[0120] Failed to install OLM version "latest": deployment/packageserver failed to rollout: context deadline exceeded
Kind
in the other hand does support it:INFO[0059] Successfully installed OLM version "latest"
- Use your repo: https://github.com/cniackz/Private-DPV-Operator2
- Jumpt to Step 4, project is already created
rm -rf /Users/cniackz/Private-DPV-Operator2
cd ~
git clone [email protected]:cniackz/Private-DPV-Operator2.git
- Get chart:
cd
rm -rf directpv
git clone [email protected]:miniohq/directpv.git
cd /Users/cniackz/directpv/helm
### En este punto obten una licensia temporal e inyectala a la helm chart
helm package aistor-volumemanager
Expected:
$ helm package aistor-volumemanager
Successfully packaged chart and saved it to: /Users/cniackz/directpv/helm/aistor-volumemanager-0.2.0.tgz
cd /Users/cniackz/Private-DPV-Operator2
operator-sdk init \
--plugins helm \
--domain quay.io \
--helm-chart /Users/cniackz/directpv/helm/aistor-volumemanager-0.2.0.tgz
- Edit below values in generated
Makefile
-
File location:
/Users/cniackz/Private-DPV-Operator/Makefile
-
Version should point to our latest version:
VERSION ?= 5.0.0
- 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} .
- Then, change the RBAC
cd /Users/cniackz/Private-DPV-Operator2
k apply -f rbac.yaml
- File location:
/Users/cniackz/Private-DPV-Operator2/rbac.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: private-dpv-operator2-cluster-admin
rules:
- apiGroups: ["*"]
resources: ["*"]
verbs: ["*"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: private-dpv-operator2-cluster-admin-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: private-dpv-operator2-cluster-admin
subjects:
- kind: ServiceAccount
name: private-dpv-operator2-controller-manager
namespace: default
- Then, Build docker image:
cd /Users/cniackz/Private-DPV-Operator2
make docker-build docker-push
- Install OLM
operator-sdk olm install
- Build operator bundle docker image
make bundle bundle-build bundle-push
Expected:
Cesars-MacBook-Pro:Private-DPV-Operator cniackz$ make bundle bundle-build bundle-push
/usr/local/bin/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:5.0.0
/opt/homebrew/bin/kustomize build config/manifests | /usr/local/bin/operator-sdk generate bundle -q --overwrite --version 5.0.0
WARN[0000] ClusterServiceVersion validation: [CSVFileNotValid] (private-dpv-operator.v5.0.0) csv.Spec.minKubeVersion is not informed. It is recommended you provide this information. Otherwise, it would mean that your operator project can be distributed and installed in any cluster version available, which is not necessarily the case for all projects.
INFO[0000] Creating bundle.Dockerfile
INFO[0000] Creating bundle/metadata/annotations.yaml
INFO[0000] Bundle metadata generated successfully
/usr/local/bin/operator-sdk bundle validate ./bundle
WARN[0000] Warning: Value : (private-dpv-operator.v5.0.0) csv.Spec.minKubeVersion is not informed. It is recommended you provide this information. Otherwise, it would mean that your operator project can be distributed and installed in any cluster version available, which is not necessarily the case for all projects.
INFO[0000] All validation tests have completed successfully
docker build -f bundle.Dockerfile -t quay.io/cniackz4/directpv-operator:5.0.0 .
[+] Building 0.2s (7/7) FINISHED docker:desktop-linux
=> [internal] load build definition from bundle.Dockerfile 0.0s
=> => transferring dockerfile: 979B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 12.18kB 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.1s
=> => exporting layers 0.0s
=> => writing image sha256:793bc2b69078a64251f8960c11c9a67206a372514011131c48acc60e65abe384 0.0s
=> => naming to quay.io/cniackz4/directpv-operator:5.0.0 0.0s
What's next:
View a summary of image vulnerabilities and recommendations → docker scout quickview
/Library/Developer/CommandLineTools/usr/bin/make docker-push IMG=quay.io/cniackz4/directpv-operator:5.0.0
docker push quay.io/cniackz4/directpv-operator:5.0.0
The push refers to repository [quay.io/cniackz4/directpv-operator]
c4c32b9244e8: Pushed
03a0d320c988: Pushed
f35d71e92d2c: Pushed
5.0.0: digest: sha256:b98f88a25a9fb6f416cb7a8d04e6c5400edca991afe2d721276ce51bbf2b6eaf size: 939
- Run bundle on your cluster:
- This will install the operator
operator-sdk run bundle quay.io/cniackz4/directpv-operator-bundle:v5.0.0
Expected:
$ operator-sdk run bundle quay.io/cniackz4/directpv-operator-bundle:v5.0.0
INFO[0018] Creating a File-Based Catalog of the bundle "quay.io/cniackz4/directpv-operator-bundle:v5.0.0"
INFO[0019] Generated a valid File-Based Catalog
INFO[0026] Created registry pod: quay-io-cniackz4-directpv-operator-bundle-v5-0-0
INFO[0026] Created CatalogSource: private-dpv-operator-catalog
INFO[0026] OperatorGroup "operator-sdk-og" created
INFO[0026] Created Subscription: private-dpv-operator-v5-0-0-sub
INFO[0042] Approved InstallPlan install-j4w7h for the Subscription: private-dpv-operator-v5-0-0-sub
INFO[0042] Waiting for ClusterServiceVersion "default/private-dpv-operator.v5.0.0" to reach 'Succeeded' phase
INFO[0043] Waiting for ClusterServiceVersion "default/private-dpv-operator.v5.0.0" to appear
INFO[0044] Found ClusterServiceVersion "default/private-dpv-operator.v5.0.0" phase: Pending
INFO[0045] Found ClusterServiceVersion "default/private-dpv-operator.v5.0.0" phase: InstallReady
INFO[0046] Found ClusterServiceVersion "default/private-dpv-operator.v5.0.0" phase: Installing
INFO[0066] Found ClusterServiceVersion "default/private-dpv-operator.v5.0.0" phase: Succeeded
INFO[0066] OLM has successfully installed "private-dpv-operator.v5.0.0"
- Run your directpv:
-
This will create the Custom Resource that will start the installation of DirectPV
-
File location:
/Users/cniackz/Private-DPV-Operator2/cr.yaml
apiVersion: charts.quay.io/v1alpha1
kind: AistorVolumemanager
metadata:
name: aistorvolumemanager-sample
spec:
# Default values copied from <project_dir>/helm-charts/aistor-volumemanager/values.yaml
annotations: {}
controller:
podAnnotations: {}
podLabels: {}
replicas: 3
images:
pullPolicy: IfNotPresent
pullSecrets: []
labels: {}
license: "eyJhbGciOiJFUzM4NCIsInR5cCI6IkpXVCJ9.eyJhaWQiOjEsImFwaUtleSI6ImNlYzM1YjAzLTRmMDItMTMwYy04MjU2LWE2NTc3MTAyZjA4MSIsImNhcCI6MTA1MCwiZXhwIjoxNzYzMjUxMTk5LCJpYXQiOjEuNzQ3MjU4NjA5NTMxNTYxNDE1ZTksImlzcyI6InN1Ym5ldEBtaW4uaW8iLCJsaWQiOiI4MjJkOTgyZC0zYTM5LTQwMmEtOTkxMC1lOWEyYWE0NjQ0ZmUiLCJvcmciOiJHcmluZ290dHMiLCJwbGFuIjoiRU5URVJQUklTRSIsInN1YiI6InN1Ym5ldEBtaW4uaW8iLCJ0cmlhbCI6ZmFsc2V9.B8iCeVpPXGz8gOEd65Ps4ax5DG-Levq6f5unGMa1INWHkIadi7_YmhojtphpNGrE673GXwMOiaY8WRX78ypvwcBtXtrFqYaKUD-4wtV7DzCpmpbREdlwzSzOtFDDpG-U"
nodeserver:
nodeSelector: {}
podAnnotations: {}
podLabels: {}
tolerations: []
cd /Users/cniackz/Private-DPV-Operator2
kubectl apply -f cr.yaml
Expected: