Black lives matter.

We stand in solidarity with the Black community.

Racism is unacceptable.

It conflicts with the core values of the Kubernetes project and our community does not tolerate it.

Makefile Helpers

By default, the projects are scaffolded with a Makefile. You can customize and update this file as please you. Here, you will find some helpers that can be useful.

To debug with go-delve

The projects are built with Go and you have a lot of ways to do that. One of the options would be use go-delve for it:

# Run with Delve for development purposes against the configured Kubernetes cluster in ~/.kube/config
# Delve is a debugger for the Go programming language. More info:
run-delve: generate fmt vet manifests
    go build -gcflags "all=-trimpath=$(shell go env GOPATH)" -o bin/manager main.go
    dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec ./bin/manager

To change the version of CRDs

The controller-gen program (from controller-tools) generates CRDs for kubebuilder projects, wrapped in the following make rule:

manifests: controller-gen
	$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases

controller-gen lets you specify what CRD API version to generate (either “v1”, the default, or “v1beta1”). You can direct it to generate a specific version by adding crd:crdVersions={<version>} to your CRD_OPTIONS, found at the top of your Makefile:

CRD_OPTIONS ?= "crd:crdVersions={v1beta1},trivialVersions=true,preserveUnknownFields=false"

To get all the manifests without deploying

By adding make dry-run you can get the patched manifests in the dry-run folder, unlike make depĺoy which runs kustomize and kubectl apply.

To accomplish this, add the following lines to the Makefile:

dry-run: manifests
	cd config/manager && kustomize edit set image controller=${IMG}
	mkdir -p dry-run
	kustomize build config/default > dry-run/manifests.yaml