-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkube-protect.yaml
334 lines (311 loc) · 6.72 KB
/
kube-protect.yaml
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pvcc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: mysql-pv
spec:
capacity:
storage: 2Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
hostPath:
path: /var/lib/mysql
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: test-python-app-sa-admin-binding
subjects:
- kind: ServiceAccount
name: test-python-app-sa
namespace: default
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
spec:
selector:
matchLabels:
app: mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:5.7
env:
- name: MYSQL_ROOT_PASSWORD
value: "root"
- name: MYSQL_DATABASE
value: "k8s"
- name: MYSQL_USER
value: "uu2fu3o"
- name: MYSQL_PASSWORD
value: "uu2fu3o"
ports:
- containerPort: 3306
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pvcc
---
apiVersion: v1
kind: Service
metadata:
name: mysql
spec:
ports:
- port: 3306
selector:
app: mysql
clusterIP: None
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: python-test
spec:
selector:
matchLabels:
app: python-test
template:
metadata:
labels:
app: python-test
spec:
serviceAccountName: test-python-app-sa
containers:
- name: python-pl
image: uu2fu3o/k8s:latest
env:
- name: DB_HOST
value: "mysql"
- name: DB_USER
value: "uu2fu3o"
- name: DB_PASSWORD
value: "uu2fu3o"
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
securityContext:
privileged: true
volumeMounts:
- name: sys-fs
mountPath: /sys
- name: proc
mountPath: /proc
- name: dev
mountPath: /dev
- name: lib-modules
mountPath: /lib/modules
readOnly: true
- name: usr-src
mountPath: /usr/src
readOnly: true
- name: boot
mountPath: /boot
- name: sys-kernel-debug
mountPath: /sys/kernel/debug
volumes:
- name: sys-fs
hostPath:
path: /sys
- name: proc
hostPath:
path: /proc
- name: dev
hostPath:
path: /dev
- name: lib-modules
hostPath:
path: /lib/modules
- name: usr-src
hostPath:
path: /usr/src
type: Directory
- name: boot
hostPath:
path: /boot
type: Directory
- name: sys-kernel-debug
hostPath:
path: /sys/kernel/debug
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: go-deployment
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: k8sgo
template:
metadata:
labels:
app: k8sgo
spec:
serviceAccountName: test-python-app-sa
containers:
- name: k8sgo
image: uu2fu3o/k8s:002
tolerations:
- key: "node-role.kubernetes.io/master"
operator: "Exists"
effect: "NoSchedule"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: scanner-deployment
spec:
selector:
matchLabels:
app: scanner
replicas: 1
template:
metadata:
labels:
app: scanner
spec:
serviceAccountName: test-python-app-sa
containers:
- name: scanner
image: uu2fu3o/k8s:auto-clair
imagePullPolicy: IfNotPresent
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: clair-combined-deployment
spec:
replicas: 1
selector:
matchLabels:
app: clair-combined
template:
metadata:
labels:
app: clair-combined
spec:
containers:
- name: clair-db
image: arminc/clair-db:latest
env:
- name: POSTGRES_USER
value: "uu2fu3o"
- name: POSTGRES_PASSWORD
value: "uu2fu3o"
ports:
- containerPort: 5432
- name: clair
image: arminc/clair-local-scan:latest
ports:
- containerPort: 6060
env:
- name: PGHOST
value: "localhost" # Clair 在同一个 Pod 中,所以使用 localhost
- name: PGPORT
value: "5432"
- name: POSTGRES_USER
value: "uu2fu3o" # 如果需要,请替换为实际用户
- name: POSTGRES_PASSWORD
value: "uu2fu3o" # 如果需要,请替换为实际密码
---
apiVersion: v1
kind: Service
metadata:
name: clair-service
spec:
type: ClusterIP
ports:
- name: clair
port: 6060
targetPort: 6060
selector:
app: clair-combined
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: flask-app
spec:
replicas: 1
selector:
matchLabels:
app: flask-app
template:
metadata:
labels:
app: flask-app
spec:
containers:
- name: flask-app
image: uu2fu3o/k8s:flask004
ports:
- containerPort: 5000
env:
- name: FLASK_ENV
value: "development"
- name: DATABASE_URL
value: "mysql://uu2fu3o:uu2fu3o@mysql:3306/k8s" # 请根据实际情况填写
---
apiVersion: v1
kind: Service
metadata:
name: flask-service
spec:
type: NodePort
ports:
- port: 5000
targetPort: 5000
nodePort: 30063
selector:
app: flask-app
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 1
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
serviceAccountName: test-python-app-sa
containers:
- name: my-app
image: x00r/k8sss:002
ports:
- containerPort: 8080