forked from Azure-Samples/pubsub-dapr-aks-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal-deploy.sh
executable file
·69 lines (61 loc) · 1.51 KB
/
local-deploy.sh
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
#!/bin/sh
serviceName="public-api-service"
version=$(date +%Y.%m.%d.%H.%M.%S)
printf "\n🛖 Releasing version: %s\n\n" "${version}"
printf "\n☢️ Attempting to delete existing deployment %s\n\n" "${serviceName}"
kubectl delete deployment "${serviceName}"
printf "\n🏗️ Building docker image\n\n"
docker build -t localhost:5001/"${serviceName}":"${version}" .
printf "\n🚚 Pushing docker image to local registry\n\n"
docker push localhost:5001/"${serviceName}":"${version}"
printf "\n🚀 Deploying to cluster\n\n"
cat <<EOF | kubectl apply -f -
kind: Service
apiVersion: v1
metadata:
name: ${serviceName}
labels:
app: ${serviceName}
spec:
selector:
app: ${serviceName}
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: ${serviceName}
labels:
app: ${serviceName}
spec:
replicas: 1
selector:
matchLabels:
app: ${serviceName}
template:
metadata:
labels:
app: ${serviceName}
annotations:
dapr.io/enabled: "true"
dapr.io/app-id: "${serviceName}"
dapr.io/app-port: "8080"
dapr.io/enable-api-logging: "true"
spec:
containers:
- name: node
image: localhost:5001/${serviceName}:${version}
env:
- name: APP_PORT
value: "8080"
- name: APP_VERSION
value: "${version}"
ports:
- containerPort: 80
imagePullPolicy: Always
EOF
printf "\n🎉 Deployment complete\n\n"