Skip to content

Latest commit

 

History

History
128 lines (109 loc) · 4.38 KB

Development.adoc

File metadata and controls

128 lines (109 loc) · 4.38 KB

Development

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.

Development with odo

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.

  1. Install the odo developer CLI as described in the OpenShift documentation: Installing odo

  2. Create resources required for development from helm chart:

    helm template helm/ \
    --include-crds \
    --set deploy=false \
    | oc apply -f -
  3. Change project namespace to babylon-config:

    oc project babylon-config
  4. 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
  5. Setup odo from the provided devfile.yaml:

    odo create --devfile devfile.yaml
    Note
    The 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.
  6. Use odo push to push code into the odo container:

    odo push
  7. Run tests

    ansible-playbook test/playbook.yaml
  8. 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 -

Development OpenShift Build

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.

  1. Create a project for development using oc:

    oc new-project babylon-config
  2. Process OpenShift build template to create BuildConfig and ImageStream:

    oc process --local -f build-template.yaml | oc apply -f -
  3. Build user-namespace-operator image from local source:

    oc start-build babylon-agnosticv-operator --from-dir=.. --follow
  4. 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 -
  5. Run tests:

    ansible-playbook test/playbook.yaml
  6. 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 -