-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·108 lines (93 loc) · 2.72 KB
/
deploy.sh
File metadata and controls
executable file
·108 lines (93 loc) · 2.72 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# Service names
PRODUCT_SERVICE="product-service"
ORDER_SERVICE="order-service"
USER_SERVICE="user-service"
APP_STACK="app-stack"
# Docker image tag
TAG="latest"
# Kubernetes context (for kind)
KUBE_CONTEXT="kind-kind"
# Create kind cluster
create_kind_cluster() {
echo "Creating a kind cluster..."
kind create cluster --name kind --wait 60s
kubectl cluster-info --context $KUBE_CONTEXT
}
# Build Docker images and load them into kind cluster
build_and_load_images() {
echo "Building Docker images and loading into kind..."
# Build Product Service Docker image
cd $PRODUCT_SERVICE
docker build -t $PRODUCT_SERVICE:$TAG .
kind load docker-image $PRODUCT_SERVICE:$TAG --name kind
cd ..
# Build Order Service Docker image
cd $ORDER_SERVICE
docker build -t $ORDER_SERVICE:$TAG .
kind load docker-image $ORDER_SERVICE:$TAG --name kind
cd ..
# Build User Service Docker image
cd $USER_SERVICE
docker build -t $USER_SERVICE:$TAG .
kind load docker-image $USER_SERVICE:$TAG --name kind
cd ..
}
# Deploy Product Service using Helm
deploy_product_service() {
echo "Deploying Product Service..."
helm upgrade -i $PRODUCT_SERVICE ./helm-charts/product-service \
--namespace product-service \
--set image.repository=$PRODUCT_SERVICE \
--set image.tag=$TAG \
--set database.enabled=true \
--create-namespace
}
# Deploy Order Service using Helm
deploy_order_service() {
echo "Deploying Order Service..."
helm upgrade -i $ORDER_SERVICE ./helm-charts/order-service \
--namespace order-service \
--set image.repository=$ORDER_SERVICE \
--set image.tag=$TAG \
--set database.enabled=true \
--create-namespace
}
# Deploy User Service using Helm
deploy_user_service() {
echo "Deploying User Service..."
helm upgrade -i $USER_SERVICE ./helm-charts/user-service \
--namespace user-service \
--set image.repository=$USER_SERVICE \
--set image.tag=$TAG \
--set database.enabled=true \
--create-namespace
}
# Deploy All Service using Helm
deploy_all_services() {
echo "Deploying All Services..."
helm upgrade -i $APP_STACK ./helm-charts/all-services \
--namespace all-services \
--set user-service.image.repository=$USER_SERVICE \
--set order-service.image.repository=$ORDER_SERVICE \
--set product-service.image.repository=$PRODUCT_SERVICE \
--set global.image.tag=$TAG \
--create-namespace
}
# Update all chart deps in case charts were changed
update_chart_deps(){
echo "Updating chart deps..."
./helm_charts/update.sh
}
# Main deployment process
main() {
create_kind_cluster
build_and_load_images
update_chart_deps
deploy_product_service
deploy_order_service
deploy_user_service
deploy_all_services
}
# Execute main function
main