@corbat-tech/coding-standards-mcp 1.0.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/LICENSE +21 -0
- package/README.md +371 -0
- package/assets/demo.gif +0 -0
- package/dist/agent.d.ts +53 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +629 -0
- package/dist/agent.js.map +1 -0
- package/dist/cli/init.d.ts +3 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +651 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/config.d.ts +73 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +105 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/profiles.d.ts +39 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +526 -0
- package/dist/profiles.js.map +1 -0
- package/dist/prompts-legacy.d.ts +25 -0
- package/dist/prompts-legacy.d.ts.map +1 -0
- package/dist/prompts-legacy.js +600 -0
- package/dist/prompts-legacy.js.map +1 -0
- package/dist/prompts-v2.d.ts +30 -0
- package/dist/prompts-v2.d.ts.map +1 -0
- package/dist/prompts-v2.js +310 -0
- package/dist/prompts-v2.js.map +1 -0
- package/dist/prompts.d.ts +30 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +310 -0
- package/dist/prompts.js.map +1 -0
- package/dist/resources.d.ts +18 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +95 -0
- package/dist/resources.js.map +1 -0
- package/dist/tools-legacy.d.ts +196 -0
- package/dist/tools-legacy.d.ts.map +1 -0
- package/dist/tools-legacy.js +1230 -0
- package/dist/tools-legacy.js.map +1 -0
- package/dist/tools-v2.d.ts +92 -0
- package/dist/tools-v2.d.ts.map +1 -0
- package/dist/tools-v2.js +410 -0
- package/dist/tools-v2.js.map +1 -0
- package/dist/tools.d.ts +92 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +410 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +3054 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +515 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/retry.d.ts +44 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +74 -0
- package/dist/utils/retry.js.map +1 -0
- package/package.json +79 -0
- package/profiles/README.md +199 -0
- package/profiles/custom/.gitkeep +2 -0
- package/profiles/templates/_template.yaml +159 -0
- package/profiles/templates/angular.yaml +494 -0
- package/profiles/templates/java-spring-backend.yaml +512 -0
- package/profiles/templates/minimal.yaml +102 -0
- package/profiles/templates/nodejs.yaml +338 -0
- package/profiles/templates/python.yaml +340 -0
- package/profiles/templates/react.yaml +331 -0
- package/profiles/templates/vue.yaml +598 -0
- package/standards/architecture/ddd.md +173 -0
- package/standards/architecture/hexagonal.md +97 -0
- package/standards/cicd/github-actions.md +567 -0
- package/standards/clean-code/naming.md +175 -0
- package/standards/clean-code/principles.md +179 -0
- package/standards/containerization/dockerfile.md +419 -0
- package/standards/database/selection-guide.md +443 -0
- package/standards/documentation/guidelines.md +189 -0
- package/standards/event-driven/domain-events.md +527 -0
- package/standards/kubernetes/deployment.md +518 -0
- package/standards/observability/guidelines.md +665 -0
- package/standards/project-setup/initialization-checklist.md +650 -0
- package/standards/spring-boot/best-practices.md +598 -0
- package/standards/testing/guidelines.md +559 -0
- package/standards/workflow/llm-development-workflow.md +542 -0
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
# Kubernetes Deployment Guidelines
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Guidelines for deploying Spring Boot applications to Kubernetes following best practices for reliability, security, and observability.
|
|
6
|
+
|
|
7
|
+
## Directory Structure
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
infrastructure/
|
|
11
|
+
├── kubernetes/
|
|
12
|
+
│ ├── base/
|
|
13
|
+
│ │ ├── deployment.yaml
|
|
14
|
+
│ │ ├── service.yaml
|
|
15
|
+
│ │ ├── configmap.yaml
|
|
16
|
+
│ │ ├── hpa.yaml
|
|
17
|
+
│ │ └── kustomization.yaml
|
|
18
|
+
│ └── overlays/
|
|
19
|
+
│ ├── development/
|
|
20
|
+
│ │ ├── kustomization.yaml
|
|
21
|
+
│ │ └── patches/
|
|
22
|
+
│ ├── staging/
|
|
23
|
+
│ │ └── kustomization.yaml
|
|
24
|
+
│ └── production/
|
|
25
|
+
│ ├── kustomization.yaml
|
|
26
|
+
│ └── patches/
|
|
27
|
+
└── helm/
|
|
28
|
+
└── order-service/
|
|
29
|
+
├── Chart.yaml
|
|
30
|
+
├── values.yaml
|
|
31
|
+
└── templates/
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Deployment
|
|
35
|
+
|
|
36
|
+
### Full Deployment Manifest
|
|
37
|
+
|
|
38
|
+
```yaml
|
|
39
|
+
# deployment.yaml
|
|
40
|
+
apiVersion: apps/v1
|
|
41
|
+
kind: Deployment
|
|
42
|
+
metadata:
|
|
43
|
+
name: order-service
|
|
44
|
+
labels:
|
|
45
|
+
app: order-service
|
|
46
|
+
app.kubernetes.io/name: order-service
|
|
47
|
+
app.kubernetes.io/version: "1.0.0"
|
|
48
|
+
app.kubernetes.io/component: backend
|
|
49
|
+
spec:
|
|
50
|
+
replicas: 2
|
|
51
|
+
revisionHistoryLimit: 3
|
|
52
|
+
strategy:
|
|
53
|
+
type: RollingUpdate
|
|
54
|
+
rollingUpdate:
|
|
55
|
+
maxSurge: 1
|
|
56
|
+
maxUnavailable: 0
|
|
57
|
+
selector:
|
|
58
|
+
matchLabels:
|
|
59
|
+
app: order-service
|
|
60
|
+
template:
|
|
61
|
+
metadata:
|
|
62
|
+
labels:
|
|
63
|
+
app: order-service
|
|
64
|
+
annotations:
|
|
65
|
+
prometheus.io/scrape: "true"
|
|
66
|
+
prometheus.io/port: "8080"
|
|
67
|
+
prometheus.io/path: "/actuator/prometheus"
|
|
68
|
+
spec:
|
|
69
|
+
serviceAccountName: order-service
|
|
70
|
+
securityContext:
|
|
71
|
+
runAsNonRoot: true
|
|
72
|
+
runAsUser: 1000
|
|
73
|
+
runAsGroup: 1000
|
|
74
|
+
fsGroup: 1000
|
|
75
|
+
|
|
76
|
+
containers:
|
|
77
|
+
- name: order-service
|
|
78
|
+
image: registry.example.com/order-service:1.0.0
|
|
79
|
+
imagePullPolicy: IfNotPresent
|
|
80
|
+
|
|
81
|
+
ports:
|
|
82
|
+
- name: http
|
|
83
|
+
containerPort: 8080
|
|
84
|
+
protocol: TCP
|
|
85
|
+
|
|
86
|
+
env:
|
|
87
|
+
- name: SPRING_PROFILES_ACTIVE
|
|
88
|
+
value: "kubernetes"
|
|
89
|
+
- name: SERVER_PORT
|
|
90
|
+
value: "8080"
|
|
91
|
+
- name: JAVA_OPTS
|
|
92
|
+
value: "-XX:+UseContainerSupport -XX:MaxRAMPercentage=75.0"
|
|
93
|
+
|
|
94
|
+
envFrom:
|
|
95
|
+
- configMapRef:
|
|
96
|
+
name: order-service-config
|
|
97
|
+
- secretRef:
|
|
98
|
+
name: order-service-secrets
|
|
99
|
+
|
|
100
|
+
resources:
|
|
101
|
+
requests:
|
|
102
|
+
cpu: "250m"
|
|
103
|
+
memory: "512Mi"
|
|
104
|
+
limits:
|
|
105
|
+
cpu: "1000m"
|
|
106
|
+
memory: "1Gi"
|
|
107
|
+
|
|
108
|
+
livenessProbe:
|
|
109
|
+
httpGet:
|
|
110
|
+
path: /actuator/health/liveness
|
|
111
|
+
port: http
|
|
112
|
+
initialDelaySeconds: 30
|
|
113
|
+
periodSeconds: 10
|
|
114
|
+
timeoutSeconds: 5
|
|
115
|
+
failureThreshold: 3
|
|
116
|
+
|
|
117
|
+
readinessProbe:
|
|
118
|
+
httpGet:
|
|
119
|
+
path: /actuator/health/readiness
|
|
120
|
+
port: http
|
|
121
|
+
initialDelaySeconds: 10
|
|
122
|
+
periodSeconds: 5
|
|
123
|
+
timeoutSeconds: 3
|
|
124
|
+
failureThreshold: 3
|
|
125
|
+
|
|
126
|
+
startupProbe:
|
|
127
|
+
httpGet:
|
|
128
|
+
path: /actuator/health/liveness
|
|
129
|
+
port: http
|
|
130
|
+
initialDelaySeconds: 10
|
|
131
|
+
periodSeconds: 5
|
|
132
|
+
failureThreshold: 30
|
|
133
|
+
|
|
134
|
+
securityContext:
|
|
135
|
+
allowPrivilegeEscalation: false
|
|
136
|
+
readOnlyRootFilesystem: true
|
|
137
|
+
capabilities:
|
|
138
|
+
drop:
|
|
139
|
+
- ALL
|
|
140
|
+
|
|
141
|
+
volumeMounts:
|
|
142
|
+
- name: tmp
|
|
143
|
+
mountPath: /tmp
|
|
144
|
+
|
|
145
|
+
volumes:
|
|
146
|
+
- name: tmp
|
|
147
|
+
emptyDir: {}
|
|
148
|
+
|
|
149
|
+
affinity:
|
|
150
|
+
podAntiAffinity:
|
|
151
|
+
preferredDuringSchedulingIgnoredDuringExecution:
|
|
152
|
+
- weight: 100
|
|
153
|
+
podAffinityTerm:
|
|
154
|
+
labelSelector:
|
|
155
|
+
matchLabels:
|
|
156
|
+
app: order-service
|
|
157
|
+
topologyKey: kubernetes.io/hostname
|
|
158
|
+
|
|
159
|
+
topologySpreadConstraints:
|
|
160
|
+
- maxSkew: 1
|
|
161
|
+
topologyKey: topology.kubernetes.io/zone
|
|
162
|
+
whenUnsatisfiable: ScheduleAnyway
|
|
163
|
+
labelSelector:
|
|
164
|
+
matchLabels:
|
|
165
|
+
app: order-service
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Service
|
|
169
|
+
|
|
170
|
+
```yaml
|
|
171
|
+
# service.yaml
|
|
172
|
+
apiVersion: v1
|
|
173
|
+
kind: Service
|
|
174
|
+
metadata:
|
|
175
|
+
name: order-service
|
|
176
|
+
labels:
|
|
177
|
+
app: order-service
|
|
178
|
+
spec:
|
|
179
|
+
type: ClusterIP
|
|
180
|
+
ports:
|
|
181
|
+
- name: http
|
|
182
|
+
port: 80
|
|
183
|
+
targetPort: http
|
|
184
|
+
protocol: TCP
|
|
185
|
+
selector:
|
|
186
|
+
app: order-service
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## ConfigMap
|
|
190
|
+
|
|
191
|
+
```yaml
|
|
192
|
+
# configmap.yaml
|
|
193
|
+
apiVersion: v1
|
|
194
|
+
kind: ConfigMap
|
|
195
|
+
metadata:
|
|
196
|
+
name: order-service-config
|
|
197
|
+
data:
|
|
198
|
+
# Application configuration
|
|
199
|
+
SPRING_APPLICATION_NAME: order-service
|
|
200
|
+
MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE: health,info,metrics,prometheus
|
|
201
|
+
MANAGEMENT_ENDPOINT_HEALTH_PROBES_ENABLED: "true"
|
|
202
|
+
|
|
203
|
+
# Kafka configuration
|
|
204
|
+
SPRING_KAFKA_BOOTSTRAP_SERVERS: kafka-cluster-kafka-bootstrap.kafka:9092
|
|
205
|
+
SPRING_KAFKA_CONSUMER_GROUP_ID: order-service
|
|
206
|
+
|
|
207
|
+
# Observability
|
|
208
|
+
MANAGEMENT_TRACING_SAMPLING_PROBABILITY: "1.0"
|
|
209
|
+
MANAGEMENT_ZIPKIN_TRACING_ENDPOINT: http://jaeger-collector.observability:9411/api/v2/spans
|
|
210
|
+
|
|
211
|
+
# Logging
|
|
212
|
+
LOGGING_LEVEL_ROOT: INFO
|
|
213
|
+
LOGGING_LEVEL_COM_EXAMPLE: DEBUG
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Secrets
|
|
217
|
+
|
|
218
|
+
```yaml
|
|
219
|
+
# secret.yaml (use External Secrets Operator in production)
|
|
220
|
+
apiVersion: v1
|
|
221
|
+
kind: Secret
|
|
222
|
+
metadata:
|
|
223
|
+
name: order-service-secrets
|
|
224
|
+
type: Opaque
|
|
225
|
+
stringData:
|
|
226
|
+
DATABASE_URL: jdbc:postgresql://postgres:5432/orderdb
|
|
227
|
+
DATABASE_USERNAME: postgres
|
|
228
|
+
DATABASE_PASSWORD: changeme
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### External Secrets (Recommended for Production)
|
|
232
|
+
|
|
233
|
+
```yaml
|
|
234
|
+
# external-secret.yaml
|
|
235
|
+
apiVersion: external-secrets.io/v1beta1
|
|
236
|
+
kind: ExternalSecret
|
|
237
|
+
metadata:
|
|
238
|
+
name: order-service-secrets
|
|
239
|
+
spec:
|
|
240
|
+
refreshInterval: 1h
|
|
241
|
+
secretStoreRef:
|
|
242
|
+
name: aws-secrets-manager
|
|
243
|
+
kind: ClusterSecretStore
|
|
244
|
+
target:
|
|
245
|
+
name: order-service-secrets
|
|
246
|
+
creationPolicy: Owner
|
|
247
|
+
data:
|
|
248
|
+
- secretKey: DATABASE_URL
|
|
249
|
+
remoteRef:
|
|
250
|
+
key: order-service/database
|
|
251
|
+
property: url
|
|
252
|
+
- secretKey: DATABASE_USERNAME
|
|
253
|
+
remoteRef:
|
|
254
|
+
key: order-service/database
|
|
255
|
+
property: username
|
|
256
|
+
- secretKey: DATABASE_PASSWORD
|
|
257
|
+
remoteRef:
|
|
258
|
+
key: order-service/database
|
|
259
|
+
property: password
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Horizontal Pod Autoscaler
|
|
263
|
+
|
|
264
|
+
```yaml
|
|
265
|
+
# hpa.yaml
|
|
266
|
+
apiVersion: autoscaling/v2
|
|
267
|
+
kind: HorizontalPodAutoscaler
|
|
268
|
+
metadata:
|
|
269
|
+
name: order-service
|
|
270
|
+
spec:
|
|
271
|
+
scaleTargetRef:
|
|
272
|
+
apiVersion: apps/v1
|
|
273
|
+
kind: Deployment
|
|
274
|
+
name: order-service
|
|
275
|
+
minReplicas: 2
|
|
276
|
+
maxReplicas: 10
|
|
277
|
+
metrics:
|
|
278
|
+
- type: Resource
|
|
279
|
+
resource:
|
|
280
|
+
name: cpu
|
|
281
|
+
target:
|
|
282
|
+
type: Utilization
|
|
283
|
+
averageUtilization: 70
|
|
284
|
+
- type: Resource
|
|
285
|
+
resource:
|
|
286
|
+
name: memory
|
|
287
|
+
target:
|
|
288
|
+
type: Utilization
|
|
289
|
+
averageUtilization: 80
|
|
290
|
+
behavior:
|
|
291
|
+
scaleDown:
|
|
292
|
+
stabilizationWindowSeconds: 300
|
|
293
|
+
policies:
|
|
294
|
+
- type: Percent
|
|
295
|
+
value: 10
|
|
296
|
+
periodSeconds: 60
|
|
297
|
+
scaleUp:
|
|
298
|
+
stabilizationWindowSeconds: 0
|
|
299
|
+
policies:
|
|
300
|
+
- type: Percent
|
|
301
|
+
value: 100
|
|
302
|
+
periodSeconds: 15
|
|
303
|
+
- type: Pods
|
|
304
|
+
value: 4
|
|
305
|
+
periodSeconds: 15
|
|
306
|
+
selectPolicy: Max
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Pod Disruption Budget
|
|
310
|
+
|
|
311
|
+
```yaml
|
|
312
|
+
# pdb.yaml
|
|
313
|
+
apiVersion: policy/v1
|
|
314
|
+
kind: PodDisruptionBudget
|
|
315
|
+
metadata:
|
|
316
|
+
name: order-service
|
|
317
|
+
spec:
|
|
318
|
+
minAvailable: 1
|
|
319
|
+
selector:
|
|
320
|
+
matchLabels:
|
|
321
|
+
app: order-service
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Ingress
|
|
325
|
+
|
|
326
|
+
```yaml
|
|
327
|
+
# ingress.yaml
|
|
328
|
+
apiVersion: networking.k8s.io/v1
|
|
329
|
+
kind: Ingress
|
|
330
|
+
metadata:
|
|
331
|
+
name: order-service
|
|
332
|
+
annotations:
|
|
333
|
+
kubernetes.io/ingress.class: nginx
|
|
334
|
+
cert-manager.io/cluster-issuer: letsencrypt-prod
|
|
335
|
+
nginx.ingress.kubernetes.io/ssl-redirect: "true"
|
|
336
|
+
nginx.ingress.kubernetes.io/proxy-body-size: "10m"
|
|
337
|
+
spec:
|
|
338
|
+
tls:
|
|
339
|
+
- hosts:
|
|
340
|
+
- api.example.com
|
|
341
|
+
secretName: order-service-tls
|
|
342
|
+
rules:
|
|
343
|
+
- host: api.example.com
|
|
344
|
+
http:
|
|
345
|
+
paths:
|
|
346
|
+
- path: /api/v1/orders
|
|
347
|
+
pathType: Prefix
|
|
348
|
+
backend:
|
|
349
|
+
service:
|
|
350
|
+
name: order-service
|
|
351
|
+
port:
|
|
352
|
+
name: http
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
## Service Account
|
|
356
|
+
|
|
357
|
+
```yaml
|
|
358
|
+
# serviceaccount.yaml
|
|
359
|
+
apiVersion: v1
|
|
360
|
+
kind: ServiceAccount
|
|
361
|
+
metadata:
|
|
362
|
+
name: order-service
|
|
363
|
+
annotations:
|
|
364
|
+
# For AWS IRSA
|
|
365
|
+
eks.amazonaws.com/role-arn: arn:aws:iam::123456789:role/order-service
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
## NetworkPolicy
|
|
369
|
+
|
|
370
|
+
```yaml
|
|
371
|
+
# networkpolicy.yaml
|
|
372
|
+
apiVersion: networking.k8s.io/v1
|
|
373
|
+
kind: NetworkPolicy
|
|
374
|
+
metadata:
|
|
375
|
+
name: order-service
|
|
376
|
+
spec:
|
|
377
|
+
podSelector:
|
|
378
|
+
matchLabels:
|
|
379
|
+
app: order-service
|
|
380
|
+
policyTypes:
|
|
381
|
+
- Ingress
|
|
382
|
+
- Egress
|
|
383
|
+
ingress:
|
|
384
|
+
- from:
|
|
385
|
+
- namespaceSelector:
|
|
386
|
+
matchLabels:
|
|
387
|
+
name: ingress-nginx
|
|
388
|
+
- podSelector:
|
|
389
|
+
matchLabels:
|
|
390
|
+
app: api-gateway
|
|
391
|
+
ports:
|
|
392
|
+
- port: 8080
|
|
393
|
+
egress:
|
|
394
|
+
- to:
|
|
395
|
+
- namespaceSelector:
|
|
396
|
+
matchLabels:
|
|
397
|
+
name: database
|
|
398
|
+
ports:
|
|
399
|
+
- port: 5432
|
|
400
|
+
- to:
|
|
401
|
+
- namespaceSelector:
|
|
402
|
+
matchLabels:
|
|
403
|
+
name: kafka
|
|
404
|
+
ports:
|
|
405
|
+
- port: 9092
|
|
406
|
+
- to:
|
|
407
|
+
- namespaceSelector: {}
|
|
408
|
+
podSelector:
|
|
409
|
+
matchLabels:
|
|
410
|
+
k8s-app: kube-dns
|
|
411
|
+
ports:
|
|
412
|
+
- port: 53
|
|
413
|
+
protocol: UDP
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
## Kustomize
|
|
417
|
+
|
|
418
|
+
### Base
|
|
419
|
+
|
|
420
|
+
```yaml
|
|
421
|
+
# base/kustomization.yaml
|
|
422
|
+
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
423
|
+
kind: Kustomization
|
|
424
|
+
|
|
425
|
+
resources:
|
|
426
|
+
- deployment.yaml
|
|
427
|
+
- service.yaml
|
|
428
|
+
- configmap.yaml
|
|
429
|
+
- hpa.yaml
|
|
430
|
+
- pdb.yaml
|
|
431
|
+
- serviceaccount.yaml
|
|
432
|
+
|
|
433
|
+
commonLabels:
|
|
434
|
+
app.kubernetes.io/name: order-service
|
|
435
|
+
app.kubernetes.io/managed-by: kustomize
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### Production Overlay
|
|
439
|
+
|
|
440
|
+
```yaml
|
|
441
|
+
# overlays/production/kustomization.yaml
|
|
442
|
+
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
443
|
+
kind: Kustomization
|
|
444
|
+
|
|
445
|
+
namespace: production
|
|
446
|
+
|
|
447
|
+
resources:
|
|
448
|
+
- ../../base
|
|
449
|
+
- ingress.yaml
|
|
450
|
+
- networkpolicy.yaml
|
|
451
|
+
- external-secret.yaml
|
|
452
|
+
|
|
453
|
+
images:
|
|
454
|
+
- name: registry.example.com/order-service
|
|
455
|
+
newTag: 1.0.0
|
|
456
|
+
|
|
457
|
+
replicas:
|
|
458
|
+
- name: order-service
|
|
459
|
+
count: 3
|
|
460
|
+
|
|
461
|
+
patches:
|
|
462
|
+
- path: patches/deployment-resources.yaml
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
```yaml
|
|
466
|
+
# overlays/production/patches/deployment-resources.yaml
|
|
467
|
+
apiVersion: apps/v1
|
|
468
|
+
kind: Deployment
|
|
469
|
+
metadata:
|
|
470
|
+
name: order-service
|
|
471
|
+
spec:
|
|
472
|
+
template:
|
|
473
|
+
spec:
|
|
474
|
+
containers:
|
|
475
|
+
- name: order-service
|
|
476
|
+
resources:
|
|
477
|
+
requests:
|
|
478
|
+
cpu: "500m"
|
|
479
|
+
memory: "1Gi"
|
|
480
|
+
limits:
|
|
481
|
+
cpu: "2000m"
|
|
482
|
+
memory: "2Gi"
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
## Deployment Commands
|
|
486
|
+
|
|
487
|
+
```bash
|
|
488
|
+
# Apply with Kustomize
|
|
489
|
+
kubectl apply -k infrastructure/kubernetes/overlays/production
|
|
490
|
+
|
|
491
|
+
# Preview changes
|
|
492
|
+
kubectl diff -k infrastructure/kubernetes/overlays/production
|
|
493
|
+
|
|
494
|
+
# Rollout status
|
|
495
|
+
kubectl rollout status deployment/order-service -n production
|
|
496
|
+
|
|
497
|
+
# Rollback
|
|
498
|
+
kubectl rollout undo deployment/order-service -n production
|
|
499
|
+
|
|
500
|
+
# View history
|
|
501
|
+
kubectl rollout history deployment/order-service -n production
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
## Best Practices Checklist
|
|
505
|
+
|
|
506
|
+
- [ ] Use resource requests and limits
|
|
507
|
+
- [ ] Configure liveness, readiness, and startup probes
|
|
508
|
+
- [ ] Use PodDisruptionBudget for high availability
|
|
509
|
+
- [ ] Configure HPA for auto-scaling
|
|
510
|
+
- [ ] Use pod anti-affinity for spreading across nodes
|
|
511
|
+
- [ ] Use topology spread constraints for zone distribution
|
|
512
|
+
- [ ] Configure NetworkPolicy for security
|
|
513
|
+
- [ ] Use External Secrets for credential management
|
|
514
|
+
- [ ] Run as non-root user
|
|
515
|
+
- [ ] Use read-only root filesystem
|
|
516
|
+
- [ ] Configure Prometheus scraping annotations
|
|
517
|
+
- [ ] Use namespaces for environment separation
|
|
518
|
+
- [ ] Use Kustomize/Helm for environment-specific configs
|