Development on this operator can be performed in the odo
OpenShift developer CLI or building with OpenShift build configs.
CodeReady Containers is recommended for local development.
An Ansible test suite is available for functional testing.
Use of odo
is recommended for fast iterative development.
odo
simplifies the build/deploy process and avoids creating unnecessary build artifacts during the development process.
-
Install the
odo
developer CLI as described in the OpenShift documentation: Installing odo -
Create resources required for development from helm chart:
helm template helm/ \ --include-crds \ --set deploy=false \ | oc apply -f -
-
Change project namespace to
bitwarden-k8s-secrets-manager
:oc project bitwarden-k8s-secrets-manager
-
Grant privileges for cluster role
bitwarden-k8s-secrets-manager
to default service account:oc adm policy add-cluster-role-to-user bitwarden-k8s-secrets-manager -z default
-
Setup
odo
from the provideddevfile.yaml
:odo create --devfile devfile.yaml
NoteThe poolboy operator domain is specified in the devfile. If you are developing with a different operator domain then you will need to update the devfile.yaml
. -
Use
odo push
to push code into the odo container:odo push
-
Run tests
ansible-playbook test/playbook.yaml
-
Cleanup
Remove
odo
component:odo delete --force bitwarden-k8s-secrets-manager
Delete resources created from helm template:
helm template helm/ \ --set deploy=false \ --set namespace.name=user-namespace-operator-dev \ | oc delete -f -
The OpenShift build process is a bit slower for development but has the advantage of being a bit closer to a normal deployment of poolboy.
It is often best to iterate development using odo
and also test with an OpenShift build and deployment prior to opening a pull request.
-
Create a project for development using
oc
:oc new-project bitwarden-k8s-secrets-manager
-
Process OpenShift build template to create BuildConfig and ImageStream:
oc process --local -f build-template.yaml | oc apply -f -
-
Build user-namespace-operator image from local source:
oc start-build bitwarden-k8s-secrets-manager --from-dir=. --follow
-
Deploy user-namespace-operator from build image:
helm template helm \ --set namespace.create=false \ --set namespace.name=bitwarden-k8s-secrets-manager \ --set=image.tagOverride=- \ --set=image.repository=$(oc get imagestream bitwarden-k8s-secrets-manager -o jsonpath='{.status.tags[?(@.tag=="latest")].items[0].dockerImageReference}') \ | oc apply -f -
-
Run tests:
ansible-playbook test/playbook.yaml
-
Cleanup
Remove resources created from the helm template:
helm template helm \ --set namespace.create=false \ --set namespace.name=bitwarden-k8s-secrets-manager \ | oc delete -f -
Remove BuildConfig and ImageStream:
oc process --local -f build-template.yaml | oc delete -f -