-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_undeploy.sh
More file actions
executable file
·37 lines (30 loc) · 985 Bytes
/
deploy_undeploy.sh
File metadata and controls
executable file
·37 lines (30 loc) · 985 Bytes
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
#!/bin/bash
function deploy_app() {
# Build the Docker image
docker buildx build --platform linux/amd64 -t bggapi --target runtime .
# Tag the Docker image
docker tag bggapi:latest gcr.io/bggapi/bggapi:latest
# Push the Docker image to Google Container Registry
docker push gcr.io/bggapi/bggapi:latest
# Apply Kubernetes deployment and service YAML files
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
}
function undeploy_app() {
# Delete Kubernetes deployment and service
kubectl delete -f deployment.yaml
kubectl delete -f service.yaml
# Optionally, you can also delete the Docker image from the registry
# docker rmi gcr.io/bggapi/bggapi:latest
}
# Check if the user wants to deploy or undeploy
if [ "$1" == "deploy" ]; then
deploy_app
echo "Application deployed successfully."
elif [ "$1" == "undeploy" ]; then
undeploy_app
echo "Application undeployed successfully."
else
echo "Usage: $0 [deploy|undeploy]"
exit 1
fi