forked from IBM/ibm-common-service-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
101 lines (82 loc) · 3.8 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
QUAY_REPO ?= quay.io/opencloudio
IMAGE_NAME ?= common-service-operator
OPERATOR_NAME ?= ibm-common-service-operator
CSV_VERSION ?= 3.4.1
VERSION ?= $(shell git describe --exact-match 2> /dev/null || \
git describe --match=$(git rev-parse --short=8 HEAD) --always --dirty --abbrev=8)
VCS_URL ?= https://github.com/IBM/ibm-common-service-operator
VCS_REF ?= $(shell git rev-parse HEAD)
# The namespce that operator will be deployed in
NAMESPACE=ibm-common-services
QUAY_USERNAME ?=
QUAY_PASSWORD ?=
BUILD_LOCALLY ?= 1
ARCH := $(shell uname -m)
LOCAL_ARCH := "amd64"
ifeq ($(ARCH),x86_64)
LOCAL_ARCH="amd64"
else ifeq ($(ARCH),ppc64le)
LOCAL_ARCH="ppc64le"
else ifeq ($(ARCH),s390x)
LOCAL_ARCH="s390x"
else
$(error "This system's ARCH $(ARCH) isn't recognized/supported")
endif
ifeq ($(BUILD_LOCALLY),0)
export CONFIG_DOCKER_TARGET = config-docker
endif
include common/Makefile.common.mk
install: ## Install all resources (CR/CRD's, RBAC and Operator)
@echo ....... Set environment variables ......
- export WATCH_NAMESPACE=${NAMESPACE}
@echo ....... Creating namespace .......
- kubectl create namespace ${NAMESPACE}
@echo ....... Applying CRDs .......
- kubectl apply -f deploy/crds/operator.ibm.com_commonservices_crd.yaml
@echo ....... Applying RBAC .......
- kubectl apply -f deploy/service_account.yaml -n ${NAMESPACE}
- kubectl apply -f deploy/role.yaml -n ${NAMESPACE}
- kubectl apply -f deploy/role_binding.yaml -n ${NAMESPACE}
@echo ....... Applying Operator .......
- kubectl apply -f deploy/operator.yaml -n ${NAMESPACE}
@echo ....... Creating the Instances .......
- kubectl apply -f deploy/crds/operator.ibm.com_v3_commonservice_cr.yaml -n ${NAMESPACE}
uninstall: ## Uninstall all that all performed in the $ make install
@echo ....... Uninstalling .......
@echo ....... Deleting the Instances .......
- kubectl delete -f deploy/crds/operator.ibm.com_v3_commonservice_cr.yaml -n ${NAMESPACE} --ignore-not-found
@echo ....... Deleting Operator .......
- kubectl delete -f deploy/operator.yaml -n ${NAMESPACE} --ignore-not-found
@echo ....... Deleting CRDs .......
- kubectl delete -f deploy/crds/operator.ibm.com_commonservices_crd.yaml --ignore-not-found
@echo ....... Deleting RBAC .......
- kubectl delete -f deploy/role_binding.yaml -n ${NAMESPACE} --ignore-not-found
- kubectl delete -f deploy/service_account.yaml -n ${NAMESPACE} --ignore-not-found
- kubectl delete -f deploy/role.yaml -n ${NAMESPACE} --ignore-not-found
@echo ....... Deleting namespace ${NAMESPACE}.......
- kubectl delete namespace ${NAMESPACE} --ignore-not-found
run: ## Run against the configured Kubernetes cluster in ~/.kube/config
@echo ....... Start Operator locally with go run ......
WATCH_NAMESPACE=${NAMESPACE} go run ./cmd/manager/main.go
code-dev:
go mod tidy
check: code-dev lint-all
CSV_VERSION=$(CSV_VERSION) ./common/scripts/lint-csv.sh
test:
echo good
build: check
CGO_ENABLED=0 go build -o build/_output/bin/$(OPERATOR_NAME) cmd/manager/main.go
@strip build/_output/bin/$(OPERATOR_NAME) || true
build-push-image: build-image push-image
build-image: build
@echo "Building the $(IMAGE_NAME) docker image for $(LOCAL_ARCH)..."
@docker build -t $(QUAY_REPO)/$(IMAGE_NAME)-$(LOCAL_ARCH):$(VERSION) --build-arg VCS_REF=$(VCS_REF) --build-arg VCS_URL=$(VCS_URL) -f build/Dockerfile .
push-image: $(CONFIG_DOCKER_TARGET) build-image
@echo "Pushing the $(IMAGE_NAME) docker image for $(LOCAL_ARCH)..."
@docker push $(QUAY_REPO)/$(IMAGE_NAME)-$(LOCAL_ARCH):$(VERSION)
generate-csv:
operator-sdk generate csv --csv-version $(CSV_VERSION) --update-crds
push-csv:
QUAY_REPO=$(QUAY_REPO) OPERATOR_NAME=$(OPERATOR_NAME) VERSION=$(CSV_VERSION) common/scripts/push-csv.sh
multiarch-image: $(CONFIG_DOCKER_TARGET)
@MAX_PULLING_RETRY=20 RETRY_INTERVAL=30 common/scripts/multiarch_image.sh $(QUAY_REPO) $(IMAGE_NAME) $(VERSION)