These instructions should help you to build a custom version of the webhook with your changes
- Golang (1.18.x)
- Operator SDK version (1.23.x+)
- podman and podman-docker or docker
- Access to Kubernetes cluster (1.24+)
- Container registry to store images
For kind
clusters, you can use the following Makefile targets
Create kind cluster
make kind-cluster
Deploy the webhook in the kind cluster
make kind-deploy IMG=<some-registry>/<user>/peer-pods-webhook:<tag>
If not using kind
, the follow these steps to deploy the webhook
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.9.1/cert-manager.yaml
- Build and push an image for your current architecture to the location specified by
IMG
:
make docker-load docker-push IMG=<some-registry>/<user>/peer-pods-webhook:<tag>
- Deploy the controller to the cluster with the image specified by
IMG
:
make deploy IMG=<some-registry>/<user>/peer-pods-webhook:<tag>
- To delete the webhook from the cluster:
make undeploy IMG=<some-registry>/<user>/peer-pods-webhook:<tag>
You can manually test your changes by following the steps:
- Create the runtimeclass
kubectl apply -f hack/rc.yaml
- Create the pod
kubectl apply -f hack/pod.yaml
- View the mutated pod
kubectl get -f hack/pod.yaml -o yaml | grep kata.peerpods
You can see that that the hack/pod.yaml
has Kubernetes resources specified in the spec:
resources:
requests:
cpu: 1
memory: 1Gi
limits:
cpu: 1
memory: 2Gi
In the mutated pod these have been removed and the pod overhead
overhead:
cpu: 250m
memory: 120Mi
and peer pod vm limit added.
resources:
limits:
kata.peerpods.io/vm: "1"
requests:
kata.peerpods.io/vm: "1"
However, before opening a pull request with your changes, it is recommended that you run the end-to-end tests locally. Ensure that you have bats, docker (or podman-docker), and kind installed in your system; and then run:
make test-e2e