Skip to content

Commit dfd3d99

Browse files
committed
Add CODEOWNERS and README
Description: - Add instructions on how to run the controller locally - Add `CODEOWNERS` to ensure only the [GOV.UK Platform Engineering team](https://github.com/orgs/alphagov/teams/gov-uk-platform-engineering) can approve - alphagov/govuk-infrastructure#4172
1 parent f4b5faa commit dfd3d99

3 files changed

Lines changed: 173 additions & 3 deletions

File tree

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Platform Engineering review required
2+
* @alphagov/gov-uk-platform-engineering

.github/workflows/test-chart.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Test Chart
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions: {}
8+
9+
jobs:
10+
test-e2e:
11+
permissions:
12+
contents: read
13+
name: Run on Ubuntu
14+
runs-on: ubuntu-latest
15+
env:
16+
IMG: controller:latest
17+
steps:
18+
- name: Clone the code
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20+
with:
21+
persist-credentials: false
22+
23+
- name: Setup Go
24+
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
25+
with:
26+
go-version-file: go.mod
27+
28+
- name: Install the latest version of kind
29+
run: |
30+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-$(go env GOARCH)
31+
chmod +x ./kind
32+
sudo mv ./kind /usr/local/bin/kind
33+
34+
- name: Verify kind installation
35+
run: kind version
36+
37+
- name: Create kind cluster
38+
run: kind create cluster
39+
40+
- name: Prepare govuk-job-request-operator
41+
run: |
42+
go mod tidy
43+
make docker-build
44+
kind load docker-image $IMG
45+
46+
- name: Install Helm
47+
run: make install-helm
48+
49+
- name: Lint Helm Chart
50+
run: |
51+
helm lint ./dist/chart
52+
53+
# TODO: Uncomment if cert-manager is enabled
54+
# - name: Install cert-manager via Helm (wait for readiness)
55+
# run: |
56+
# helm repo add jetstack https://charts.jetstack.io
57+
# helm repo update
58+
# helm install cert-manager jetstack/cert-manager \
59+
# --namespace cert-manager \
60+
# --create-namespace \
61+
# --set crds.enabled=true \
62+
# --wait \
63+
# --timeout 300s
64+
65+
# TODO: Uncomment if Prometheus is enabled
66+
# - name: Install Prometheus Operator CRDs
67+
# run: |
68+
# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
69+
# helm repo update
70+
# helm install prometheus-crds prometheus-community/prometheus-operator-crds
71+
72+
- name: Deploy manager via Helm
73+
run: |
74+
make helm-deploy
75+
76+
- name: Check Helm release status
77+
run: |
78+
make helm-status

README.md

Lines changed: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,104 @@
11
# GOV.UK Job Request Operator
22

3-
This is a k8s operator that is used to make job requests built with [operator-sdk](https://sdk.operatorframework.io/).
3+
This is a k8s operator that is used to make job requests built with [kube-builder](https://github.com/kubernetes-sigs/kubebuilder).
44

55
## Usage
66

7-
To install the required dependencies::
7+
To install the required dependencies:
88

99
```shell
10-
brew install operator-sdk
10+
brew install kubebuilder
1111
brew install helm
12+
brew install k3d
13+
```
14+
15+
### Custom Resource Definition (CRD)
16+
17+
```
18+
apiVersion: platform.gov.uk/v1
19+
kind: JobRequest
20+
metadata:
21+
labels:
22+
app.kubernetes.io/name: govuk-job-request-operator
23+
app.kubernetes.io/managed-by: kustomize
24+
name: jobrequest-sample
25+
spec:
26+
foo: bar
27+
```
28+
29+
### Create and generate the manifests
30+
31+
1. Create the manifests
32+
33+
```
34+
make manifests
35+
```
36+
37+
2. Start a k3d cluster
38+
39+
```
40+
k3d cluster create cluster --api-port 6550
41+
```
42+
43+
3. Install the CRDs into the cluster
44+
45+
```
46+
make install
47+
```
48+
49+
### Run the controller locally
50+
51+
1. Run the controller locally
52+
53+
This will run the controller locally and not in the cluster.
54+
55+
```
56+
make run
57+
```
58+
59+
2. Create a custom resource
60+
61+
Edit `platform_v1_jobrequest.yaml` to the following:
62+
63+
```
64+
spec:
65+
foo: bar
66+
```
67+
68+
3. Apply the resource
69+
70+
```
71+
kubectl apply -k config/samples
72+
```
73+
74+
### Run the controller in the cluster
75+
76+
1. Build the controller in a docker image
77+
78+
```
79+
make docker-build
80+
```
81+
82+
2. Modify the `manager` manifest
83+
84+
Edit the `manager` Deployment in `config/manager/manager.yaml` to include the following:
85+
86+
```
87+
imagePullPolicy: IfNotPresent
88+
```
89+
90+
3. Load the image into the cluster
91+
92+
```
93+
k3d image import controller:latest -c cluster
94+
```
95+
96+
### Generate Helm chart
97+
98+
1. Generate a Helm chart
99+
100+
```
101+
kubebuilder edit --plugins=helm/v2-alpha
12102
```
13103

14104
## Team

0 commit comments

Comments
 (0)