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.
-
Install
ododeveloper CLI as described in the OpenShift documentation: Installing odo -
Select or create a project namespace for performing Anarchy development:
oc new-project anarchy
-
Use
odo createto setup configuration for beginning work on Anarchy:odo create --devfile devfile.yaml
-
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 -
-
Grant the
anarchycluster role to the default service account:oc policy add-role-to-user anarchy -z default \ --rolebinding-name=anarchy \ --role-namespace=$(oc project -q)
NoteAt this time ododoes not support running with an alternate service account. Normal deployment does not use the default service account. -
Use
odo pushto create ananarchy-appDeploy Anarchy within odo:odo push
-
Run test playbook
ansible-playbook test/odo-playbook.yaml
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.
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