Skip to content

Latest commit

 

History

History
129 lines (110 loc) · 4.46 KB

Development.adoc

File metadata and controls

129 lines (110 loc) · 4.46 KB

Development

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.

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 bitwarden-k8s-secrets-manager:

    oc project bitwarden-k8s-secrets-manager
  4. 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
  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 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 -

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 bitwarden-k8s-secrets-manager
  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 bitwarden-k8s-secrets-manager --from-dir=. --follow
  4. 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 -
  5. Run tests:

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