-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
89 lines (76 loc) · 2.92 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
# Makefile for building the webhook project
BINARY_NAME := webhook
OUTPUT_DIR := bin
IMAGE_NAME := webhook:latest
NAMESPACE := default
CLUSTER_NAME ?= operator-controller
SCRIPTS_DIR := scripts
CONFIG_DIR := config
CERTS_DIR := $(CONFIG_DIR)/certs
.PHONY: all build deps test clean make-cert deploy undeploy deploy-openai deploy-local-llm
all: build
build: deps
mkdir -p $(OUTPUT_DIR)
go build -o $(OUTPUT_DIR)/$(BINARY_NAME) cmd/main.go
deps:
go mod tidy
test:
go test -v ./...
clean:
rm -rf $(OUTPUT_DIR)
make-cert:
@echo "Generating TLS certificates..."
./$(SCRIPTS_DIR)/generate-certs.sh
# Default deploy target: OpenAI
deploy: deploy-openai
# Deploy with OpenAI API
deploy-openai: build make-cert
@echo "Building Docker image..."
docker build -t $(IMAGE_NAME) .
@echo "Loading Docker image into Kind cluster..."
kind load docker-image $(IMAGE_NAME) --name ${CLUSTER_NAME}
@echo "Generating OpenAI API Key secret..."
./$(SCRIPTS_DIR)/generate-openai-secret.sh
@echo "Applying Kubernetes manifests for OpenAI..."
kubectl apply -f $(CERTS_DIR)/webhook-certs.yaml
kubectl apply -f $(CONFIG_DIR)/openai-api-key.yaml
kubectl apply -f $(CONFIG_DIR)/deployment.yaml
kubectl apply -f $(CONFIG_DIR)/service.yaml
@echo "Configuring MutatingWebhookConfiguration for OpenAI..."
./$(SCRIPTS_DIR)/generate-mutatingwebhookconfiguration.sh
kubectl apply -f $(CONFIG_DIR)/mutatingwebhookconfiguration.yaml
kubectl apply -f config/rbac/serviceaccount.yaml
kubectl apply -f config/rbac/clusterrole.yaml
kubectl apply -f config/rbac/clusterrolebinding.yaml
rm -f ca.crt
@echo "Deployment with OpenAI complete."
# Deploy with Local LLM
deploy-local-llm: build make-cert
@echo "Building Docker image..."
docker build -t $(IMAGE_NAME) .
@echo "Loading Docker image into Kind cluster..."
kind load docker-image $(IMAGE_NAME) --name ${CLUSTER_NAME}
@echo "Applying Kubernetes manifests for Local LLM..."
kubectl apply -f $(CERTS_DIR)/webhook-certs.yaml
kubectl apply -f $(CONFIG_DIR)/deployment-llm.yaml
kubectl apply -f $(CONFIG_DIR)/service.yaml
@echo "Configuring MutatingWebhookConfiguration for Local LLM..."
./$(SCRIPTS_DIR)/generate-mutatingwebhookconfiguration.sh
kubectl apply -f $(CONFIG_DIR)/mutatingwebhookconfiguration.yaml
kubectl apply -f config/rbac/serviceaccount.yaml
kubectl apply -f config/rbac/clusterrole.yaml
kubectl apply -f config/rbac/clusterrolebinding.yaml
rm -f ca.crt
@echo "Deployment with Local LLM complete."
undeploy:
@echo "Deleting Kubernetes resources..."
-kubectl delete -f $(CONFIG_DIR)/mutatingwebhookconfiguration.yaml
-kubectl delete -f $(CONFIG_DIR)/deployment.yaml
-kubectl delete -f $(CONFIG_DIR)/deployment-llm.yaml
-kubectl delete -f $(CONFIG_DIR)/service.yaml
-kubectl delete secret webhook-certs
-kubectl delete secret openai-api-key
rm -f $(CONFIG_DIR)/mutatingwebhookconfiguration.yaml
rm -f $(CONFIG_DIR)/openai-api-key.yaml
rm -f $(CERTS_DIR)/webhook-certs.yaml
@echo "Undeployment complete."