Analytical Platform Tools Operator
This repository contains the necessary code to deploy a "Tools" Kubernetes operator into the Analytical Platform ecosystem.
The "Tools" operator will enable the control panel to communicate with it using standard REST API calls, providing an endpoint for Analytical Platform tools (such as JupyterLab, RStudio and Airflow) to do the following:
- list all available versions of each tools
TODO: Add global tool command - perhaps another api
- show what the current user has deployed
For example, After a tool is deployed it can be listing user be queried using the kubectl command:
> kubectl get tool -n user-namespace
NAME AGE
airflow 17h
jupyterlab 17h
rstudio 17h
- install/start/stop and delete a tool for the current user.
A tool can be deployed, deleted by crafting a manifest file and sending it to the api:
kubectl apply -f ./config/samples/tools_v1alpha1_jupyterlab.yaml
Development practices
Commit messages
Please if you can use conventional commits to make your commits and follow the conventional commit guidelines.
Versioning
Please use semantic versioning for versioning when releasing. This will make it easier to track changes and to make it easier to find the latest version.
Local development
Pre-reqs
How to use
Using a local Kubernetes cluster, you should be able to deploy and perform actions locally that should emulate the dev and production clusters.
To spin up a local cluster with a local container registry run the following in the root of the repository:
make cluster up
To run the controller outside the cluster, run:
make install run
In another window you can create a sample resource from here: ./config/samples/.
Deployment
The deployment in this repository isn't ideal. At the time of its creation, the Analytical Platform only allows installs via flux - this flux installation is also fairly flaky and required a bit of hacking to allow us control of the image it installs. This next section should clear up how deployment works.
Development cluster
The development cluster is an EKS cluster in the dev AWS account. Deployment to this cluster should be restricted to anything in the main branch of this repository.
GitHub Action
A GitHub Acton named build-test-build-dev
triggers on each push to main. The intention of this pipeline is to test (make test
), build (make docker-build
) and push to dockerhub (make docker-push
) using a combination of branch
-gitSHA
-timestamp
as the image tag. The pipeline will then deploy the controller to the Development cluster by amending the image tag in config/manager
.
The less than ideal part of this pipeline is we have to amend the kustomize manifest file as a step in the pipeline. This means the pipeline creates a commit and push to main to deploy.
Manual
Pre-reqs
You must have push permissions to the ministryofjustice
dockerhub repository.
Build, push and deploy
make docker-build
make docker-push
make deploy
Production cluster
GitHub Action
Manual
Test
The code in this repository uses envtest to perform go tests against mock ectd and api components. To run these tests:
make test