|
1 | 1 | # GOV.UK Job Request Operator |
2 | 2 |
|
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). |
4 | 4 |
|
5 | 5 | ## Usage |
6 | 6 |
|
7 | | -To install the required dependencies:: |
| 7 | +To install the required dependencies: |
8 | 8 |
|
9 | 9 | ```shell |
10 | | -brew install operator-sdk |
| 10 | +brew install kubebuilder |
11 | 11 | 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 |
12 | 102 | ``` |
13 | 103 |
|
14 | 104 | ## Team |
|
0 commit comments