-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (72 loc) · 2.09 KB
/
Makefile
File metadata and controls
89 lines (72 loc) · 2.09 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Makefile for cert-manager-webhook-etcd
IMAGE_NAME ?= cert-manager-webhook-etcd
IMAGE_TAG ?= latest
REGISTRY ?=
.PHONY: all build test docker-build docker-push deploy clean
all: build
# Build the Go binary
build:
CGO_ENABLED=1 go build -o bin/webhook -ldflags="-w -s" .
# Run tests
test:
go test -v ./...
# Download dependencies
deps:
go mod download
go mod tidy
# Build Docker image
docker-build:
docker build -t $(IMAGE_NAME):$(IMAGE_TAG) .
# Push Docker image
docker-push:
ifdef REGISTRY
docker tag $(IMAGE_NAME):$(IMAGE_TAG) $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)
docker push $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)
else
docker push $(IMAGE_NAME):$(IMAGE_TAG)
endif
# Deploy to Kubernetes using Helm
deploy:
helm upgrade --install cert-manager-webhook-etcd \
./charts/cert-manager-webhook-etcd \
--namespace cert-manager \
--create-namespace
# Deploy using kubectl
deploy-manifests:
kubectl apply -f deploy/rbac.yaml
kubectl apply -f deploy/deployment.yaml
kubectl apply -f deploy/apiservice.yaml
# Undeploy from Kubernetes
undeploy:
helm uninstall cert-manager-webhook-etcd --namespace cert-manager || true
# Clean build artifacts
clean:
rm -rf bin/
go clean
# Lint the code
lint:
golangci-lint run ./...
# Format the code
fmt:
go fmt ./...
# Generate go.sum
generate-sum:
go mod tidy
# Local development - run the webhook locally
run-local:
go run . --tls-cert-file=./testdata/tls.crt --tls-private-key-file=./testdata/tls.key --secure-port=8443
# Help target
help:
@echo "Available targets:"
@echo " build - Build the Go binary"
@echo " test - Run tests"
@echo " deps - Download dependencies"
@echo " docker-build - Build Docker image"
@echo " docker-push - Push Docker image to registry"
@echo " deploy - Deploy to Kubernetes using Helm"
@echo " deploy-manifests - Deploy using kubectl manifests"
@echo " undeploy - Undeploy from Kubernetes"
@echo " clean - Clean build artifacts"
@echo " lint - Lint the code"
@echo " fmt - Format the code"
@echo " help - Show this help message"