Skip to content

Latest commit

 

History

History
98 lines (82 loc) · 2.21 KB

DEVELOPMENT.md

File metadata and controls

98 lines (82 loc) · 2.21 KB

Introduction

These instructions should help you to build a custom version of the webhook with your changes

Prerequisites

  • 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

Using kind cluster

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

Deploy cert-manager

kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.9.1/cert-manager.yaml

Running on the cluster

  1. 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>
  1. Deploy the controller to the cluster with the image specified by IMG:
make deploy IMG=<some-registry>/<user>/peer-pods-webhook:<tag>
  1. To delete the webhook from the cluster:
make undeploy IMG=<some-registry>/<user>/peer-pods-webhook:<tag>

Testing

You can manually test your changes by following the steps:

  1. Create the runtimeclass
kubectl apply -f hack/rc.yaml
  1. Create the pod
kubectl apply -f hack/pod.yaml
  1. 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