-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkubernetes.ctl
More file actions
207 lines (207 loc) · 4.39 KB
/
kubernetes.ctl
File metadata and controls
207 lines (207 loc) · 4.39 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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# Kubernetes Deployment for FSK HTTP Service
apiVersion: v1
kind: Namespace
metadata:
name: fskhttp
---
apiVersion: v1
kind: ConfigMap
metadata:
name: fskhttp-config
namespace: fskhttp
data:
FLASK_HOST: "0.0.0.0"
FLASK_PORT: "8080"
MAX_WORKERS: "16"
MAX_CONCURRENT_REQUESTS: "50"
REQUEST_TIMEOUT: "30"
LOG_LEVEL: "INFO"
HEALTH_CHECK_ENABLED: "true"
TEMP_FILE_CLEANUP_INTERVAL: "300"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fskhttp-deployment
namespace: fskhttp
labels:
app: fskhttp
version: v2.0.0
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
selector:
matchLabels:
app: fskhttp
template:
metadata:
labels:
app: fskhttp
version: v2.0.0
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "8080"
prometheus.io/path: "/metrics"
spec:
containers:
- name: fskhttp
image: fskhttp:v2.0.0
ports:
- containerPort: 8080
name: http
envFrom:
- configMapRef:
name: fskhttp-config
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: INSTANCE_ID
valueFrom:
fieldRef:
fieldPath: metadata.name
resources:
requests:
memory: "256Mi"
cpu: "250m"
limits:
memory: "1Gi"
cpu: "1000m"
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 30
periodSeconds: 30
timeoutSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
volumeMounts:
- name: tmp-volume
mountPath: /tmp
volumes:
- name: tmp-volume
emptyDir:
sizeLimit: 1Gi
securityContext:
runAsNonRoot: true
runAsUser: 1001
fsGroup: 1001
---
apiVersion: v1
kind: Service
metadata:
name: fskhttp-service
namespace: fskhttp
labels:
app: fskhttp
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "8080"
prometheus.io/path: "/metrics"
spec:
selector:
app: fskhttp
ports:
- name: http
port: 80
targetPort: 8080
protocol: TCP
type: ClusterIP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: fskhttp-ingress
namespace: fskhttp
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/proxy-body-size: "50m"
nginx.ingress.kubernetes.io/proxy-connect-timeout: "60"
nginx.ingress.kubernetes.io/proxy-send-timeout: "60"
nginx.ingress.kubernetes.io/proxy-read-timeout: "60"
nginx.ingress.kubernetes.io/rate-limit-rps: "10"
nginx.ingress.kubernetes.io/rate-limit-connections: "5"
spec:
ingressClassName: nginx
rules:
- host: fskhttp.yourdomain.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: fskhttp-service
port:
number: 80
# tls:
# - hosts:
# - fskhttp.yourdomain.com
# secretName: fskhttp-tls
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: fskhttp-hpa
namespace: fskhttp
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: fskhttp-deployment
minReplicas: 2
maxReplicas: 20
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80
behavior:
scaleUp:
stabilizationWindowSeconds: 60
policies:
- type: Percent
value: 50
periodSeconds: 60
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Percent
value: 25
periodSeconds: 60
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: fskhttp-pdb
namespace: fskhttp
spec:
minAvailable: 1
selector:
matchLabels:
app: fskhttp