...
1
2# Image URL to use all building/pushing image targets
3IMG ?= controller:latest
4# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
5CRD_OPTIONS ?= "crd:trivialVersions=true"
6
7all: manager
8
9# Run tests
10test: generate fmt vet manifests
11 go test ./api/... ./controllers/... -coverprofile cover.out
12
13# Build manager binary
14manager: generate fmt vet
15 go build -o bin/manager main.go
16
17# Run against the configured Kubernetes cluster in ~/.kube/config
18run: generate fmt vet
19 go run ./main.go
20
21# Install CRDs into a cluster
22install: manifests
23 kubectl apply -f config/crd/bases
24
25# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
26deploy: manifests
27 kubectl apply -f config/crd/bases
28 kustomize build config/default | kubectl apply -f -
29
30# Generate manifests e.g. CRD, RBAC etc.
31manifests: controller-gen
32 $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
33
34# Run go fmt against code
35fmt:
36 go fmt ./...
37
38# Run go vet against code
39vet:
40 go vet ./...
41
42# Generate code
43generate: controller-gen
44 $(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./api/...
45
46# Build the docker image
47docker-build: test
48 docker build . -t ${IMG}
49 @echo "updating kustomize image patch file for manager resource"
50 sed -i'' -e 's@image: .*@image: '"${IMG}"'@' ./config/default/manager_image_patch.yaml
51
52# Push the docker image
53docker-push:
54 docker push ${IMG}
55
56# find or download controller-gen
57# download controller-gen if necessary
58controller-gen:
59ifeq (, $(shell which controller-gen))
60 go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.0-beta.2
61CONTROLLER_GEN=$(shell go env GOPATH)/bin/controller-gen
62else
63CONTROLLER_GEN=$(shell which controller-gen)
64endif
View as plain text