-
Notifications
You must be signed in to change notification settings - Fork 25
/
Makefile
41 lines (35 loc) · 1 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
DATE:=$(shell date +%s)
GOBIN=go
GOBUILD=$(GOBIN) build
GOTEST=$(GOBIN) test
OPERATOR?=scaling
CONTROLLER=$(OPERATOR)-controller.go
TEST_CONTROLLER=$(OPERATOR)-controller_test.go
BIN=bin/k8s-restdev-$(OPERATOR)
DOCKERBIN=docker
VERSION?=kube-system.$(DATE)
IMAGE?=k8srestdev/$(OPERATOR):$(VERSION)
DOCKERBUILD=$(DOCKERBIN) build --build-arg bin=$(BIN) -t $(IMAGE) .
DEPLOYBIN?=kubectl
KN_PROJECT_ID?=$(PROJECT_ID)
.PHONY: test
all: test build push deploy
test:
$(GOTEST) $(TEST_CONTROLLER) $(CONTROLLER)
$(GOTEST) ./...
build:
GOOS=linux $(GOBUILD) \
-a --ldflags '-extldflags "-static"' \
-tags netgo \
-installsuffix netgo \
-v \
-o $(BIN) $(CONTROLLER)
$(DOCKERBUILD)
push:
docker push $(IMAGE)
deploy:
ifeq ($(DEPLOYBIN), kn)
cat ./artifacts/kubes/$(OPERATOR)/deployment.yml | sed "s|\[IMAGE\]|$(IMAGE)|g" | kn $(KN_PROJECT_ID) -- --namespace=kube-system apply -f -
else
cat ./artifacts/kubes/$(OPERATOR)/deployment.yml | sed "s|\[IMAGE\]|$(IMAGE)|g" | kubectl --namespace=kube-system apply -f -
endif