omgkit 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugin/skills/SKILL_STANDARDS.md +743 -0
- package/plugin/skills/databases/mongodb/SKILL.md +797 -28
- package/plugin/skills/databases/postgresql/SKILL.md +494 -18
- package/plugin/skills/databases/prisma/SKILL.md +776 -30
- package/plugin/skills/databases/redis/SKILL.md +885 -25
- package/plugin/skills/devops/aws/SKILL.md +686 -28
- package/plugin/skills/devops/docker/SKILL.md +466 -18
- package/plugin/skills/devops/github-actions/SKILL.md +684 -29
- package/plugin/skills/devops/kubernetes/SKILL.md +621 -24
- package/plugin/skills/frameworks/django/SKILL.md +920 -20
- package/plugin/skills/frameworks/express/SKILL.md +1361 -35
- package/plugin/skills/frameworks/fastapi/SKILL.md +1260 -33
- package/plugin/skills/frameworks/laravel/SKILL.md +1244 -31
- package/plugin/skills/frameworks/nestjs/SKILL.md +1005 -26
- package/plugin/skills/frameworks/nextjs/SKILL.md +407 -44
- package/plugin/skills/frameworks/rails/SKILL.md +594 -28
- package/plugin/skills/frameworks/react/SKILL.md +1006 -32
- package/plugin/skills/frameworks/spring/SKILL.md +528 -35
- package/plugin/skills/frameworks/vue/SKILL.md +1296 -27
- package/plugin/skills/frontend/accessibility/SKILL.md +1108 -34
- package/plugin/skills/frontend/frontend-design/SKILL.md +1304 -26
- package/plugin/skills/frontend/responsive/SKILL.md +847 -21
- package/plugin/skills/frontend/shadcn-ui/SKILL.md +976 -38
- package/plugin/skills/frontend/tailwindcss/SKILL.md +831 -35
- package/plugin/skills/frontend/threejs/SKILL.md +1298 -29
- package/plugin/skills/languages/javascript/SKILL.md +935 -31
- package/plugin/skills/languages/python/SKILL.md +489 -25
- package/plugin/skills/languages/typescript/SKILL.md +379 -30
- package/plugin/skills/methodology/brainstorming/SKILL.md +597 -23
- package/plugin/skills/methodology/defense-in-depth/SKILL.md +832 -34
- package/plugin/skills/methodology/dispatching-parallel-agents/SKILL.md +665 -31
- package/plugin/skills/methodology/executing-plans/SKILL.md +556 -24
- package/plugin/skills/methodology/finishing-development-branch/SKILL.md +595 -25
- package/plugin/skills/methodology/problem-solving/SKILL.md +429 -61
- package/plugin/skills/methodology/receiving-code-review/SKILL.md +536 -24
- package/plugin/skills/methodology/requesting-code-review/SKILL.md +632 -21
- package/plugin/skills/methodology/root-cause-tracing/SKILL.md +641 -30
- package/plugin/skills/methodology/sequential-thinking/SKILL.md +262 -3
- package/plugin/skills/methodology/systematic-debugging/SKILL.md +571 -32
- package/plugin/skills/methodology/test-driven-development/SKILL.md +779 -24
- package/plugin/skills/methodology/testing-anti-patterns/SKILL.md +691 -29
- package/plugin/skills/methodology/token-optimization/SKILL.md +598 -29
- package/plugin/skills/methodology/verification-before-completion/SKILL.md +543 -22
- package/plugin/skills/methodology/writing-plans/SKILL.md +590 -18
- package/plugin/skills/omega/omega-architecture/SKILL.md +838 -39
- package/plugin/skills/omega/omega-coding/SKILL.md +636 -39
- package/plugin/skills/omega/omega-sprint/SKILL.md +855 -48
- package/plugin/skills/omega/omega-testing/SKILL.md +940 -41
- package/plugin/skills/omega/omega-thinking/SKILL.md +703 -50
- package/plugin/skills/security/better-auth/SKILL.md +1065 -28
- package/plugin/skills/security/oauth/SKILL.md +968 -31
- package/plugin/skills/security/owasp/SKILL.md +894 -33
- package/plugin/skills/testing/playwright/SKILL.md +764 -38
- package/plugin/skills/testing/pytest/SKILL.md +873 -36
- package/plugin/skills/testing/vitest/SKILL.md +980 -35
|
@@ -1,64 +1,661 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: kubernetes
|
|
3
|
-
description: Kubernetes orchestration
|
|
3
|
+
description: Kubernetes container orchestration with deployments, services, ConfigMaps, Helm, and production patterns
|
|
4
|
+
category: devops
|
|
5
|
+
triggers:
|
|
6
|
+
- kubernetes
|
|
7
|
+
- k8s
|
|
8
|
+
- kubectl
|
|
9
|
+
- helm
|
|
10
|
+
- deployment
|
|
11
|
+
- pods
|
|
12
|
+
- container orchestration
|
|
4
13
|
---
|
|
5
14
|
|
|
6
|
-
# Kubernetes
|
|
15
|
+
# Kubernetes
|
|
16
|
+
|
|
17
|
+
Enterprise-grade **Kubernetes container orchestration** following industry best practices. This skill covers deployments, services, ConfigMaps, secrets, Helm charts, ingress, and production-ready patterns used by top engineering teams.
|
|
18
|
+
|
|
19
|
+
## Purpose
|
|
20
|
+
|
|
21
|
+
Deploy and manage containerized applications at scale:
|
|
22
|
+
|
|
23
|
+
- Configure deployments with proper resource limits
|
|
24
|
+
- Expose services with load balancing
|
|
25
|
+
- Manage configuration with ConfigMaps and Secrets
|
|
26
|
+
- Implement health checks and probes
|
|
27
|
+
- Package applications with Helm
|
|
28
|
+
- Configure ingress and networking
|
|
29
|
+
- Implement autoscaling strategies
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
### 1. Deployment Configuration
|
|
7
34
|
|
|
8
|
-
## Deployment
|
|
9
35
|
```yaml
|
|
36
|
+
# k8s/deployment.yaml
|
|
10
37
|
apiVersion: apps/v1
|
|
11
38
|
kind: Deployment
|
|
12
39
|
metadata:
|
|
13
|
-
name:
|
|
40
|
+
name: api-server
|
|
41
|
+
namespace: production
|
|
42
|
+
labels:
|
|
43
|
+
app: api-server
|
|
44
|
+
version: v1.0.0
|
|
14
45
|
spec:
|
|
15
46
|
replicas: 3
|
|
47
|
+
revisionHistoryLimit: 5
|
|
48
|
+
strategy:
|
|
49
|
+
type: RollingUpdate
|
|
50
|
+
rollingUpdate:
|
|
51
|
+
maxSurge: 1
|
|
52
|
+
maxUnavailable: 0
|
|
16
53
|
selector:
|
|
17
54
|
matchLabels:
|
|
18
|
-
app:
|
|
55
|
+
app: api-server
|
|
19
56
|
template:
|
|
20
57
|
metadata:
|
|
21
58
|
labels:
|
|
22
|
-
app:
|
|
59
|
+
app: api-server
|
|
60
|
+
version: v1.0.0
|
|
61
|
+
annotations:
|
|
62
|
+
prometheus.io/scrape: "true"
|
|
63
|
+
prometheus.io/port: "9090"
|
|
23
64
|
spec:
|
|
65
|
+
serviceAccountName: api-server
|
|
66
|
+
securityContext:
|
|
67
|
+
runAsNonRoot: true
|
|
68
|
+
runAsUser: 1000
|
|
69
|
+
fsGroup: 1000
|
|
24
70
|
containers:
|
|
25
|
-
- name:
|
|
26
|
-
image:
|
|
71
|
+
- name: api-server
|
|
72
|
+
image: ghcr.io/company/api-server:v1.0.0
|
|
73
|
+
imagePullPolicy: IfNotPresent
|
|
27
74
|
ports:
|
|
28
|
-
-
|
|
75
|
+
- name: http
|
|
76
|
+
containerPort: 3000
|
|
77
|
+
protocol: TCP
|
|
78
|
+
- name: metrics
|
|
79
|
+
containerPort: 9090
|
|
80
|
+
protocol: TCP
|
|
81
|
+
env:
|
|
82
|
+
- name: NODE_ENV
|
|
83
|
+
value: "production"
|
|
84
|
+
- name: PORT
|
|
85
|
+
value: "3000"
|
|
86
|
+
- name: DATABASE_URL
|
|
87
|
+
valueFrom:
|
|
88
|
+
secretKeyRef:
|
|
89
|
+
name: api-secrets
|
|
90
|
+
key: database-url
|
|
91
|
+
- name: REDIS_URL
|
|
92
|
+
valueFrom:
|
|
93
|
+
configMapKeyRef:
|
|
94
|
+
name: api-config
|
|
95
|
+
key: redis-url
|
|
29
96
|
resources:
|
|
30
|
-
|
|
97
|
+
requests:
|
|
98
|
+
cpu: "100m"
|
|
31
99
|
memory: "256Mi"
|
|
100
|
+
limits:
|
|
32
101
|
cpu: "500m"
|
|
102
|
+
memory: "512Mi"
|
|
103
|
+
livenessProbe:
|
|
104
|
+
httpGet:
|
|
105
|
+
path: /health/live
|
|
106
|
+
port: http
|
|
107
|
+
initialDelaySeconds: 15
|
|
108
|
+
periodSeconds: 20
|
|
109
|
+
timeoutSeconds: 5
|
|
110
|
+
failureThreshold: 3
|
|
111
|
+
readinessProbe:
|
|
112
|
+
httpGet:
|
|
113
|
+
path: /health/ready
|
|
114
|
+
port: http
|
|
115
|
+
initialDelaySeconds: 5
|
|
116
|
+
periodSeconds: 10
|
|
117
|
+
timeoutSeconds: 3
|
|
118
|
+
failureThreshold: 3
|
|
119
|
+
startupProbe:
|
|
120
|
+
httpGet:
|
|
121
|
+
path: /health/live
|
|
122
|
+
port: http
|
|
123
|
+
initialDelaySeconds: 10
|
|
124
|
+
periodSeconds: 5
|
|
125
|
+
failureThreshold: 30
|
|
126
|
+
volumeMounts:
|
|
127
|
+
- name: config-volume
|
|
128
|
+
mountPath: /app/config
|
|
129
|
+
readOnly: true
|
|
130
|
+
- name: tmp
|
|
131
|
+
mountPath: /tmp
|
|
132
|
+
securityContext:
|
|
133
|
+
allowPrivilegeEscalation: false
|
|
134
|
+
readOnlyRootFilesystem: true
|
|
135
|
+
capabilities:
|
|
136
|
+
drop:
|
|
137
|
+
- ALL
|
|
138
|
+
volumes:
|
|
139
|
+
- name: config-volume
|
|
140
|
+
configMap:
|
|
141
|
+
name: api-config
|
|
142
|
+
- name: tmp
|
|
143
|
+
emptyDir: {}
|
|
144
|
+
affinity:
|
|
145
|
+
podAntiAffinity:
|
|
146
|
+
preferredDuringSchedulingIgnoredDuringExecution:
|
|
147
|
+
- weight: 100
|
|
148
|
+
podAffinityTerm:
|
|
149
|
+
labelSelector:
|
|
150
|
+
matchExpressions:
|
|
151
|
+
- key: app
|
|
152
|
+
operator: In
|
|
153
|
+
values:
|
|
154
|
+
- api-server
|
|
155
|
+
topologyKey: kubernetes.io/hostname
|
|
156
|
+
topologySpreadConstraints:
|
|
157
|
+
- maxSkew: 1
|
|
158
|
+
topologyKey: topology.kubernetes.io/zone
|
|
159
|
+
whenUnsatisfiable: DoNotSchedule
|
|
160
|
+
labelSelector:
|
|
161
|
+
matchLabels:
|
|
162
|
+
app: api-server
|
|
33
163
|
```
|
|
34
164
|
|
|
35
|
-
|
|
165
|
+
### 2. Service and Ingress
|
|
166
|
+
|
|
36
167
|
```yaml
|
|
168
|
+
# k8s/service.yaml
|
|
37
169
|
apiVersion: v1
|
|
38
170
|
kind: Service
|
|
39
171
|
metadata:
|
|
40
|
-
name:
|
|
172
|
+
name: api-server
|
|
173
|
+
namespace: production
|
|
174
|
+
labels:
|
|
175
|
+
app: api-server
|
|
41
176
|
spec:
|
|
42
|
-
|
|
43
|
-
app: myapp
|
|
177
|
+
type: ClusterIP
|
|
44
178
|
ports:
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
|
|
179
|
+
- name: http
|
|
180
|
+
port: 80
|
|
181
|
+
targetPort: http
|
|
182
|
+
protocol: TCP
|
|
183
|
+
selector:
|
|
184
|
+
app: api-server
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
# k8s/ingress.yaml
|
|
188
|
+
apiVersion: networking.k8s.io/v1
|
|
189
|
+
kind: Ingress
|
|
190
|
+
metadata:
|
|
191
|
+
name: api-server
|
|
192
|
+
namespace: production
|
|
193
|
+
annotations:
|
|
194
|
+
kubernetes.io/ingress.class: nginx
|
|
195
|
+
nginx.ingress.kubernetes.io/ssl-redirect: "true"
|
|
196
|
+
nginx.ingress.kubernetes.io/proxy-body-size: "10m"
|
|
197
|
+
nginx.ingress.kubernetes.io/proxy-read-timeout: "60"
|
|
198
|
+
nginx.ingress.kubernetes.io/proxy-send-timeout: "60"
|
|
199
|
+
cert-manager.io/cluster-issuer: letsencrypt-prod
|
|
200
|
+
nginx.ingress.kubernetes.io/rate-limit: "100"
|
|
201
|
+
nginx.ingress.kubernetes.io/rate-limit-window: "1m"
|
|
202
|
+
spec:
|
|
203
|
+
tls:
|
|
204
|
+
- hosts:
|
|
205
|
+
- api.example.com
|
|
206
|
+
secretName: api-tls-secret
|
|
207
|
+
rules:
|
|
208
|
+
- host: api.example.com
|
|
209
|
+
http:
|
|
210
|
+
paths:
|
|
211
|
+
- path: /
|
|
212
|
+
pathType: Prefix
|
|
213
|
+
backend:
|
|
214
|
+
service:
|
|
215
|
+
name: api-server
|
|
216
|
+
port:
|
|
217
|
+
name: http
|
|
48
218
|
```
|
|
49
219
|
|
|
50
|
-
|
|
220
|
+
### 3. ConfigMaps and Secrets
|
|
221
|
+
|
|
51
222
|
```yaml
|
|
223
|
+
# k8s/configmap.yaml
|
|
52
224
|
apiVersion: v1
|
|
53
225
|
kind: ConfigMap
|
|
54
226
|
metadata:
|
|
55
|
-
name:
|
|
227
|
+
name: api-config
|
|
228
|
+
namespace: production
|
|
56
229
|
data:
|
|
57
|
-
|
|
230
|
+
redis-url: "redis://redis-master:6379"
|
|
231
|
+
log-level: "info"
|
|
232
|
+
cors-origins: "https://example.com,https://www.example.com"
|
|
233
|
+
config.json: |
|
|
234
|
+
{
|
|
235
|
+
"features": {
|
|
236
|
+
"newDashboard": true,
|
|
237
|
+
"analytics": true
|
|
238
|
+
},
|
|
239
|
+
"limits": {
|
|
240
|
+
"maxUploadSize": 10485760,
|
|
241
|
+
"maxRequestsPerMinute": 100
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
# k8s/secret.yaml
|
|
247
|
+
apiVersion: v1
|
|
248
|
+
kind: Secret
|
|
249
|
+
metadata:
|
|
250
|
+
name: api-secrets
|
|
251
|
+
namespace: production
|
|
252
|
+
type: Opaque
|
|
253
|
+
stringData:
|
|
254
|
+
database-url: "postgresql://user:password@postgres:5432/db"
|
|
255
|
+
jwt-secret: "your-super-secret-jwt-key"
|
|
256
|
+
api-key: "your-api-key"
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
# External Secrets (with External Secrets Operator)
|
|
260
|
+
apiVersion: external-secrets.io/v1beta1
|
|
261
|
+
kind: ExternalSecret
|
|
262
|
+
metadata:
|
|
263
|
+
name: api-external-secrets
|
|
264
|
+
namespace: production
|
|
265
|
+
spec:
|
|
266
|
+
refreshInterval: 1h
|
|
267
|
+
secretStoreRef:
|
|
268
|
+
kind: ClusterSecretStore
|
|
269
|
+
name: aws-secrets-manager
|
|
270
|
+
target:
|
|
271
|
+
name: api-secrets
|
|
272
|
+
creationPolicy: Owner
|
|
273
|
+
data:
|
|
274
|
+
- secretKey: database-url
|
|
275
|
+
remoteRef:
|
|
276
|
+
key: production/api/database
|
|
277
|
+
property: url
|
|
278
|
+
- secretKey: jwt-secret
|
|
279
|
+
remoteRef:
|
|
280
|
+
key: production/api/jwt
|
|
281
|
+
property: secret
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### 4. Horizontal Pod Autoscaler
|
|
285
|
+
|
|
286
|
+
```yaml
|
|
287
|
+
# k8s/hpa.yaml
|
|
288
|
+
apiVersion: autoscaling/v2
|
|
289
|
+
kind: HorizontalPodAutoscaler
|
|
290
|
+
metadata:
|
|
291
|
+
name: api-server
|
|
292
|
+
namespace: production
|
|
293
|
+
spec:
|
|
294
|
+
scaleTargetRef:
|
|
295
|
+
apiVersion: apps/v1
|
|
296
|
+
kind: Deployment
|
|
297
|
+
name: api-server
|
|
298
|
+
minReplicas: 3
|
|
299
|
+
maxReplicas: 20
|
|
300
|
+
metrics:
|
|
301
|
+
- type: Resource
|
|
302
|
+
resource:
|
|
303
|
+
name: cpu
|
|
304
|
+
target:
|
|
305
|
+
type: Utilization
|
|
306
|
+
averageUtilization: 70
|
|
307
|
+
- type: Resource
|
|
308
|
+
resource:
|
|
309
|
+
name: memory
|
|
310
|
+
target:
|
|
311
|
+
type: Utilization
|
|
312
|
+
averageUtilization: 80
|
|
313
|
+
- type: Pods
|
|
314
|
+
pods:
|
|
315
|
+
metric:
|
|
316
|
+
name: http_requests_per_second
|
|
317
|
+
target:
|
|
318
|
+
type: AverageValue
|
|
319
|
+
averageValue: "1000"
|
|
320
|
+
behavior:
|
|
321
|
+
scaleDown:
|
|
322
|
+
stabilizationWindowSeconds: 300
|
|
323
|
+
policies:
|
|
324
|
+
- type: Percent
|
|
325
|
+
value: 10
|
|
326
|
+
periodSeconds: 60
|
|
327
|
+
scaleUp:
|
|
328
|
+
stabilizationWindowSeconds: 0
|
|
329
|
+
policies:
|
|
330
|
+
- type: Percent
|
|
331
|
+
value: 100
|
|
332
|
+
periodSeconds: 15
|
|
333
|
+
- type: Pods
|
|
334
|
+
value: 4
|
|
335
|
+
periodSeconds: 15
|
|
336
|
+
selectPolicy: Max
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
# Vertical Pod Autoscaler
|
|
340
|
+
apiVersion: autoscaling.k8s.io/v1
|
|
341
|
+
kind: VerticalPodAutoscaler
|
|
342
|
+
metadata:
|
|
343
|
+
name: api-server-vpa
|
|
344
|
+
namespace: production
|
|
345
|
+
spec:
|
|
346
|
+
targetRef:
|
|
347
|
+
apiVersion: apps/v1
|
|
348
|
+
kind: Deployment
|
|
349
|
+
name: api-server
|
|
350
|
+
updatePolicy:
|
|
351
|
+
updateMode: "Auto"
|
|
352
|
+
resourcePolicy:
|
|
353
|
+
containerPolicies:
|
|
354
|
+
- containerName: api-server
|
|
355
|
+
minAllowed:
|
|
356
|
+
cpu: "100m"
|
|
357
|
+
memory: "256Mi"
|
|
358
|
+
maxAllowed:
|
|
359
|
+
cpu: "2"
|
|
360
|
+
memory: "2Gi"
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### 5. Helm Chart Structure
|
|
364
|
+
|
|
365
|
+
```yaml
|
|
366
|
+
# charts/api-server/Chart.yaml
|
|
367
|
+
apiVersion: v2
|
|
368
|
+
name: api-server
|
|
369
|
+
description: API Server Helm chart
|
|
370
|
+
type: application
|
|
371
|
+
version: 1.0.0
|
|
372
|
+
appVersion: "1.0.0"
|
|
373
|
+
dependencies:
|
|
374
|
+
- name: redis
|
|
375
|
+
version: "17.x.x"
|
|
376
|
+
repository: https://charts.bitnami.com/bitnami
|
|
377
|
+
condition: redis.enabled
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
# charts/api-server/values.yaml
|
|
381
|
+
replicaCount: 3
|
|
382
|
+
|
|
383
|
+
image:
|
|
384
|
+
repository: ghcr.io/company/api-server
|
|
385
|
+
tag: ""
|
|
386
|
+
pullPolicy: IfNotPresent
|
|
387
|
+
|
|
388
|
+
service:
|
|
389
|
+
type: ClusterIP
|
|
390
|
+
port: 80
|
|
391
|
+
|
|
392
|
+
ingress:
|
|
393
|
+
enabled: true
|
|
394
|
+
className: nginx
|
|
395
|
+
annotations:
|
|
396
|
+
cert-manager.io/cluster-issuer: letsencrypt-prod
|
|
397
|
+
hosts:
|
|
398
|
+
- host: api.example.com
|
|
399
|
+
paths:
|
|
400
|
+
- path: /
|
|
401
|
+
pathType: Prefix
|
|
402
|
+
tls:
|
|
403
|
+
- secretName: api-tls
|
|
404
|
+
hosts:
|
|
405
|
+
- api.example.com
|
|
406
|
+
|
|
407
|
+
resources:
|
|
408
|
+
requests:
|
|
409
|
+
cpu: 100m
|
|
410
|
+
memory: 256Mi
|
|
411
|
+
limits:
|
|
412
|
+
cpu: 500m
|
|
413
|
+
memory: 512Mi
|
|
414
|
+
|
|
415
|
+
autoscaling:
|
|
416
|
+
enabled: true
|
|
417
|
+
minReplicas: 3
|
|
418
|
+
maxReplicas: 20
|
|
419
|
+
targetCPUUtilizationPercentage: 70
|
|
420
|
+
|
|
421
|
+
env:
|
|
422
|
+
NODE_ENV: production
|
|
423
|
+
LOG_LEVEL: info
|
|
424
|
+
|
|
425
|
+
secrets:
|
|
426
|
+
databaseUrl: ""
|
|
427
|
+
jwtSecret: ""
|
|
428
|
+
|
|
429
|
+
redis:
|
|
430
|
+
enabled: true
|
|
431
|
+
architecture: standalone
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
# charts/api-server/templates/deployment.yaml
|
|
435
|
+
apiVersion: apps/v1
|
|
436
|
+
kind: Deployment
|
|
437
|
+
metadata:
|
|
438
|
+
name: {{ include "api-server.fullname" . }}
|
|
439
|
+
labels:
|
|
440
|
+
{{- include "api-server.labels" . | nindent 4 }}
|
|
441
|
+
spec:
|
|
442
|
+
{{- if not .Values.autoscaling.enabled }}
|
|
443
|
+
replicas: {{ .Values.replicaCount }}
|
|
444
|
+
{{- end }}
|
|
445
|
+
selector:
|
|
446
|
+
matchLabels:
|
|
447
|
+
{{- include "api-server.selectorLabels" . | nindent 6 }}
|
|
448
|
+
template:
|
|
449
|
+
metadata:
|
|
450
|
+
labels:
|
|
451
|
+
{{- include "api-server.selectorLabels" . | nindent 8 }}
|
|
452
|
+
spec:
|
|
453
|
+
containers:
|
|
454
|
+
- name: {{ .Chart.Name }}
|
|
455
|
+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
|
456
|
+
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
|
457
|
+
ports:
|
|
458
|
+
- name: http
|
|
459
|
+
containerPort: 3000
|
|
460
|
+
env:
|
|
461
|
+
{{- range $key, $value := .Values.env }}
|
|
462
|
+
- name: {{ $key }}
|
|
463
|
+
value: {{ $value | quote }}
|
|
464
|
+
{{- end }}
|
|
465
|
+
- name: DATABASE_URL
|
|
466
|
+
valueFrom:
|
|
467
|
+
secretKeyRef:
|
|
468
|
+
name: {{ include "api-server.fullname" . }}-secrets
|
|
469
|
+
key: database-url
|
|
470
|
+
resources:
|
|
471
|
+
{{- toYaml .Values.resources | nindent 12 }}
|
|
472
|
+
livenessProbe:
|
|
473
|
+
httpGet:
|
|
474
|
+
path: /health/live
|
|
475
|
+
port: http
|
|
476
|
+
readinessProbe:
|
|
477
|
+
httpGet:
|
|
478
|
+
path: /health/ready
|
|
479
|
+
port: http
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
### 6. Network Policies
|
|
483
|
+
|
|
484
|
+
```yaml
|
|
485
|
+
# k8s/network-policy.yaml
|
|
486
|
+
apiVersion: networking.k8s.io/v1
|
|
487
|
+
kind: NetworkPolicy
|
|
488
|
+
metadata:
|
|
489
|
+
name: api-server-network-policy
|
|
490
|
+
namespace: production
|
|
491
|
+
spec:
|
|
492
|
+
podSelector:
|
|
493
|
+
matchLabels:
|
|
494
|
+
app: api-server
|
|
495
|
+
policyTypes:
|
|
496
|
+
- Ingress
|
|
497
|
+
- Egress
|
|
498
|
+
ingress:
|
|
499
|
+
- from:
|
|
500
|
+
- namespaceSelector:
|
|
501
|
+
matchLabels:
|
|
502
|
+
name: ingress-nginx
|
|
503
|
+
- podSelector:
|
|
504
|
+
matchLabels:
|
|
505
|
+
app: frontend
|
|
506
|
+
ports:
|
|
507
|
+
- protocol: TCP
|
|
508
|
+
port: 3000
|
|
509
|
+
egress:
|
|
510
|
+
- to:
|
|
511
|
+
- podSelector:
|
|
512
|
+
matchLabels:
|
|
513
|
+
app: postgres
|
|
514
|
+
ports:
|
|
515
|
+
- protocol: TCP
|
|
516
|
+
port: 5432
|
|
517
|
+
- to:
|
|
518
|
+
- podSelector:
|
|
519
|
+
matchLabels:
|
|
520
|
+
app: redis
|
|
521
|
+
ports:
|
|
522
|
+
- protocol: TCP
|
|
523
|
+
port: 6379
|
|
524
|
+
- to:
|
|
525
|
+
- namespaceSelector: {}
|
|
526
|
+
podSelector:
|
|
527
|
+
matchLabels:
|
|
528
|
+
k8s-app: kube-dns
|
|
529
|
+
ports:
|
|
530
|
+
- protocol: UDP
|
|
531
|
+
port: 53
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
### 7. Pod Disruption Budget
|
|
535
|
+
|
|
536
|
+
```yaml
|
|
537
|
+
# k8s/pdb.yaml
|
|
538
|
+
apiVersion: policy/v1
|
|
539
|
+
kind: PodDisruptionBudget
|
|
540
|
+
metadata:
|
|
541
|
+
name: api-server-pdb
|
|
542
|
+
namespace: production
|
|
543
|
+
spec:
|
|
544
|
+
minAvailable: 2
|
|
545
|
+
selector:
|
|
546
|
+
matchLabels:
|
|
547
|
+
app: api-server
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
## Use Cases
|
|
551
|
+
|
|
552
|
+
### CronJob for Scheduled Tasks
|
|
553
|
+
|
|
554
|
+
```yaml
|
|
555
|
+
# k8s/cronjob.yaml
|
|
556
|
+
apiVersion: batch/v1
|
|
557
|
+
kind: CronJob
|
|
558
|
+
metadata:
|
|
559
|
+
name: cleanup-job
|
|
560
|
+
namespace: production
|
|
561
|
+
spec:
|
|
562
|
+
schedule: "0 2 * * *"
|
|
563
|
+
concurrencyPolicy: Forbid
|
|
564
|
+
successfulJobsHistoryLimit: 3
|
|
565
|
+
failedJobsHistoryLimit: 3
|
|
566
|
+
jobTemplate:
|
|
567
|
+
spec:
|
|
568
|
+
template:
|
|
569
|
+
spec:
|
|
570
|
+
containers:
|
|
571
|
+
- name: cleanup
|
|
572
|
+
image: ghcr.io/company/cleanup:latest
|
|
573
|
+
env:
|
|
574
|
+
- name: DATABASE_URL
|
|
575
|
+
valueFrom:
|
|
576
|
+
secretKeyRef:
|
|
577
|
+
name: api-secrets
|
|
578
|
+
key: database-url
|
|
579
|
+
restartPolicy: OnFailure
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
### StatefulSet for Databases
|
|
583
|
+
|
|
584
|
+
```yaml
|
|
585
|
+
# k8s/statefulset.yaml
|
|
586
|
+
apiVersion: apps/v1
|
|
587
|
+
kind: StatefulSet
|
|
588
|
+
metadata:
|
|
589
|
+
name: postgres
|
|
590
|
+
namespace: production
|
|
591
|
+
spec:
|
|
592
|
+
serviceName: postgres
|
|
593
|
+
replicas: 3
|
|
594
|
+
selector:
|
|
595
|
+
matchLabels:
|
|
596
|
+
app: postgres
|
|
597
|
+
template:
|
|
598
|
+
metadata:
|
|
599
|
+
labels:
|
|
600
|
+
app: postgres
|
|
601
|
+
spec:
|
|
602
|
+
containers:
|
|
603
|
+
- name: postgres
|
|
604
|
+
image: postgres:15
|
|
605
|
+
ports:
|
|
606
|
+
- containerPort: 5432
|
|
607
|
+
env:
|
|
608
|
+
- name: POSTGRES_PASSWORD
|
|
609
|
+
valueFrom:
|
|
610
|
+
secretKeyRef:
|
|
611
|
+
name: postgres-secrets
|
|
612
|
+
key: password
|
|
613
|
+
volumeMounts:
|
|
614
|
+
- name: data
|
|
615
|
+
mountPath: /var/lib/postgresql/data
|
|
616
|
+
volumeClaimTemplates:
|
|
617
|
+
- metadata:
|
|
618
|
+
name: data
|
|
619
|
+
spec:
|
|
620
|
+
accessModes: ["ReadWriteOnce"]
|
|
621
|
+
storageClassName: fast-ssd
|
|
622
|
+
resources:
|
|
623
|
+
requests:
|
|
624
|
+
storage: 100Gi
|
|
58
625
|
```
|
|
59
626
|
|
|
60
627
|
## Best Practices
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
- Use
|
|
628
|
+
|
|
629
|
+
### Do's
|
|
630
|
+
|
|
631
|
+
- Use namespaces for environment isolation
|
|
632
|
+
- Set resource requests and limits
|
|
633
|
+
- Implement health probes (liveness, readiness, startup)
|
|
634
|
+
- Use ConfigMaps for configuration
|
|
635
|
+
- Use Secrets for sensitive data
|
|
636
|
+
- Implement pod anti-affinity rules
|
|
637
|
+
- Use Network Policies for security
|
|
638
|
+
- Set up Pod Disruption Budgets
|
|
639
|
+
- Use Horizontal Pod Autoscaler
|
|
640
|
+
- Implement proper logging and monitoring
|
|
641
|
+
|
|
642
|
+
### Don'ts
|
|
643
|
+
|
|
644
|
+
- Don't run containers as root
|
|
645
|
+
- Don't hardcode configuration in images
|
|
646
|
+
- Don't skip resource limits
|
|
647
|
+
- Don't ignore health probes
|
|
648
|
+
- Don't use latest tag in production
|
|
649
|
+
- Don't expose unnecessary ports
|
|
650
|
+
- Don't skip network policies
|
|
651
|
+
- Don't ignore pod security standards
|
|
652
|
+
- Don't use NodePort in production
|
|
653
|
+
- Don't skip backup strategies
|
|
654
|
+
|
|
655
|
+
## References
|
|
656
|
+
|
|
657
|
+
- [Kubernetes Documentation](https://kubernetes.io/docs/)
|
|
658
|
+
- [Helm Documentation](https://helm.sh/docs/)
|
|
659
|
+
- [Kubernetes Patterns](https://k8spatterns.io/)
|
|
660
|
+
- [CNCF Best Practices](https://www.cncf.io/blog/)
|
|
661
|
+
- [Kubernetes Security](https://kubernetes.io/docs/concepts/security/)
|