Skip to content

Latest commit

 

History

History
153 lines (134 loc) · 4.88 KB

Development.adoc

File metadata and controls

153 lines (134 loc) · 4.88 KB

Poolboy Development

Poolboy development 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 poolboy local dev resources from the provided helm chart using poolboy.dev.local as the operator domain:

    helm template helm \
    --set deploy=false \
    --set admin.deploy=false \
    --set nameOverride=poolboy-dev \
    --set operatorDomain.name=poolboy.dev.local \
    | oc apply -f -
  3. Create a project for development using odo:

    oc create namespace poolboy-dev
  4. Change project to poolboy-dev namespace:

    oc project poolboy-dev
  5. Grant privileges for cluster role poolboy-dev to default service account:

    oc adm policy add-cluster-role-to-user poolboy-dev -z default
  6. Run odo:

    odo dev
    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.
  7. Run tests with Ansible:

    ansible-playbook \
    -e ansible_python_interpreter='{{ ansible_playbook_python }}' \
    -e poolboy_domain=poolboy.dev.local \
    -e poolboy_namespace=poolboy-dev \
    -e poolboy_service_account=default \
    -e poolboy_test_namespace=poolboy-dev-test \
    -e poolboy_tests='["simple"]' \
    test/playbook.yaml
  8. Cleanup

    Remove odo component

    odo delete --force poolboy

    Delete resources created from helm template:

    helm template helm \
    --set deploy=false \
    --set nameOverride=poolboy-dev \
    --set operatorDomain.name=poolboy.dev.local \
    | 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 poolboy-dev
  2. Process OpenShift build template to create BuildConfig and ImageStream:

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

    oc start-build poolboy --from-dir=. --follow
  4. Deploy Poolboy from build image

    helm template helm \
    --set nameOverride=poolboy-dev \
    --set namespace.create=false \
    --set manageClaimsInterval=5 \
    --set manageHandlesInterval=5 \
    --set operatorDomain.name=poolboy.dev.local \
    --set=image.tagOverride=- \
    --set=image.repository=$(oc get imagestream poolboy -o jsonpath='{.status.tags[?(@.tag=="latest")].items[0].dockerImageReference}') \
    | oc apply -f -
  5. Run tests with Ansible:

    ansible-playbook \
    -e ansible_python_interpreter='{{ ansible_playbook_python }}' \
    -e poolboy_domain=poolboy.dev.local \
    -e poolboy_namespace=poolboy-dev \
    -e poolboy_service_account=poolboy-dev \
    -e poolboy_test_namespace=poolboy-dev-test \
    test/playbook.yaml

    To test development, rerun thes build/deploy/test steps.

  6. Cleanup

    Remove resources created from the helm template:

    helm template helm \
    --set nameOverride=poolboy-dev \
    --set namespace.create=false \
    --set operatorDomain.name=poolboy.dev.local \
    --set=image.tagOverride=- \
    | oc delete -f -

    Remove BuildConfig and ImageStream:

    oc process --local -f build-template.yaml | oc delete -f -