omgkit 2.2.0 → 2.3.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/databases/mongodb/SKILL.md +60 -776
- package/plugin/skills/databases/prisma/SKILL.md +53 -744
- package/plugin/skills/databases/redis/SKILL.md +53 -860
- package/plugin/skills/devops/aws/SKILL.md +68 -672
- package/plugin/skills/devops/github-actions/SKILL.md +54 -657
- package/plugin/skills/devops/kubernetes/SKILL.md +67 -602
- package/plugin/skills/devops/performance-profiling/SKILL.md +59 -863
- package/plugin/skills/frameworks/django/SKILL.md +87 -853
- package/plugin/skills/frameworks/express/SKILL.md +95 -1301
- package/plugin/skills/frameworks/fastapi/SKILL.md +90 -1198
- package/plugin/skills/frameworks/laravel/SKILL.md +87 -1187
- package/plugin/skills/frameworks/nestjs/SKILL.md +106 -973
- package/plugin/skills/frameworks/react/SKILL.md +94 -962
- package/plugin/skills/frameworks/vue/SKILL.md +95 -1242
- package/plugin/skills/frontend/accessibility/SKILL.md +91 -1056
- package/plugin/skills/frontend/frontend-design/SKILL.md +69 -1262
- package/plugin/skills/frontend/responsive/SKILL.md +76 -799
- package/plugin/skills/frontend/shadcn-ui/SKILL.md +73 -921
- package/plugin/skills/frontend/tailwindcss/SKILL.md +60 -788
- package/plugin/skills/frontend/threejs/SKILL.md +72 -1266
- package/plugin/skills/languages/javascript/SKILL.md +106 -849
- package/plugin/skills/methodology/brainstorming/SKILL.md +70 -576
- package/plugin/skills/methodology/defense-in-depth/SKILL.md +79 -831
- package/plugin/skills/methodology/dispatching-parallel-agents/SKILL.md +81 -654
- package/plugin/skills/methodology/executing-plans/SKILL.md +86 -529
- package/plugin/skills/methodology/finishing-development-branch/SKILL.md +95 -586
- package/plugin/skills/methodology/problem-solving/SKILL.md +67 -681
- package/plugin/skills/methodology/receiving-code-review/SKILL.md +70 -533
- package/plugin/skills/methodology/requesting-code-review/SKILL.md +70 -610
- package/plugin/skills/methodology/root-cause-tracing/SKILL.md +70 -646
- package/plugin/skills/methodology/sequential-thinking/SKILL.md +70 -478
- package/plugin/skills/methodology/systematic-debugging/SKILL.md +66 -559
- package/plugin/skills/methodology/test-driven-development/SKILL.md +91 -752
- package/plugin/skills/methodology/testing-anti-patterns/SKILL.md +78 -687
- package/plugin/skills/methodology/token-optimization/SKILL.md +72 -602
- package/plugin/skills/methodology/verification-before-completion/SKILL.md +108 -529
- package/plugin/skills/methodology/writing-plans/SKILL.md +79 -566
- package/plugin/skills/omega/omega-architecture/SKILL.md +91 -752
- package/plugin/skills/omega/omega-coding/SKILL.md +161 -552
- package/plugin/skills/omega/omega-sprint/SKILL.md +132 -777
- package/plugin/skills/omega/omega-testing/SKILL.md +157 -845
- package/plugin/skills/omega/omega-thinking/SKILL.md +165 -606
- package/plugin/skills/security/better-auth/SKILL.md +46 -1034
- package/plugin/skills/security/oauth/SKILL.md +80 -934
- package/plugin/skills/security/owasp/SKILL.md +78 -862
- package/plugin/skills/testing/playwright/SKILL.md +77 -700
- package/plugin/skills/testing/pytest/SKILL.md +73 -811
- package/plugin/skills/testing/vitest/SKILL.md +60 -920
- package/plugin/skills/tools/document-processing/SKILL.md +111 -838
- package/plugin/skills/tools/image-processing/SKILL.md +126 -659
- package/plugin/skills/tools/mcp-development/SKILL.md +85 -758
- package/plugin/skills/tools/media-processing/SKILL.md +118 -735
- package/plugin/stdrules/SKILL_STANDARDS.md +490 -0
- package/plugin/skills/SKILL_STANDARDS.md +0 -743
|
@@ -1,55 +1,20 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
description: Kubernetes container orchestration with deployments, services,
|
|
4
|
-
category: devops
|
|
5
|
-
triggers:
|
|
6
|
-
- kubernetes
|
|
7
|
-
- k8s
|
|
8
|
-
- kubectl
|
|
9
|
-
- helm
|
|
10
|
-
- deployment
|
|
11
|
-
- pods
|
|
12
|
-
- container orchestration
|
|
2
|
+
name: Orchestrating with Kubernetes
|
|
3
|
+
description: The agent implements Kubernetes container orchestration with deployments, services, Helm charts, and production patterns. Use when deploying containerized applications, configuring autoscaling, managing secrets, or setting up ingress routing.
|
|
13
4
|
---
|
|
14
5
|
|
|
15
|
-
# Kubernetes
|
|
6
|
+
# Orchestrating with Kubernetes
|
|
16
7
|
|
|
17
|
-
|
|
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
|
|
8
|
+
## Quick Start
|
|
34
9
|
|
|
35
10
|
```yaml
|
|
36
|
-
#
|
|
11
|
+
# deployment.yaml
|
|
37
12
|
apiVersion: apps/v1
|
|
38
13
|
kind: Deployment
|
|
39
14
|
metadata:
|
|
40
15
|
name: api-server
|
|
41
|
-
namespace: production
|
|
42
|
-
labels:
|
|
43
|
-
app: api-server
|
|
44
|
-
version: v1.0.0
|
|
45
16
|
spec:
|
|
46
17
|
replicas: 3
|
|
47
|
-
revisionHistoryLimit: 5
|
|
48
|
-
strategy:
|
|
49
|
-
type: RollingUpdate
|
|
50
|
-
rollingUpdate:
|
|
51
|
-
maxSurge: 1
|
|
52
|
-
maxUnavailable: 0
|
|
53
18
|
selector:
|
|
54
19
|
matchLabels:
|
|
55
20
|
app: api-server
|
|
@@ -57,239 +22,62 @@ spec:
|
|
|
57
22
|
metadata:
|
|
58
23
|
labels:
|
|
59
24
|
app: api-server
|
|
60
|
-
version: v1.0.0
|
|
61
|
-
annotations:
|
|
62
|
-
prometheus.io/scrape: "true"
|
|
63
|
-
prometheus.io/port: "9090"
|
|
64
25
|
spec:
|
|
65
|
-
serviceAccountName: api-server
|
|
66
|
-
securityContext:
|
|
67
|
-
runAsNonRoot: true
|
|
68
|
-
runAsUser: 1000
|
|
69
|
-
fsGroup: 1000
|
|
70
26
|
containers:
|
|
71
|
-
- name: api
|
|
72
|
-
image: ghcr.io/
|
|
73
|
-
imagePullPolicy: IfNotPresent
|
|
27
|
+
- name: api
|
|
28
|
+
image: ghcr.io/org/api:v1.0.0
|
|
74
29
|
ports:
|
|
75
|
-
-
|
|
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
|
|
30
|
+
- containerPort: 3000
|
|
96
31
|
resources:
|
|
97
|
-
requests:
|
|
98
|
-
|
|
99
|
-
memory: "256Mi"
|
|
100
|
-
limits:
|
|
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
|
|
32
|
+
requests: { cpu: "100m", memory: "256Mi" }
|
|
33
|
+
limits: { cpu: "500m", memory: "512Mi" }
|
|
163
34
|
```
|
|
164
35
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
```yaml
|
|
168
|
-
# k8s/service.yaml
|
|
169
|
-
apiVersion: v1
|
|
170
|
-
kind: Service
|
|
171
|
-
metadata:
|
|
172
|
-
name: api-server
|
|
173
|
-
namespace: production
|
|
174
|
-
labels:
|
|
175
|
-
app: api-server
|
|
176
|
-
spec:
|
|
177
|
-
type: ClusterIP
|
|
178
|
-
ports:
|
|
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
|
|
36
|
+
```bash
|
|
37
|
+
kubectl apply -f deployment.yaml
|
|
218
38
|
```
|
|
219
39
|
|
|
220
|
-
|
|
40
|
+
## Features
|
|
221
41
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
}
|
|
42
|
+
| Feature | Description | Guide |
|
|
43
|
+
|---------|-------------|-------|
|
|
44
|
+
| Deployments | Declarative pod management with rollbacks | Define replicas, update strategy, pod template |
|
|
45
|
+
| Services | Internal/external load balancing | ClusterIP for internal, LoadBalancer for external |
|
|
46
|
+
| ConfigMaps/Secrets | Configuration and sensitive data | Mount as volumes or environment variables |
|
|
47
|
+
| Ingress | HTTP routing with TLS termination | Use nginx-ingress or cloud provider ingress |
|
|
48
|
+
| HPA | Horizontal Pod Autoscaler | Scale based on CPU, memory, or custom metrics |
|
|
49
|
+
| Helm | Package manager for K8s applications | Template and version deployments |
|
|
244
50
|
|
|
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"
|
|
51
|
+
## Common Patterns
|
|
257
52
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
kind: ExternalSecret
|
|
262
|
-
metadata:
|
|
263
|
-
name: api-external-secrets
|
|
264
|
-
namespace: production
|
|
53
|
+
### Production Deployment with Probes
|
|
54
|
+
|
|
55
|
+
```yaml
|
|
265
56
|
spec:
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
property: secret
|
|
57
|
+
containers:
|
|
58
|
+
- name: api
|
|
59
|
+
image: ghcr.io/org/api:v1.0.0
|
|
60
|
+
livenessProbe:
|
|
61
|
+
httpGet: { path: /health/live, port: 3000 }
|
|
62
|
+
initialDelaySeconds: 15
|
|
63
|
+
periodSeconds: 20
|
|
64
|
+
readinessProbe:
|
|
65
|
+
httpGet: { path: /health/ready, port: 3000 }
|
|
66
|
+
initialDelaySeconds: 5
|
|
67
|
+
periodSeconds: 10
|
|
68
|
+
env:
|
|
69
|
+
- name: DATABASE_URL
|
|
70
|
+
valueFrom:
|
|
71
|
+
secretKeyRef: { name: app-secrets, key: database-url }
|
|
282
72
|
```
|
|
283
73
|
|
|
284
|
-
###
|
|
74
|
+
### Horizontal Pod Autoscaler
|
|
285
75
|
|
|
286
76
|
```yaml
|
|
287
|
-
# k8s/hpa.yaml
|
|
288
77
|
apiVersion: autoscaling/v2
|
|
289
78
|
kind: HorizontalPodAutoscaler
|
|
290
79
|
metadata:
|
|
291
80
|
name: api-server
|
|
292
|
-
namespace: production
|
|
293
81
|
spec:
|
|
294
82
|
scaleTargetRef:
|
|
295
83
|
apiVersion: apps/v1
|
|
@@ -299,363 +87,40 @@ spec:
|
|
|
299
87
|
maxReplicas: 20
|
|
300
88
|
metrics:
|
|
301
89
|
- 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
|
|
90
|
+
resource: { name: cpu, target: { type: Utilization, averageUtilization: 70 } }
|
|
480
91
|
```
|
|
481
92
|
|
|
482
|
-
###
|
|
93
|
+
### Ingress with TLS
|
|
483
94
|
|
|
484
95
|
```yaml
|
|
485
|
-
# k8s/network-policy.yaml
|
|
486
96
|
apiVersion: networking.k8s.io/v1
|
|
487
|
-
kind:
|
|
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
|
|
97
|
+
kind: Ingress
|
|
588
98
|
metadata:
|
|
589
|
-
name:
|
|
590
|
-
|
|
99
|
+
name: api-ingress
|
|
100
|
+
annotations:
|
|
101
|
+
cert-manager.io/cluster-issuer: letsencrypt-prod
|
|
591
102
|
spec:
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
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
|
|
103
|
+
tls:
|
|
104
|
+
- hosts: [api.example.com]
|
|
105
|
+
secretName: api-tls
|
|
106
|
+
rules:
|
|
107
|
+
- host: api.example.com
|
|
108
|
+
http:
|
|
109
|
+
paths:
|
|
110
|
+
- path: /
|
|
111
|
+
pathType: Prefix
|
|
112
|
+
backend:
|
|
113
|
+
service: { name: api-server, port: { number: 80 } }
|
|
625
114
|
```
|
|
626
115
|
|
|
627
116
|
## Best Practices
|
|
628
117
|
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
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/)
|
|
118
|
+
| Do | Avoid |
|
|
119
|
+
|----|-------|
|
|
120
|
+
| Set resource requests and limits | Running containers as root |
|
|
121
|
+
| Implement liveness and readiness probes | Using `latest` tag in production |
|
|
122
|
+
| Use namespaces for environment isolation | Hardcoding config in container images |
|
|
123
|
+
| Configure Pod Disruption Budgets | Skipping network policies |
|
|
124
|
+
| Use Secrets for sensitive data | Exposing unnecessary ports |
|
|
125
|
+
| Implement pod anti-affinity rules | Using NodePort in production |
|
|
126
|
+
| Set up HPA for autoscaling | Ignoring pod security standards |
|