See Helm's documentation to get started with Helm.
See the GOV.UK Kubernetes cluster docs for an introduction to the cluster or ask #govuk-platform-engineering in Slack.
Local development uses k3d which runs a Kubernetes cluster locally using Docker.
- Install Helm
brew install helm
- Install Docker
Install from here
- Install k3d
brew install k3d
- Install kubectl
brew install kubectl
- Clone the repository
git clone [email protected]:alphagov/govuk-dgu-charts.git
Advantage of using k3d
is that we don't need to worry about creating an ingress controller. This aligns with how we
run the cluster in EKS as that manages creation of the ingress controller for us.
- Create the
k3d
cluster
k3d cluster create local-ckan --api-port 6550 -p "8081:80@loadbalancer" --registry-create local-registry
- Switch kubectl to point to your local cluster:
kubectl config use-context k3d-local-ckan
- Locate the port the registry is running on:
docker ps -f name=local-registry
The remaining steps will assume our local registry is running on localhost:53492
- Build a docker image
If we want to push an image to our local registry we have to tag our image. See here for background on local Docker registries.
So if our local registry is running at localhost:53492
and we want to build
ckan 2.10.4
we have to tag our image as follows:
docker build -t localhost:53492/ckan:2.10.4 -f docker/ckan/2.10.4.Dockerfile .
Note: for Publish and Find build the dev.Dockerfile version
docker build -t localhost:53492/datagovuk_publish:dev -f docker/dev.Dockerfile .
- Push the image to our local registry
docker push localhost:53492/ckan:2.10.4
- Use the image in our Helm chart
Currently govuk-dgu-charts/charts/ckan/values.yaml
points to the test
environment:
environment: test
ckan:
replicaCount: 1
...
Update govuk-dgu-charts/ckan/images/test/ckan.yaml with our new image so it looks like this:
repository: local-registry:53492/ckan
tag: 2.10.4
branch: main
Note that local-registry
matches the name of the registry we passed in step 1.
If we want to use a different image from a different environment then set environment
appropriately.
- Apply the local dev Helm Chart
kubectl apply -f local-dev.yaml
This sets up some initial configuration in the cluster.
- Install the application Helm charts
helm install ckan-dev ./charts/ckan/
helm install datagovuk-dev ./charts/datagovuk/
Now your local CKAN deployment will use the localhost:54392/ckan.2.10.4
image.
Update /etc/hosts
and add ckan.dev.govuk.digital
and find.data.gov.uk
after kubernetes.docker.internal
on the sameline in the /etc/hosts
file
- update the
targetRevision
inckan-application.yaml
ordatagovuk-application.yaml
to be the branch you want to test against. - update the target revision in Argo on
dgu-app-of-apps
to be the branch you want to test, normally on the Integration cluster. - after testing is complete remember to set the target revision back to
main
indgu-app-of-apps
. - if you are creating a PR drop the commit which updates the
targetRevision
in step 1.
When creating fine-grained API tokens, ensure that read/write permissions for PRs and Content are allowed (this will allow for PR and commit creation) and that CI user is used to create the PRs.
We have several Custom Resource Definitions (CRDs) installed in our Kubernetes clusters, and referenced by the Helm charts in this repository.
We use kubeconform to validate our Kubernetes manifests against schemas for those resources. This helps us ensure that our Helm charts are correct.
kubeconform
runs in a GitHub Action as a pre-merge check and can also be run
locally.
You can run the validation tests locally by installing kubeconform
and running
mkdir helm-dist
for c in charts/*; do
helm template "$(basename "$c")" "$c" --output-dir helm-dist
done
kubeconform -schema-location default \
-schema-location "https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json" \
-summary helm-dist
GOV.UK Platform Engineering team looks after this repo. If you're inside GDS, you can find us in #govuk-platform-engineering.