-
Notifications
You must be signed in to change notification settings - Fork 0
/
k8s_template.yml
164 lines (159 loc) · 3.32 KB
/
k8s_template.yml
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
### Ingress Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: ingress
name: ingress
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: ingress
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: ingress
spec:
containers:
### Actual Ingress image
- image: gcr.io/${GOOGLE_PROJECT_ID}/ingress:${CIRCLE_SHA1}
name: ingress
resources:
requests:
cpu: "250m"
### CloudSQL Proxy (db connection)
- name: cloudsql-proxy
image: gcr.io/cloudsql-docker/gce-proxy:1.16
command: ["/cloud_sql_proxy",
"-instances=reflect-backend:us-central1:reflect-db=tcp:3306",
"-credential_file=/secrets/cloudsql/key.json"]
securityContext:
runAsUser: 2
allowPrivilegeEscalation: false
volumeMounts:
- name: cloudsql-instance-credentials
mountPath: /secrets/cloudsql
readOnly: true
volumes:
- name: cloudsql-instance-credentials
secret:
secretName: cloudsql-instance-credentials
- name: cloudsql-db-credentials
secret:
secretName: cloudsql-db-credentials
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
---
### Ingress Service
apiVersion: "v1"
kind: "Service"
metadata:
name: "ingress-service"
namespace: "default"
labels:
app: "ingress"
spec:
ports:
- protocol: "TCP"
port: 80
targetPort: 8080
selector:
app: "ingress"
type: "LoadBalancer"
---
### Ingress HPA
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: "static-ip"
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: ingress
minReplicas: 1
maxReplicas: 3
targetCPUUtilizationPercentage: 80
---
### NLP Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
generation: 1
labels:
app: nlp
name: nlp
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: nlp
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: nlp
spec:
containers:
- image: gcr.io/${GOOGLE_PROJECT_ID}/nlp:${CIRCLE_SHA1}
name: nlp
resources:
requests:
cpu: "250m"
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
---
### NLP Service
apiVersion: v1
kind: Service
metadata:
labels:
app: nlp
name: nlp-service
namespace: default
spec:
externalTrafficPolicy: Cluster
ports:
- nodePort: 32610
port: 30000
protocol: TCP
targetPort: 5000
selector:
app: nlp
sessionAffinity: None
type: NodePort
---
### NLP HPA
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: nlp
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: nlp
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 50