Repository: govuk-job-request-operator
- GitHub
- govuk-job-request-operator
- Ownership
- #govuk-platform-engineering-team owns the repo. #govuk-platform-support receives automated alerts for this repo.
- Category
- Utilities
- Links
README
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
annotations:
platform.publishing.service.gov.uk/requested-by: arn:aws:sts::123456789: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::123456789:assumed-role/otheruser.name-platformengineer/environment-platformengineer
spec:
jobRequestName: something
decision: Approved
description: "LGTM"
status:
state: Approved
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
managermanifest
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
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
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 --cleanruns, 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
IDE Settings
In order for gopls to pick up the test/e2e package ensure your IDE settings have "-tags=e2e" added. Set the following for VSCode in settings.json have the following:
{
"go.buildFlags": [
"-tags=e2e"
]
}
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.