-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMakefile.infoblox
130 lines (94 loc) · 4.1 KB
/
Makefile.infoblox
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
118
119
120
121
122
123
124
125
126
127
128
129
130
GIT_COMMIT := $(shell git describe --always --long --tags || echo pre-commit)
# image tag
CHART_VERSION := $(GIT_COMMIT)
PROJECT ?= db-controller
CHART_FILE := $(PROJECT)-$(CHART_VERSION).tgz
CHART_FILE_CRD := $(PROJECT)-crds-$(CHART_VERSION).tgz
IMG ?= ghcr.io/infobloxopen/db-controller:${GIT_COMMIT}
# FIXME: combine all images into one
DBPROXY_IMG ?= ghcr.io/infobloxopen/db-controller/dbproxy:${GIT_COMMIT}
DSNEXEC_IMG ?= ghcr.io/infobloxopen/db-controller/dsnexec:${GIT_COMMIT}
.id:
git config user.email | awk -F@ '{print $$1}' > .id
.env: force
kubectl config current-context | awk -F@ '{print $$1}' > .env
# Make a rule always rebuild
force:
docker-build-%: target=$(@:docker-build-%=%)
docker-build-%: .id
cd $(target) && $(CONTAINER_TOOL) build \
--platform linux/amd64 \
-t ghcr.io/infobloxopen/$(target):$(GIT_COMMIT) .
docker-push-%: target=$(@:docker-push-%=%)
docker-push-%: .id
$(CONTAINER_TOOL) push ghcr.io/infobloxopen/$(target):$(GIT_COMMIT)
# FIXME: use the actual chart names
build-properties: build.properties crd.build.properties
build.properties:
@sed 's/{CHART_FILE}/$(CHART_FILE)/g' build.properties.in > $@
crd.build.properties:
@sed 's/{CHART_FILE}/$(CHART_FILE_CRD)/g' build.properties.in > $@
HELM ?= $(LOCALBIN)/helm-$(HELM_VERSION)
HELMS3 ?= .helms3
HELM_VERSION ?= v3.15.2
.PHONY: helm
helm: $(HELM) ## Download golangci-lint locally if necessary.
$(HELM): $(LOCALBIN)
@test -s $(LOCALBIN)/helm || { curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | PATH="${PATH}":$(LOCALBIN) HELM_INSTALL_DIR=$(LOCALBIN) BINARY_NAME=helm-$(HELM_VERSION) bash -s -- --version $(HELM_VERSION) --no-sudo; }
@ln -sf $(LOCALBIN)/helm-$(HELM_VERSION) $(LOCALBIN)/helm
.PHONY: helms3
helms3: helm $(HELMS3)
$(HELMS3): $(LOCALBIN)
$(HELM) plugin list | grep s3 || $(HELM) plugin install https://github.com/hypnoglow/helm-s3.git
$(HELM) repo ls | grep infobloxcto || $(HELM) repo add infobloxcto s3://infoblox-helm-dev/charts
$(HELM) repo update
touch $@
package-charts: package-chart-db-controller package-chart-db-controller-crds
.FORCE:
%-$(CHART_VERSION).tgz: .FORCE
$(HELM) lint helm/$(*F)
$(HELM) package helm/$(*F) --version ${CHART_VERSION} --app-version ${CHART_VERSION}
touch $@
package-chart-%: target=$(@:package-chart-%=%)
package-chart-%: helm
$(MAKE) $(*F)-$(CHART_VERSION).tgz
push-charts: .id push-chart-db-controller push-chart-db-controller-crds
push-chart-%: target=$(@:push-chart-%=%)
push-chart-%: helms3
$(HELM) repo update
PATH=$PATH:$(LOCALBIN) $(HELM) s3 push --force ${target}-${CHART_VERSION}.tgz infobloxcto
.PHONY: list-of-images
list-of-images:
@echo -n ${IMG} ${DBPROXY_IMG} ${DSNEXEC_IMG}
# FIXME: remove for a single image
build-images: docker-build docker-build-dbproxy docker-build-dsnexec
# FIXME: remove for a single image
push-images: docker-push-db-controller docker-push-dbproxy docker-push-dsnexec
# source check-context as part of helm upgrade command
.deploy-$(GIT_COMMIT): .id .env
export HELM_SETFLAGS=$$(bash ./scripts/check-context.sh) && \
echo "HELM_SETFLAGS is: $$HELM_SETFLAGS" >&2 && \
helm upgrade --install `cat .id` \
db-controller-${CHART_VERSION}.tgz \
--debug --namespace "`cat .id`" \
--wait --wait-for-jobs \
--create-namespace \
-f helm/db-controller/minikube.yaml \
--set dbController.class=`cat .id` \
--set env=`cat .env` \
$$HELM_SETFLAGS
deploy: package-chart-db-controller .deploy-$(GIT_COMMIT)
undeploy:
helm -n `cat .id` uninstall `cat .id`
helm-test:
helm -n `cat .id` test `cat .id` --debug
manifests: test/crd
test/crd: test/crd/rds.aws.crossplane.io_dbclusters.yaml test/crd/rds.aws.crossplane.io_dbclusterparametergroups.yaml test/crd/rds.aws.crossplane.io_dbinstances.yaml test/crd/rds.aws.crossplane.io_dbparametergroups.yaml
test/crd/%.yaml:
mkdir -p test/crd
curl -sS -o $@ https://raw.githubusercontent.com/crossplane-contrib/provider-aws/v0.48.1/package/crds/$*.yaml
clean:
chmod -R +w bin/
rm -rf $(shell git check-ignore -- *)
docs-serve:
mkdocs serve -a '0.0.0.0:9000'