Skip to content

Latest commit

 

History

History
102 lines (72 loc) · 2.77 KB

development.md

File metadata and controls

102 lines (72 loc) · 2.77 KB

How it works

This project aims to follow the Kubernetes Operator pattern.

It uses Controllers which provides a reconcile function responsible for synchronizing resources untile the desired state is reached on the cluster.

More information can be found via the Kubebuilder Documentation.

Getting Started

You’ll need a Kubernetes cluster to run against. You can use KIND to get a local cluster for testing, or run against a remote cluster.

Note: Your controller will automatically use the current context in your kubeconfig file (i.e. whatever cluster kubectl cluster-info shows).

Note: Run make --help for more information on all potential make targets.

Running on the cluster

  1. Deploy the requirements for tests in the cluster, i.e. cert-manager and the prometheus-operator:
make deploy-test-requirements
  1. Build and push your image to the location specified by IMG:
IMAGE=<some-registry>/sts-phased-rollout-operator:tag
make docker-build docker-push IMG=$IMAGE

Or, if you use kind you can push the image directly to the cluster with:

IMAGE=<some-registry>/sts-phased-rollout-operator:tag
make docker-build IMG=$IMAGE
kind load docker-image $IMAGE
  1. Deploy the controller to the cluster with the image specified by IMG:
make deploy IMG=$IMAGE
  1. Install Instances of Custom Resources:
kubectl apply -k config/samples/

Running locally

Test it without running the operator in the cluster:

  1. Deploy the requirements for tests in the cluster, i.e. cert-manager and the prometheus-operator:
make deploy-test-requirements
  1. Port forward the prometheus endpoint so that it is reachable from your local development:
kubectl port-forward service/prometheus-prometheus -n monitoring 9090:9090
  1. Install the CRDs into the cluster:
make install
  1. Run your controller (this will run in the foreground, so switch to a new terminal if you want to leave it running):
# disable webhooks, otherwise you will need valid certs files ca.crt, tls.crt and tls.key in the /tmp/k8s-webhook-server/serving-certs/ directory
export ENABLE_WEBHOOKS=false
make run #or `make run-debug` for debug logs
  1. Run the sample:
kubectl apply -k config/samples/local-development

Modifying the API definitions

If you are editing the API definitions, generate the manifests such as CRs or CRDs using:

make manifests

Uninstall CRDs

To delete the CRDs from the cluster:

make uninstall

Undeploy controller

UnDeploy the controller from the cluster:

make undeploy