Skip to content

Latest commit

 

History

History
100 lines (76 loc) · 3.69 KB

Development.adoc

File metadata and controls

100 lines (76 loc) · 3.69 KB

Anarchy Development

Anarchy development is primarily aimed at development within an OpenShift cluster. Any recent version of OpenShift will be suitable.

Anarchy development can be performed in the odo OpenShift developer CLI or building with OpenShift build configs. Use of odo is recommended for fast iterative development, but all changes should be tested against a build with Anarchy components running in separate deployments before opening a pull request.

Anarchy is build on top of Python Kopf source-to-image. Kopf requires the CustomResourceDefinition kopfpeerings.kopf.dev to govern operations between pods. If this CRD is not already available in the cluster it and should be applied with:

oc apply -f kopfpeerings.crd.yaml

Steps described here for building and testing Anarchy assume you have already installed the Anarchy custom resource definitions and cluster roles.

Using odo

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

  2. Select or create a project namespace for performing Anarchy development:

    oc new-project anarchy
  3. Use odo create to setup configuration for beginning work on Anarchy:

    odo create --devfile devfile.yaml
  4. Process the helm template with set to exclude deployment and apply resource definitions:

    helm template helm/ --include-crds \
    --set deploy=false \
    --set roles.create=true \
    --set clusterroles.create=true \
    | oc apply -f -
  5. Grant the anarchy cluster role to the default service account:

    oc policy add-role-to-user anarchy -z default \
    --rolebinding-name=anarchy \
    --role-namespace=$(oc project -q)
    Note
    At this time odo does not support running with an alternate service account. Normal deployment does not use the default service account.
  6. Use odo push to create an anarchy-app Deploy Anarchy within odo:

    odo push
  7. Run test playbook

    ansible-playbook test/odo-playbook.yaml

Building an Anarchy Container Image

You may wish to build and run Anarchy from a container image so that it deploys runners in separate pods as it does in a normal deployment.

OpenShift

Create the Anarchy BuildConfig and ImageStream using the provided template:

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

Build the anarchy image from local source:

oc start-build -wF anarchy --from-dir=.

Deploy new Anarchy image from build with helm template:

helm template helm/ --include-crds \
--set=envVars.CLEANUP_INTERVAL="10" \
--set=image.repository=$(oc get imagestream anarchy -o jsonpath='{.status.tags[?(@.tag=="latest")].items[0].dockerImageReference}') \
| oc apply -f -

Run test playbook

ansible-playbook test/playbook.yaml