This repository has been archived by the owner on Jan 27, 2023. It is now read-only.
forked from jpeeler/podpreset-crd
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
117 lines (96 loc) · 2.91 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
APP_NAME=podpreset
IMG=$(DOCKER_PUSH_REPOSITORY)$(DOCKER_PUSH_DIRECTORY)/$(APP_NAME)
TAG=$(DOCKER_TAG)
BINARY=$(APP_NAME)
.PHONY: build-controller
build-controller:
./before-commit.sh ci
# Run tests
.PHONY: test-controller
test-controller:
go test ./pkg/... ./cmd/...
# Generate manifests e.g. CRD, RBAC etc.
.PHONY: manifests
manifests:
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all
# Generate code
.PHONY: generate
generate:
go generate ./pkg/... ./cmd/...
# Build the docker image
.PHONY: build-image-controller
build-image-controller:
docker build --no-cache -t $(APP_NAME)-controller:latest .
.PHONY: push-image-controller
push-image-controller:
docker tag $(APP_NAME)-controller $(IMG)-controller:$(TAG)
docker push $(IMG)-controller:$(TAG)
ifeq ($(JOB_TYPE), postsubmit)
@echo "Sign image with Cosign"
cosign version
cosign sign -key ${KMS_KEY_URL} $(IMG)-controller:$(TAG)
else
@echo "Image signing skipped"
endif
.PHONY: clean
clean:
rm -f webhook/webhook
rm -f manager
#
# Controller deployment targets
#
# Run against the configured Kubernetes cluster in ~/.kube/config
.PHONY: run-controller
run-controller: generate fmt vet
go run ./cmd/manager/main.go
# Install CRDs into a cluster
.PHONY: install
install: manifests
kubectl apply -f config/crds
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
.PHONY: deploy
deploy: manifests
kubectl apply -f config/crds
kustomize build config/default | kubectl apply -f -
.PHONY: undeploy
undeploy:
kustomize build config/default | kubectl delete -f -
kubectl delete -f config/crds
#
# Mutating webhook targets
#
.PHONY: deploy-webhook
deploy-webhook:
kubectl apply -f webhook/rbac/
kustomize build webhook/kustomize-config | kubectl apply -f -
.PHONY: undeploy-webhook
undeploy-webhook:
kustomize build webhook/kustomize-config | kubectl delete -f -
kubectl delete -f webhook/rbac/
.PHONY: build-webhook
build-webhook:
CGO_ENABLED=0 GOOS=linux go build -o ./webhook/webhook ./webhook/
.PHONY: build-image-webhook
build-image-webhook:
docker build --no-cache -t $(APP_NAME)-webhook:latest ./webhook/
rm -rf ./webhook/webhook
.PHONY: push-image-webhook
push-image-webhook:
docker tag $(APP_NAME)-webhook $(IMG)-webhook:$(TAG)
docker push $(IMG)-webhook:$(TAG)
ifeq ($(JOB_TYPE), postsubmit)
@echo "Sign image with Cosign"
cosign version
cosign sign -key ${KMS_KEY_URL} $(IMG)-webhook:$(TAG)
else
@echo "Image signing skipped"
endif
#
# CI targets
#
.PHONY: ci-pr
ci-pr: build-controller test-controller build-image-controller push-image-controller build-webhook build-image-webhook push-image-webhook
.PHONY: ci-master
ci-master: build-controller test-controller build-image-controller push-image-controller build-webhook build-image-webhook push-image-webhook
.PHONY: ci-release
ci-release: build-controller test-controller build-image-controller push-image-controller build-webhook build-image-webhook push-image-webhook