Development on this operator can be performed in the odo
OpenShift developer CLI or building with OpenShift build configs.
An OpenShift cluster with cluster-admin is required for odo
development.
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
babylon-config
:oc project babylon-config
-
Grant privileges for cluster role
babylon-agnosticv-operator
to default service account:oc adm policy add-cluster-role-to-user babylon-agnosticv-operator -z default oc policy add-role-to-user --role-namespace=babylon-config agnosticv-operator -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 babylon-agnosticv-operator
Delete resources created from helm template:
helm template helm/ \ --set deploy=false \ | 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 babylon-config
-
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 babylon-agnosticv-operator --from-dir=.. --follow
-
Deploy user-namespace-operator from build image:
helm template helm \ --set namespace.create=false \ --set=image.tagOverride=- \ --set=image.repository=$(oc get imagestream babylon-agnosticv-operator -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 \ | oc delete -f -
Remove BuildConfig and ImageStream:
oc process --local -f build-template.yaml | oc delete -f -