GOV.UK Job Request Operator
This is a k8s operator that is used to make job requests built with kubebuilder.
Installation
Requires Kubernetes >=1.36
Install the Helm chart, where $VERSION is the latest release version (e.g. v1.2.3):
helm install my-operator oci://ghcr.io/alphagov/govuk/charts/govuk-job-request-operator:$VERSION
Usage
govuk-cli is the recommended way to interact with this operator.
Custom Resource Definitions (CRDs)
JobRequest
A JobRequest represents a request to run a command/job.
apiVersion: platform.publishing.service.gov.uk/v1
kind: JobRequest
metadata:
name: something
annotations:
platform.publishing.service.gov.uk/requested-by: arn:aws:sts::123456789012:assumed-role/user.name-platformengineer/environment-platformengineer
spec:
containerFrom:
podSpecFrom:
group: apps/v1
kind: Deployment
name: whitehall-admin
containerName: app
command: rake
args: [ "some:task", "some-arg" ]
status:
jobName: jr-something
reviewName: something-approval
state: Started
JobRequestReview
A JobRequestReview is a review of a JobRequest.
It can either be Approved or Rejected.
apiVersion: platform.publishing.service.gov.uk/v1
kind: JobRequestReview
metadata:
name: something-approval
annotations:
platform.publishing.service.gov.uk/reviewed-by: arn:aws:sts::123456789012:assumed-role/otheruser.name-platformengineer/environment-platformengineer
spec:
jobRequestName: something
decision: Approved
description: "LGTM"
status:
state: Approved
Development
To install the required dependencies:
brew install helm
brew install k3d
Pre-commit hooks
We have some recommended pre-commit hooks. You need
to install pre-commit for these to run.
Create and generate the manifests
- Create the manifests
make manifests
- Start a k3d cluster
k3d cluster create cluster --api-port 6550
- Install the CRDs into the cluster
make install
Run the controller locally
- Run the controller locally
This will run the controller locally and not in the cluster.
make run
Run the controller in the cluster
- Build the controller in a docker image
make docker-build
- Modify the
manager manifest
Edit the manager Deployment in config/manager/manager.yaml to include the following:
imagePullPolicy: IfNotPresent
- Load the image into the cluster
k3d image import controller:latest -c cluster
- Deploy the controller to the cluster
make deploy
Generate Helm chart
- Generate a Helm chart
go tool kubebuilder edit --plugins=helm/v2-alpha
Run the integration tests
make test
Run the end-to-end tests
End to end tests use kind to spin up a local cluster.
- Install
kind:
brew install kind
- Run the end-to-end tests
See https://github.com/kubernetes-sigs/kind/issues/3795 to turn off containerd image store
make test-e2e
IDE Settings
In order for gopls to pick up the test/e2e package ensure your IDE settings have "-tags=e2e" added. Add the following to VSCode's settings.json:
{
"go.buildFlags": [
"-tags=e2e"
]
}
Release a new version
This project uses Semantic Versioning.
To create a new release, use the Create Versioned Release
GitHub Actions workflow.
Select the correct version bump level (patch, minor or major) based on the changes made since the last release.
The release process works as follows:
- 'Create Versioned Release' is triggered manually
- A Git tag is calculated based on the provided version bump level and the latest version number
goreleaser release --clean runs, which:
- Builds the operator for macOS and Linux, arm64 and x86
- Generates CRD resources
- Packages up the binary and CRD resources into a .tar.gz
- Creates a GitHub Release with the packaged binary and creates a changelog based on commits since last release
- Builds a container image
make push-helm-chart runs, which generates, packages and pushes the Helm chart
Team
GOV.UK Platform
Engineering
team looks after this repo. If you're inside GDS, you can find us in
#govuk-platform-engineering or view our kanban
board.
Licence
MIT License