-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
88 lines (67 loc) · 2.75 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
# Check to see if we can use ash, in Alpine images, or default to BASH.
SHELL_PATH = /bin/ash
SHELL = $(if $(wildcard $(SHELL_PATH)),/bin/ash,/bin/bash)
run:
go run api/cmd/services/sales/main.go | go run api/cmd/tooling/logfmt/main.go
# ==============================================================================
# Define dependencies
GOLANG := golang:1.22
ALPINE := alpine:3.20
KIND := kindest/node:v1.30.0
POSTGRES := postgres:16.3
GRAFANA := grafana/grafana:10.4.0
PROMETHEUS := prom/prometheus:v2.53.0
TEMPO := grafana/tempo:2.5.0
LOKI := grafana/loki:3.0.0
PROMTAIL := grafana/promtail:3.0.0
VERSION := 0.0.1
KIND_CLUSTER := ardan-starter-cluster
NAMESPACE := sales-system
SALES_APP := sales
AUTH_APP := auth
BASE_IMAGE_NAME := localhost/ardanlabs
VERSION := 0.0.1
SALES_IMAGE := $(BASE_IMAGE_NAME)/$(SALES_APP):$(VERSION)
METRICS_IMAGE := $(BASE_IMAGE_NAME)/metrics:$(VERSION)
AUTH_IMAGE := $(BASE_IMAGE_NAME)/$(AUTH_APP):$(VERSION)
# VERSION := "0.0.1-$(shell git rev-parse --short HEAD)"
# ==============================================================================
# Building containers
build: sales
sales:
docker build \
-f zarf/docker/dockerfile.sales \
-t $(SALES_IMAGE) \
--build-arg BUILD_REF=$(VERSION) \
--build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
.
# ==============================================================================
# Running from within k8s/kind
dev-up:
kind create cluster \
--image $(KIND) \
--name $(KIND_CLUSTER) \
--config zarf/k8s/dev/kind-config.yaml
kubectl wait --timeout=120s --namespace=local-path-storage --for=condition=Available deployment/local-path-provisioner
dev-down:
kind delete cluster --name $(KIND_CLUSTER)
dev-status-all:
kubectl get nodes -o wide
kubectl get svc -o wide
kubectl get pods -o wide --watch --all-namespaces
dev-status:
watch -n 2 kubectl get pods -o wide --all-namespaces
# ------------------------------------------------------------------------------
dev-load:
kind load docker-image $(SALES_IMAGE) --name $(KIND_CLUSTER)
dev-apply:
kustomize build zarf/k8s/dev/sales | kubectl apply -f -
kubectl wait pods --namespace=$(NAMESPACE) --selector app=$(SALES_APP) --timeout=120s --for=condition=Ready
dev-restart:
kubectl rollout restart deployment $(SALES_APP) --namespace=$(NAMESPACE)
dev-update: build dev-load dev-restart
dev-update-apply: build dev-load dev-apply
dev-logs:
kubectl logs --namespace=$(NAMESPACE) -l app=$(SALES_APP) --all-containers=true -f --tail=100 --max-log-requests=6 | go run api/cmd/tooling/logfmt/main.go -service=$(SALES_APP)
dev-describe-sales:
kubectl describe pod --namespace=$(NAMESPACE) -l app=$(SALES_APP)