forked from openshift/elasticsearch-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
171 lines (135 loc) · 5.36 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
CURPATH=$(PWD)
export GOBIN=$(CURDIR)/bin
export PATH:=$(GOBIN):$(PATH)
include .bingo/Variables.mk
export GOROOT=$(shell go env GOROOT)
export GOFLAGS=-mod=vendor
export GO111MODULE=on
export OCP_VERSION=4.6
export APP_NAME=elasticsearch-operator
IMAGE_TAG?=127.0.0.1:5000/openshift/origin-$(APP_NAME):latest
APP_REPO=github.com/openshift/$(APP_NAME)
KUBECONFIG?=$(HOME)/.kube/config
MAIN_PKG=cmd/manager/main.go
RUN_LOG?=elasticsearch-operator.log
RUN_PID?=elasticsearch-operator.pid
LOGGING_IMAGE_STREAM?=stable
OPERATOR_NAMESPACE=openshift-operators-redhat
DEPLOYMENT_NAMESPACE=openshift-logging
REPLICAS?=0
OS_NAME=$(shell uname -s | tr '[:upper:]' '[:lower:]')
.PHONY: all build clean fmt generate gobindir run test-e2e test-unit
all: build
gobindir:
@mkdir -p $(GOBIN)
GEN_TIMESTAMP=.zz_generate_timestamp
generate: $(GEN_TIMESTAMP) $(OPERATOR_SDK)
$(GEN_TIMESTAMP): $(shell find pkg/apis -name '*.go')
@./hack/generate-crd.sh
@$(MAKE) fmt
@touch $@
regenerate: $(OPERATOR_SDK)
@rm -f $(GEN_TIMESTAMP)
@$(MAKE) generate
build: fmt
@go build -o $(GOBIN)/elasticsearch-operator $(MAIN_PKG)
clean:
@rm -rf bin tmp _output
go clean -cache -testcache ./...
fmt:
@gofmt -s -l -w $(shell find pkg cmd test -name '*.go')
lint: $(GOLANGCI_LINT) fmt
@$(GOLANGCI_LINT) run -c golangci.yaml
image:
@if [ $${SKIP_BUILD:-false} = false ] ; then \
podman build -t $(IMAGE_TAG) . ; \
fi
test-unit:
@go test ./pkg/... ./cmd/...
deploy: deploy-image
LOCAL_IMAGE_ELASTICSEARCH_OPERATOR_REGISTRY=127.0.0.1:5000/openshift/elasticsearch-operator-registry \
$(MAKE) elasticsearch-catalog-build && \
IMAGE_ELASTICSEARCH_OPERATOR_REGISTRY=image-registry.openshift-image-registry.svc:5000/openshift/elasticsearch-operator-registry \
IMAGE_ELASTICSEARCH_OPERATOR=image-registry.openshift-image-registry.svc:5000/openshift/origin-elasticsearch-operator:latest \
$(MAKE) elasticsearch-catalog-deploy && \
IMAGE_ELASTICSEARCH_OPERATOR=image-registry.openshift-image-registry.svc:5000/openshift/origin-elasticsearch-operator:latest \
$(MAKE) elasticsearch-operator-install
.PHONY: deploy
deploy-image: image
IMAGE_TAG=$(IMAGE_TAG) hack/deploy-image.sh
.PHONY: deploy-image
deploy-example: deploy deploy-example-secret
@oc create -n $(DEPLOYMENT_NAMESPACE) -f hack/cr.yaml
.PHONY: deploy-example
deploy-example-secret: gen-example-certs
hack/deploy-example-secrets.sh $(DEPLOYMENT_NAMESPACE)
.PHONY: deploy-example-secret
gen-example-certs:
@rm -rf /tmp/example-secrets ||: \
mkdir /tmp/example-secrets && \
hack/cert_generation.sh /tmp/example-secrets $(DEPLOYMENT_NAMESPACE) elasticsearch
.PHONY: gen-example-certs
run: deploy deploy-example
@ALERTS_FILE_PATH=files/prometheus_alerts.yml \
RULES_FILE_PATH=files/prometheus_rules.yml \
OPERATOR_NAME=elasticsearch-operator WATCH_NAMESPACE=$(DEPLOYMENT_NAMESPACE) \
KUBERNETES_CONFIG=/etc/origin/master/admin.kubeconfig \
go run ${MAIN_PKG} > $(RUN_LOG) 2>&1 & echo $$! > $(RUN_PID)
run-local:
@ALERTS_FILE_PATH=files/prometheus_alerts.yml \
RULES_FILE_PATH=files/prometheus_rules.yml \
OPERATOR_NAME=elasticsearch-operator WATCH_NAMESPACE=$(DEPLOYMENT_NAMESPACE) \
KUBERNETES_CONFIG=$(KUBECONFIG) \
go run ${MAIN_PKG} LOG_LEVEL=debug
.PHONY: run-local
scale-cvo:
@oc -n openshift-cluster-version scale deployment/cluster-version-operator --replicas=$(REPLICAS)
.PHONY: scale-cvo
scale-olm:
@oc -n openshift-operator-lifecycle-manager scale deployment/olm-operator --replicas=$(REPLICAS)
.PHONY: scale-olm
uninstall:
$(MAKE) elasticsearch-catalog-uninstall
.PHONY: uninstall
MANIFEST_VERSION?="4.6"
generate-bundle: regenerate $(OPM)
mkdir -p bundle; \
$(OPM) alpha bundle generate --directory manifests/${MANIFEST_VERSION} --package elasticsearch-operator --channels ${MANIFEST_VERSION} --default ${MANIFEST_VERSION} --output-dir bundle/; \
find bundle/manifests/ -type f ! \( -name "elasticsearch-operator*.yaml" -o -name "*crd.yaml" \) -delete && \
$(OPERATOR_SDK) bundle validate --verbose bundle
.PHONY: generate-bundle
# to use these targets, ensure the following env vars are set:
# either each IMAGE env var:
# IMAGE_ELASTICSEARCH_OPERATOR_REGISTRY
# IMAGE_ELASTICSEARCH_OPERATOR
# IMAGE_ELASTICSEARCH6
# IMAGE_ELASTICSEARCH_PROXY
# IMAGE_LOGGING_KIBANA6
# IMAGE_OAUTH_PROXY
# or the image format:
# IMAGE_FORMAT
#
# You must also set:
# ELASTICSEARCH_OPERATOR_NAMESPACE (Default: openshift-operators-redhat)
RANDOM_SUFFIX:=$(shell echo $$RANDOM)
TEST_NAMESPACE?="e2e-test-${RANDOM_SUFFIX}"
test-e2e-olm: DEPLOYMENT_NAMESPACE="${TEST_NAMESPACE}"
test-e2e-olm:
TEST_NAMESPACE=${TEST_NAMESPACE} hack/test-e2e-olm.sh
elasticsearch-catalog: elasticsearch-catalog-build elasticsearch-catalog-deploy
elasticsearch-cleanup: elasticsearch-operator-uninstall elasticsearch-catalog-uninstall
# builds an operator-registry image containing the elasticsearch operator
elasticsearch-catalog-build:
olm_deploy/scripts/catalog-build.sh
# deploys the operator registry image and creates a catalogsource referencing it
elasticsearch-catalog-deploy:
olm_deploy/scripts/catalog-deploy.sh
# deletes the catalogsource and catalog namespace
elasticsearch-catalog-uninstall:
olm_deploy/scripts/catalog-uninstall.sh
# installs the elasticsearch operator from the deployed operator-registry/catalogsource.
elasticsearch-operator-install:
olm_deploy/scripts/operator-install.sh
# uninstalls the elasticsearch operator
elasticsearch-operator-uninstall:
olm_deploy/scripts/operator-uninstall.sh