-
Notifications
You must be signed in to change notification settings - Fork 157
/
Makefile
98 lines (76 loc) · 2.95 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
all: test local-build
# Image URL to use all building/pushing image targets
REPO ?= scylladb/scylla-operator
TAG ?= $(shell ./version.sh)
IMG ?= $(REPO):$(TAG)
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"
.EXPORT_ALL_VARIABLES:
DOCKER_BUILDKIT := 1
GOVERSION := $(shell go version)
GOPATH := $(shell go env GOPATH)
KUBEBUILDER_ASSETS := $(GOPATH)/bin
PATH := $(GOPATH)/bin:$(PATH):
# Default package
PKG := ./pkg/...
# Run tests
test: fmt vet
go test $(PKG) -coverprofile cover.out
integration-test:
go test $(PKG) -tags integration
# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet manifests
go run ./cmd operator --image="$(IMG)" --enable-admission-webhook=false
# Install CRDs into a cluster
install: manifests cert-manager
kustomize build config/operator/crd | kubectl apply -f -
# Uninstall CRDs from a cluster
uninstall: manifests
kustomize build config/operator/crd | kubectl delete -f -
kubectl delete -f examples/common/cert-manager.yaml
cert-manager:
cat config/operator/certmanager/cert-manager.yaml > examples/common/cert-manager.yaml
kubectl apply -f examples/common/cert-manager.yaml
kubectl -n cert-manager wait --for=condition=ready pod -l app=cert-manager --timeout=60s
kubectl -n cert-manager wait --for=condition=ready pod -l app=cainjector --timeout=60s
kubectl -n cert-manager wait --for=condition=ready pod -l app=webhook --timeout=60s
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: manifests cert-manager
kubectl apply -f examples/common/operator.yaml
# Generate manifests e.g. CRD, RBAC etc.
manifests:
cd config/operator/operator && kustomize edit set image controller=${IMG}
controller-gen $(CRD_OPTIONS) paths="$(PKG)" output:crd:dir=config/operator/crd/bases \
rbac:roleName=manager-role output:rbac:artifacts:config=config/operator/rbac \
webhook output:webhook:artifacts:config=config/operator/webhook
controller-gen $(CRD_OPTIONS) paths="./pkg/controllers/manager" rbac:roleName=manager-role output:rbac:artifacts:config=config/manager/rbac
kustomize build config/operator/default > examples/common/operator.yaml
kustomize build config/manager/default > examples/common/manager.yaml
# Run go fmt against code
fmt:
go fmt $(PKG)
# Run go vet against code
vet:
go vet $(PKG)
# Generate code
generate:
controller-gen object:headerFile="hack/boilerplate.go.txt" paths="$(PKG)"
# Build the docker image
.PHONY: docker-build
docker-build:
goreleaser --skip-validate --skip-publish --rm-dist
# Push the docker image
docker-push:
docker push ${IMG}
# Ensure dependencies
.PHONY: vendor
vendor:
go mod vendor
# Build local-build binary
.PHONY: local-build
local-build: fmt vet vendor
CGO_ENABLED=0 go build -trimpath -a -o bin/scylla-operator github.com/scylladb/scylla-operator/pkg/cmd
release:
goreleaser --rm-dist
nightly:
goreleaser --snapshot --rm-dist --config=.goreleaser-nightly.yml