-
Notifications
You must be signed in to change notification settings - Fork 52
/
Makefile
443 lines (369 loc) · 18 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
# Copyright 2021 NVIDIA
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Package related
BINARY_NAME=network-operator
PACKAGE=network-operator
ORG_PATH=github.com/Mellanox
REPO_PATH=$(ORG_PATH)/$(PACKAGE)
CHART_PATH=$(CURDIR)/deployment/$(PACKAGE)
TOOLSDIR=$(CURDIR)/hack/tools/bin
MANIFESTDIR=$(CURDIR)/hack/manifests
BUILDDIR=$(CURDIR)/build/_output
GOFILES=$(shell find . -name "*.go" | grep -vE "(\/vendor\/)|(_test.go)")
TESTPKGS=./...
ENVTEST_K8S_VERSION=1.28
ARCH ?= $(shell go env GOARCH)
OS ?= $(shell go env GOOS)
# Version
VERSION?=master
DATE=`date -Iseconds`
COMMIT?=`git rev-parse --verify HEAD`
LDFLAGS="-X github.com/Mellanox/network-operator/version.Version=$(BUILD_VERSION) -X github.com/Mellanox/network-operator/version.Commit=$(COMMIT) -X github.com/Mellanox/network-operator/version.Date=$(DATE)"
GCFLAGS=""
BUILD_VERSION := $(strip $(shell [ -d .git ] && git describe --always --tags --dirty))
BUILD_TIMESTAMP := $(shell date -u +"%Y-%m-%dT%H:%M:%S%Z")
VCS_BRANCH := $(strip $(shell git rev-parse --abbrev-ref HEAD))
VCS_REF := $(strip $(shell [ -d .git ] && git rev-parse --short HEAD))
# Docker
IMAGE_BUILDER?=docker
DOCKERFILE?=$(CURDIR)/Dockerfile
TAG?=mellanox/network-operator
REGISTRY?=docker.io
IMAGE_NAME?=network-operator
CONTROLLER_IMAGE=$(REGISTRY)/$(IMAGE_NAME)
IMAGE_BUILD_OPTS?=
BUNDLE_IMG?=network-operator-bundle:$(VERSION)
BUNDLE_OCP_VERSIONS=v4.14-v4.16
# BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
BUILD_ARCH= amd64 arm64
# USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
# You can enable this value if you would like to use SHA Based Digests
# To enable set flag to true
USE_IMAGE_DIGESTS ?= false
ifeq ($(USE_IMAGE_DIGESTS), true)
BUNDLE_GEN_FLAGS += --use-image-digests
endif
# Accept proxy settings for docker
# To pass proxy for Docker invoke it as 'make image HTTP_POXY=http://192.168.0.1:8080'
DOCKERARGS=
ifdef HTTP_PROXY
DOCKERARGS += --build-arg http_proxy=$(HTTP_PROXY)
endif
ifdef HTTPS_PROXY
DOCKERARGS += --build-arg https_proxy=$(HTTPS_PROXY)
endif
IMAGE_BUILD_OPTS += $(DOCKERARGS)
# timeout for tests, seconds
TIMEOUT = 120
Q = $(if $(filter 1,$V),,@)
## Options for 'bundle-build'
ifneq ($(origin CHANNELS), undefined)
BUNDLE_CHANNELS := --channels=$(CHANNELS)
endif
ifneq ($(origin DEFAULT_CHANNEL), undefined)
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
endif
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
admissionReviewVersions=v1
ifndef ignore-not-found
ignore-not-found = false
endif
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
.PHONY: all
all: lint build
$(TOOLSDIR):
@mkdir -p $@
$(MANIFESTDIR):
@mkdir -p $@
$(BUILDDIR): ; $(info Creating build directory...)
mkdir -p $@
build: generate $(BUILDDIR)/$(BINARY_NAME) ; $(info Building $(BINARY_NAME)...) @ ## Build executable file
$(info Done!)
$(BUILDDIR)/$(BINARY_NAME): $(GOFILES) | $(BUILDDIR)
CGO_ENABLED=0 $(GO) build -o $(BUILDDIR)/$(BINARY_NAME) -tags no_openssl -v -ldflags=$(LDFLAGS)
# Tools
GO = go
# golangci-lint is used to lint go code.
GOLANGCI_LINT_PKG=github.com/golangci/golangci-lint/cmd/golangci-lint
GOLANGCI_LINT_BIN= golangci-lint
GOLANGCI_LINT_VER = v1.61.0
GOLANGCI_LINT = $(TOOLSDIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)
$(GOLANGCI_LINT):
$(call go-install-tool,$(GOLANGCI_LINT_PKG),$(GOLANGCI_LINT_BIN),$(GOLANGCI_LINT_VER))
# controller gen is used to generate manifests and code for Kubernetes controllers.
CONTROLLER_GEN_PKG = sigs.k8s.io/controller-tools/cmd/controller-gen
CONTROLLER_GEN_BIN = controller-gen
CONTROLLER_GEN_VER = v0.16.4
CONTROLLER_GEN = $(TOOLSDIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER)
$(CONTROLLER_GEN):
$(call go-install-tool,$(CONTROLLER_GEN_PKG),$(CONTROLLER_GEN_BIN),$(CONTROLLER_GEN_VER))
# kustomize is used to generate manifests for OpenShift bundles and developer deployments.
KUSTOMIZE_PKG = sigs.k8s.io/kustomize/kustomize/v5
KUSTOMIZE_BIN = kustomize
KUSTOMIZE_VER = v5.5.0
KUSTOMIZE = $(TOOLSDIR)/$(KUSTOMIZE_BIN)-$(KUSTOMIZE_VER)
$(KUSTOMIZE):
$(call go-install-tool,$(KUSTOMIZE_PKG),$(KUSTOMIZE_BIN),$(KUSTOMIZE_VER))
# setup-envtest is used to install test Kubernetes control plane components for envtest-based tests.
SETUP_ENVTEST_PKG := sigs.k8s.io/controller-runtime/tools/setup-envtest
SETUP_ENVTEST_BIN := setup-envtest
SETUP_ENVTEST_VER := v0.0.0-20240110160329-8f8247fdc1c3
SETUP_ENVTEST := $(abspath $(TOOLSDIR)/$(SETUP_ENVTEST_BIN)-$(SETUP_ENVTEST_VER))
$(SETUP_ENVTEST):
$(call go-install-tool,$(SETUP_ENVTEST_PKG),$(SETUP_ENVTEST_BIN),$(SETUP_ENVTEST_VER))
# hadolint is used to lint docker files.
HADOLINT_BIN = hadolint
HADOLINT_VER = v2.12.0
HADOLINT = $(abspath $(TOOLSDIR)/$(HADOLINT_BIN)-$(HADOLINT_VER))
$(HADOLINT): | $(TOOLSDIR)
$Q echo "Installing hadolint-$(HADOLINT_VER) to $(TOOLSDIR)"
$Q curl -sSfL -o $(HADOLINT) https://github.com/hadolint/hadolint/releases/download/$(HADOLINT_VER)/hadolint-Linux-x86_64
$Q chmod +x $(HADOLINT)
# helm is used to manage helm deployments and artifacts.
GET_HELM = $(TOOLSDIR)/get_helm.sh
HELM_VER = v3.13.3
HELM_BIN = helm
HELM = $(abspath $(TOOLSDIR)/$(HELM_BIN)-$(HELM_VER))
$(HELM): | $(TOOLSDIR)
$Q echo "Installing helm-$(HELM_VER) to $(TOOLSDIR)"
$Q curl -fsSL -o $(GET_HELM) https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
$Q chmod +x $(GET_HELM)
$Q env HELM_INSTALL_DIR=$(TOOLSDIR) PATH=$(PATH):$(TOOLSDIR) $(GET_HELM) --no-sudo -v $(HELM_VER)
$Q mv $(TOOLSDIR)/$(HELM_BIN) $(TOOLSDIR)/$(HELM_BIN)-$(HELM_VER)
$Q rm -f $(GET_HELM)
# operator-sdk is used to generate operator-sdk bundles
OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download
OPERATOR_SDK_BIN = operator-sdk
OPERATOR_SDK_VER = v1.33.0
OPERATOR_SDK = $(abspath $(TOOLSDIR)/$(OPERATOR_SDK_BIN)-$(OPERATOR_SDK_VER))
$(OPERATOR_SDK): | $(TOOLSDIR)
$Q echo "Installing $(OPERATOR_SDK_BIN)-$(OPERATOR_SDK_VER) to $(TOOLSDIR)"
$Q curl -sSfL $(OPERATOR_SDK_DL_URL)/$(OPERATOR_SDK_VER)/operator-sdk_$(OS)_$(ARCH) -o $(OPERATOR_SDK)
$Q chmod +x $(OPERATOR_SDK)
# minikube is used to set-up a local kubernetes cluster for dev work.
MINIKUBE_VER := v0.0.0-20231012212722-e25aeebc7846
MINIKUBE_BIN := minikube
MINIKUBE := $(abspath $(TOOLSDIR)/$(MINIKUBE_BIN)-$(MINIKUBE_VER))
$(MINIKUBE): | $(TOOLSDIR)
$Q echo "Installing minikube-$(MINIKUBE_VER) to $(TOOLSDIR)"
$Q curl -fsSL https://storage.googleapis.com/minikube/releases/latest/minikube-$(OS)-$(ARCH) -o $(MINIKUBE)
$Q chmod +x $(MINIKUBE)
# skaffold is used to run a debug build of the network operator for dev work.
SKAFFOLD_VER := v2.10.0
SKAFFOLD_BIN := skaffold
SKAFFOLD := $(abspath $(TOOLSDIR)/$(SKAFFOLD_BIN)-$(SKAFFOLD_VER))
$(SKAFFOLD): | $(TOOLSDIR)
$Q echo "Installing skaffold-$(SKAFFOLD_VER) to $(TOOLSDIR)"
$Q curl -fsSL https://storage.googleapis.com/skaffold/releases/latest/skaffold-$(OS)-$(ARCH) -o $(SKAFFOLD)
$Q chmod +x $(SKAFFOLD)
# mockery is used to generate mocks for unit tests.
MOCKERY_PKG := github.com/vektra/mockery/v2
MOCKERY_VER := v2.43.2
MOCKERY_BIN := mockery
MOCKERY_PATH = $(abspath $(TOOLSDIR)/$(MOCKERY_BIN))
MOCKERY = $(abspath $(TOOLSDIR)/$(MOCKERY_BIN))-$(MOCKERY_VER)
$(MOCKERY): | $(TOOLSDIR)
$(call go-install-tool,$(MOCKERY_PKG),$(MOCKERY_BIN),$(MOCKERY_VER))
$Q ln $(MOCKERY) $(MOCKERY_PATH)
# cert-manager is used for webhook certs in the dev setup.
CERT_MANAGER_YAML=$(MANIFESTDIR)/cert-manager.yaml
CERT_MANAGER_VER=v1.13.3
$(CERT_MANAGER_YAML): | $(MANIFESTDIR)
curl -fSsL "https://github.com/cert-manager/cert-manager/releases/download/$(CERT_MANAGER_VER)/cert-manager.yaml" -o $(CERT_MANAGER_YAML)
# Tests
.PHONY: lint
lint: | $(GOLANGCI_LINT) ; $(info running golangci-lint...) @ ## Run golangci-lint
$Q $(GOLANGCI_LINT) run --timeout=10m
.PHONY: lint-fix
lint-fix: | $(GOLANGCI_LINT) ; $(info running golangci-lint...) @ ## Run golangci-lint and fix findings where possible
$Q $(GOLANGCI_LINT) run --timeout=10m --fix
.PHONY: lint-dockerfile
lint-dockerfile: $(HADOLINT) ; $(info running Dockerfile lint with hadolint...) @ ## Run hadolint
# Ignoring warning DL3029: Do not use --platform flag with FROM
$Q $(HADOLINT) --ignore DL3029 Dockerfile
.PHONY: lint-helm
lint-helm: $(HELM) ; $(info running lint for helm charts...) @ ## Run helm lint
$Q $(HELM) lint $(CHART_PATH)
.PHONY: check-manifests
check-manifests: generate manifests
$(info checking for git diff after running 'make manifests')
git diff --quiet ; if [ $$? -eq 1 ] ; then echo "Please, commit manifests after running 'make manifests' and 'make generate' commands"; exit 1 ; fi
.PHONY: check-go-modules
check-go-modules: generate-go-modules
git diff --quiet HEAD go.sum; if [ $$? -eq 1 ] ; then echo "go.sum is out of date. Please commit after running 'make generate-go-modules' command"; exit 1; fi
.PHONY: generate-go-modules
generate-go-modules:
go mod tidy
.PHONY: check-release-build
check-release-build: release-build
$(info checking for git diff after running 'make release-build')
git diff --quiet ; if [ $$? -eq 1 ] ; then echo "Please, commit templates after running 'make release-build' command"; exit 1 ; fi
TEST_TARGETS := test-default test-bench test-short test-verbose test-race
.PHONY: $(TEST_TARGETS) test-xml check test tests
test-bench: ARGS=-run=__absolutelynothing__ -bench=. ## Run benchmarks
test-short: ARGS=-short ## Run only short tests
test-verbose: ARGS=-v ## Run tests in verbose mode with coverage reporting
test-race: ARGS=-race ## Run tests with race detector
$(TEST_TARGETS): NAME=$(MAKECMDGOALS:test-%=%)
$(TEST_TARGETS): test
check test tests test-xml test-coverage: SHELL:=/bin/bash
.PHONY: setup-envtest
setup-envtest: $(SETUP_ENVTEST) ## Install envtest binaries
@echo KUBEBUILDER_ASSETS=`$(SETUP_ENVTEST) use --use-env -p path $(ENVTEST_K8S_VERSION)`
.PHONY: clean-envtest
clean-envtest: setup-envtest ;## Clean up assets installed by setup-envtest
$Q $(SETUP_ENVTEST) cleanup
check test tests: setup-envtest ; $(info running $(NAME:%=% )tests...) @ ## Run tests
KUBEBUILDER_ASSETS=`$(SETUP_ENVTEST) use --use-env -p path $(ENVTEST_K8S_VERSION)` $(GO) test -timeout $(TIMEOUT)s $(ARGS) $(TESTPKGS)
COVERAGE_MODE = count
.PHONY: test-coverage
test-coverage: COVERAGE_DIR := $(CURDIR)/test
test-coverage: setup-envtest; $(info running coverage tests...) @ ## Run coverage tests
KUBEBUILDER_ASSETS=`$(SETUP_ENVTEST) use --use-env -p path $(ENVTEST_K8S_VERSION)` $(GO) test -covermode=$(COVERAGE_MODE) -coverpkg=./... -coverprofile=network-operator.cover $(TESTPKGS)
.PHONY: generate-mocks
generate-mocks: | $(MOCKERY) ; $(info running mockery...) @ ## Run mockery
$Q PATH=$(TOOLSDIR):$(PATH) go generate ./...
# Container image
.PHONY: image
image: ; $(info Building Docker image...) @ ## Build container image
$Q DOCKER_BUILDKIT=1 $(IMAGE_BUILDER) build --build-arg BUILD_DATE="$(BUILD_TIMESTAMP)" \
--build-arg VERSION="$(BUILD_VERSION)" \
--build-arg VCS_REF="$(VCS_REF)" \
--build-arg VCS_BRANCH="$(VCS_BRANCH)" \
--build-arg LDFLAGS=$(LDFLAGS) \
--build-arg ARCH="$(ARCH)" \
--build-arg GCFLAGS="$(GCFLAGS)" \
-t $(TAG) -f $(DOCKERFILE) $(CURDIR) $(IMAGE_BUILD_OPTS)
image-push:
$(IMAGE_BUILDER) push $(TAG)
# Targets for multi-arch container builds
# The multi arch build flow first builds containers locally with a suffix in the image tag stating the architecture.
# Each of these images is then tagged and pushed to the registry as `$(CONTROLLER_IMAGE):$(VERSION)`.
# A manifest is created linking all of the images together.
# None of the resulting images in the registry have an architecture specific tag or name.
.PHONY: image-build
image-build: ; $(info Building Docker image...) @ ## Build container image
DOCKER_BUILDKIT=1 $(IMAGE_BUILDER) build --build-arg BUILD_DATE="$(BUILD_TIMESTAMP)" \
--build-arg VERSION="$(BUILD_VERSION)" \
--build-arg VCS_REF="$(VCS_REF)" \
--build-arg VCS_BRANCH="$(VCS_BRANCH)" \
--build-arg LDFLAGS=$(LDFLAGS) \
--build-arg ARCH="$(ARCH)" \
--build-arg GCFLAGS="$(GCFLAGS)" \
-t $(CONTROLLER_IMAGE):$(VERSION)-$(ARCH) -f $(DOCKERFILE) $(CURDIR) $(IMAGE_BUILD_OPTS)
image-build-%:
$(MAKE) ARCH=$* image-build
.PHONY: image-build-multiarch
image-build-multiarch: $(addprefix image-build-,$(BUILD_ARCH))
DOCKER_MANIFEST_CREATE_ARGS?="--amend"
image-manifest-for-arch: $(addprefix image-push-for-arch-,$(BUILD_ARCH))
$(IMAGE_BUILDER) manifest create $(DOCKER_MANIFEST_CREATE_ARGS) $(CONTROLLER_IMAGE):$(VERSION) $(shell $(IMAGE_BUILDER) inspect --format='{{index .RepoDigests 0}}' $(CONTROLLER_IMAGE):$(VERSION))
image-push-for-arch-%:
$(IMAGE_BUILDER) tag $(CONTROLLER_IMAGE):$(VERSION)-$(ARCH) $(CONTROLLER_IMAGE):$(VERSION)
$(IMAGE_BUILDER) push $(CONTROLLER_IMAGE):$(VERSION)
image-manifest-for-arch-%:
$(MAKE) ARCH=$* image-manifest-for-arch
.PHONY: image-push-multiarch
image-push-multiarch: $(addprefix image-manifest-for-arch-,$(BUILD_ARCH))
$(IMAGE_BUILDER) manifest push $(CONTROLLER_IMAGE):$(VERSION)
.PHONY: chart-build
chart-build: $(HELM) ; $(info Building Helm image...) @ ## Build Helm Chart
@if [ -z "$(APP_VERSION)" ]; then \
echo "APP_VERSION is not set, skipping a part of the command."; \
$(HELM) package --dependency-update deployment/network-operator/ --version $(VERSION); \
else $(HELM) package --dependency-update deployment/network-operator/ --version $(VERSION) --app-version $(APP_VERSION); \
fi
.PHONY: chart-push
chart-push: $(HELM) ; $(info Pushing Helm image...) @ ## Push Helm Chart
ngc registry chart push $(NGC_REPO):$(VERSION)
# Misc
.PHONY: clean
clean: ; $(info Cleaning...) @ ## Cleanup everything
@rm -rf $(BUILDDIR)
@rm -rf $(TOOLSDIR)
@rm -rf $(MANIFESTDIR)
.PHONY: help
help: ## Show this message
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
run: generate manifests ## Run against the configured Kubernetes cluster in ~/.kube/config
go run ./main.go
install: manifests ## Install CRDs into a cluster
kubectl apply -f config/crd/bases
uninstall: manifests ## Uninstall CRDs from a cluster
sh kubectl delete --ignore-not-found=$(ignore-not-found) -f -
deploy: manifests $(KUSTOMIZE) ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${TAG}
$(KUSTOMIZE) build config/default | kubectl apply -f -
kubectl apply -f hack/crds/*
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/default | kubectl delete -f -
$(KUSTOMIZE) build config/resources-namespace | kubectl delete -f -
kubectl delete -f hack/crds/*
.PHONY: manifests
manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
cp config/crd/bases/* deployment/network-operator/crds/
generate: $(CONTROLLER_GEN) ## Generate code
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
.PHONY: bundle
bundle: $(OPERATOR_SDK) $(KUSTOMIZE) manifests ## Generate bundle manifests and metadata, then validate generated files.
$(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(TAG)
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
git checkout -- config/manager/kustomization.yaml
GO=$(GO) BUNDLE_OCP_VERSIONS=$(BUNDLE_OCP_VERSIONS) TAG=$(TAG) hack/scripts/ocp-bundle-postprocess.sh
$(OPERATOR_SDK) bundle validate ./bundle
.PHONY: bundle-build
bundle-build: ## Build the bundle image.
${IMAGE_BUILDER} build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
.PHONY: bundle-push
bundle-push: ## Push the bundle image.
${IMAGE_BUILDER} push $(BUNDLE_IMG)
.PHONY: release-build
release-build:
yq '.[].version' hack/release.yaml | grep 'latest' && exit 1 || true
cd hack && $(GO) run release.go --templateDir ./templates/samples/ --outputDir ../config/samples/
cd hack && $(GO) run release.go --templateDir ./templates/crs/ --outputDir ../example/crs
cd hack && $(GO) run release.go --templateDir ./templates/values/ --outputDir ../deployment/network-operator/
cd hack && $(GO) run release.go --templateDir ./templates/config/manager --outputDir ../config/manager/
# dev environment
MINIKUBE_CLUSTER_NAME = net-op-dev
dev-minikube: $(MINIKUBE) ## Create a minikube cluster for development.
CLUSTER_NAME=$(MINIKUBE_CLUSTER_NAME) MINIKUBE_BIN=$(MINIKUBE) $(CURDIR)/hack/scripts/minikube-install.sh
clean-minikube: $(MINIKUBE) ## Delete the development minikube cluster.
$(MINIKUBE) delete -p $(MINIKUBE_CLUSTER_NAME)
SKAFFOLD_REGISTRY=localhost:5000
dev-skaffold: $(SKAFFOLD) $(CERT_MANAGER_YAML) manifests generate dev-minikube ## Create a development minikube cluster and deploy the operator in debug mode.
## Deploy the network attachment definition CRD.
kubectl apply -f hack/crds/*
## Deploy cert manager to provide certificates for webhooks.
$Q kubectl apply -f $(CERT_MANAGER_YAML) \
&& echo "Waiting for cert-manager deployment to be ready."\
&& kubectl wait --for=condition=ready pod -l app=webhook --timeout=60s -n cert-manager
# Use minikube for docker build and deployment.
$Q eval $$($(MINIKUBE) -p $(MINIKUBE_CLUSTER_NAME) docker-env); \
$(SKAFFOLD) debug --default-repo=$(SKAFFOLD_REGISTRY) --detect-minikube=false
# go-install-tool will 'go install' a go module $1 with version $3 and install it with the name $2-$3 to $TOOLSDIR.
define go-install-tool
$Q echo "Installing $(2)-$(3) to $(TOOLSDIR)"
$Q GOBIN=$(TOOLSDIR) go install $(1)@$(3)
$Q mv $(TOOLSDIR)/$(2) $(TOOLSDIR)/$(2)-$(3)
endef