This is a k8s operator that is used to make job requests built with kube-builder.
Usage
To install the required dependencies:
brew install kubebuilder
brew install helm
brew install k3d
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
spec:
containerFrom:
podSpecFrom:
group: apps/v1
kind: Deployment
labelSelector:
matchLabels:
app: whitehall-admin
containerName: app
command: rake
args: [ "some:task", "some-arg" ]
status:
jobName: jr-something
requestedBy: arn:aws:sts::123456789:assumed-role/user.name-platformengineer/environment-platformengineer
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
spec:
jobRequestName: something
decision: Approved
description: "LGTM"
status:
reviewedBy: arn:aws:sts::123456789:assumed-role/otheruser.name-platformengineer/environment-platformengineer
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
kubebuilder edit --plugins=helm/v2-alpha
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
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