-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (57 loc) · 2.44 KB
/
Makefile
File metadata and controls
70 lines (57 loc) · 2.44 KB
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
REPOSITORY ?= deployment-tracker
TAG ?= latest
IMG := $(REPOSITORY):$(TAG)
CLUSTER = kind
.PHONY: run-local
run-local: cluster-delete cluster build docker kind-load-image echo deploy
.PHONY: build
build:
go build -o deployment-tracker cmd/deployment-tracker/main.go
.PHONY: docker
docker:
docker build --platform linux/arm64 -t ${IMG} .
.PHONY: kind-load-image
kind-load-image:
kind load docker-image ${IMG} --name ${CLUSTER}
.PHONY: deploy
deploy:
@echo "Deploying deployment-tracker to cluster..."
kubectl apply -f deploy/manifest.yaml
@echo "Deployment complete. Waiting for deployment to be ready..."
kubectl rollout status deployment/deployment-tracker -n deployment-tracker --timeout=60s
fmt:
go fmt ./...
test:
go test ./...
integration-test:
KUBEBUILDER_ASSETS=$$(setup-envtest use -p path) go test -tags integration_test ./...
test-short:
go test -short ./...
.PHONY: cluster
cluster:
@echo "Creating kind cluster: ${CLUSTER}"
kind create cluster --name ${CLUSTER}
@echo "Creating namespaces..."
kubectl create namespace test1 --dry-run=client -o yaml | kubectl apply -f -
kubectl create namespace test2 --dry-run=client -o yaml | kubectl apply -f -
kubectl create namespace test3 --dry-run=client -o yaml | kubectl apply -f -
@echo "Kind cluster '${CLUSTER}' created with namespaces: test1, test2, test3"
.PHONY: cluster-delete
cluster-delete:
@echo "Deleting kind cluster: ${CLUSTER}"
kind delete cluster --name ${CLUSTER}
# adds an echo server to the cluster that deployment tracker can point to to simulate 200 response
.PHONY: echo
echo:
@echo "Deploying echo server to artifact-registry namespace..."
kubectl create namespace artifact-registry --dry-run=client -o yaml | kubectl apply -f -
kubectl run artifact-registry --image=ealen/echo-server:latest --port=80 -n artifact-registry --restart=Always --labels="app=artifact-registry"
kubectl expose pod artifact-registry --port=9090 --target-port=80 --name=artifact-registry -n artifact-registry --type=ClusterIP
@echo "Echo server deployed and reachable at http://artifact-registry.artifact-registry.svc.cluster.local:9090"
.PHONY: echo-delete
echo-delete:
@echo "Deleting echo server from artifact-registry namespace..."
kubectl delete service artifact-registry -n artifact-registry --ignore-not-found=true
kubectl delete pod artifact-registry -n artifact-registry --ignore-not-found=true
kubectl delete namespace artifact-registry --ignore-not-found=true
@echo "Echo server deleted"