-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
117 lines (92 loc) · 3.73 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
# Copyright 2021-2024 Hewlett Packard Enterprise Development LP
# Other additional copyright holders may be indicated within.
#
# The entirety of this work is 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.
# Default container tool to use.
# To use podman:
# $ DOCKER=podman make docker-build
DOCKER ?= docker
IMAGE_TAG_BASE ?= ghcr.io/hewlettpackard/lustre-csi-driver
# Tell Kustomize to deploy the default config, or an overlay.
# To use the 'kind' overlay:
# export KUBECONFIG=/my/kubeconfig.file
# make deploy OVERLAY=overlays/kind
# Or, make kind-deploy
# To deploy the base lustre config:
# make deploy
OVERLAY ?= overlays/kind
all: build
fmt: ## Run go fmt against code.
go fmt ./...
vet: ## Run go vet against code.
go vet ./...
build: VERSION ?= $(shell cat .version)
build: .version fmt vet
go mod vendor
go build -o bin/lustre-csi-driver
run: fmt vet
go run ./main.go
docker-build: VERSION ?= $(shell cat .version)
docker-build: .version Dockerfile fmt vet
time ${DOCKER} build -t $(IMAGE_TAG_BASE):$(VERSION) .
edit-image: VERSION ?= $(shell cat .version)
edit-image: .version ## Replace plugin.yaml image with name "controller" -> ghcr tagged container reference
$(KUSTOMIZE_IMAGE_TAG) deploy/kubernetes/begin $(OVERLAY) $(IMAGE_TAG_BASE) $(VERSION)
kind-push: VERSION ?= $(shell cat .version)
kind-push: .version ## Push image to Kind environment
kind load docker-image $(IMAGE_TAG_BASE):$(VERSION)
deploy_overlay: kustomize edit-image ## Deploy controller to the K8s cluster specified in ~/.kube/config.
./deploy.sh deploy $(KUSTOMIZE) deploy/kubernetes/begin
.PHONY: deploy
deploy: OVERLAY ?= base
deploy: deploy_overlay
kind-deploy: OVERLAY=overlays/kind
kind-deploy: deploy_overlay
undeploy_overlay: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
./deploy.sh undeploy $(KUSTOMIZE) deploy/kubernetes/$(OVERLAY)
undeploy: OVERLAY ?= lustre
undeploy: undeploy_overlay
kind-undeploy: OVERLAY=overlays/kind
kind-undeploy: undeploy_overlay
installer: kustomize edit-image helm-version
helm-version: VERSION ?= $(shell cat .version)
helm-version: .version ## Updates the Helm values.yaml with new version
yq e -i ".deployment.tag=\"$(VERSION)\"" charts/lustre-csi-driver/values.yaml
# Let .version be phony so that a git update to the workarea can be reflected
# in it each time it's needed.
.PHONY: .version
.version: ## Uses the git-version-gen script to generate a tag version
./git-version-gen --fallback `git rev-parse HEAD` > .version
clean:
rm -f .version
.PHONY: clean-bin
clean-bin:
rm -rf $(LOCALBIN)
## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
## Tool Binaries
KUSTOMIZE_IMAGE_TAG ?= ./hack/make-kustomization.sh
KUSTOMIZE ?= $(LOCALBIN)/kustomize
## Tool Versions
KUSTOMIZE_VERSION ?= v5.1.1
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
kustomize: $(LOCALBIN) ## Download kustomize locally if necessary.
if [[ ! -s $(LOCALBIN)/kustomize || ! $$($(LOCALBIN)/kustomize version) =~ $(KUSTOMIZE_VERSION) ]]; then \
rm -f $(LOCALBIN)/kustomize && \
{ curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }; \
fi