-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
99 lines (80 loc) · 3.65 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
VERSION ?= $(shell cat VERSION)
IMAGE_REGISTRY ?= ghcr.io/raft-tech/konfirm
IMAGE ?= $(IMAGE_REGISTRY)/controller
IMAGE_VERSION = $(IMAGE):$(VERSION)
E2E_IMAGE ?= $(IMAGE_REGISTRY)/controller-e2e
E2E_IMAGE_VERSION ?= $(E2E_IMAGE):$(VERSION)
MOCK_IMAGE ?= $(IMAGE_REGISTRY)/mock-inspection
MOCK_IMAGE_VERSION ?= $(MOCK_IMAGE):$(VERSION)
ENVTEST ?= $(BIN)/setup-envtest
ENVTEST_K8S_VERSION = 1.30.0
KUBECTL ?= kubectl
KUBE_PROMETHEUS_STACK_CHART ?= https://github.com/prometheus-community/helm-charts/releases/download/kube-prometheus-stack-62.3.1/kube-prometheus-stack-62.3.1.tgz
.PHONY: generate
generate:
go generate ./...
.PHONY: test
test: generate vet envtest
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(BIN) -p path)" \
go test -v ./... -ginkgo.label-filter="!e2e && !broken"
.PHONY: clean
clean: clean-kind-cluster
[ ! -d $(BIN) ] || rm -rf $(BIN)
.PHONY: vet
KONFIRM_CHART_VERSION=$(shell helm inspect chart charts/konfirm |grep appVersion |cut -d ' ' -f 2)
MOCKS_CHART_VERSION=$(shell helm inspect chart charts/mock-inspection |grep appVersion |cut -d ' ' -f 2)
vet: helm-lint
go vet ./...
[ "$(VERSION)" = "$(KONFIRM_CHART_VERSION)" ]
[ "$(VERSION)" = "$(MOCKS_CHART_VERSION)" ]
.PHONY: build
build: generate
go build -o bin/konfirm main.go
.PHONY: docker-build
docker-build:
docker build -t $(IMAGE) -t $(IMAGE_VERSION) .
.PHONY: docker-build-e2e
docker-build-e2e:
docker build -f docker/e2e.dockerfile -t $(E2E_IMAGE) -t $(E2E_IMAGE_VERSION) .
.PHONY: docker-build-mock
docker-build-mock:
docker build -f docker/mock.dockerfile -t $(MOCK_IMAGE) -t $(MOCK_IMAGE_VERSION) .
BIN ?= $(shell pwd)/bin
$(BIN):
mkdir -p $(BIN)
.PHONY: envtest
envtest: $(ENVTEST)
$(ENVTEST): $(BIN)
[ -f $(BIN)/setup-envtest ] || GOBIN=$(BIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
.PHONY: helm-lint
helm-lint:
helm lint charts/konfirm
helm lint charts/konfirm/charts/konfirm-validate
helm lint charts/mock-inspection
.PHONY: kind-cluster
kind-cluster:
[ -n "$$(kind get clusters | grep konfirm)" ] || kind create cluster --name konfirm
kubectl config use-context kind-konfirm
kubectl config set contexts.kind-konfirm.namespace "konfirm-system"
.PHONY: clean-kind-cluster
clean-kind-cluster:
[ -z $$(kind get clusters | grep konfirm) ] || kind delete cluster --name konfirm
.PHONY: kind-load
kind-load: kind-cluster docker-build docker-build-e2e docker-build-mock
kind load docker-image --name konfirm $(IMAGE) $(IMAGE_VERSION) $(E2E_IMAGE) $(E2E_IMAGE_VERSION) $(MOCK_IMAGE) $(MOCK_IMAGE_VERSION)
.PHONY: kind-deploy
kind-deploy: kind-load kind-monitoring
helm upgrade --install --create-namespace --namespace konfirm-system konfirm charts/konfirm --set monitoring.enabled=true
.PHONY: kind-deploy-mock
kind-deploy-mock:
helm upgrade -n konfirm-inspections --create-namespace --install mocks charts/mock-inspection
.PHONY: kind-monitoring
kind-monitoring: kind-cluster
helm -n monitoring get notes monitoring > /dev/null || \
helm upgrade --install -n monitoring --create-namespace monitoring $(KUBE_PROMETHEUS_STACK_CHART) \
--set prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues=false,prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false
.PHONY: demo
demo: kind-deploy kind-deploy-mock
kubectl -n monitoring wait --for=jsonpath='{.status.readyReplicas}'=1 deploy/monitoring-grafana
@echo "\nOpen http://localhost:8080/d/fb649f81aa874446bd67280970df879d/konfirm-inspections?orgId=1&refresh=1m in your browser.\nThe username is 'admin' and the password is 'prom-operator'.\nWhen finished, used ctrl+C here to finish the demo."
@kubectl -n monitoring port-forward svc/monitoring-grafana 8080:80 > /dev/null