agentic-team-templates 0.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.
Files changed (103) hide show
  1. package/README.md +280 -0
  2. package/bin/cli.js +5 -0
  3. package/package.json +47 -0
  4. package/src/index.js +521 -0
  5. package/templates/_shared/code-quality.md +162 -0
  6. package/templates/_shared/communication.md +114 -0
  7. package/templates/_shared/core-principles.md +62 -0
  8. package/templates/_shared/git-workflow.md +165 -0
  9. package/templates/_shared/security-fundamentals.md +173 -0
  10. package/templates/blockchain/.cursorrules/defi-patterns.md +520 -0
  11. package/templates/blockchain/.cursorrules/gas-optimization.md +339 -0
  12. package/templates/blockchain/.cursorrules/overview.md +130 -0
  13. package/templates/blockchain/.cursorrules/security.md +318 -0
  14. package/templates/blockchain/.cursorrules/smart-contracts.md +364 -0
  15. package/templates/blockchain/.cursorrules/testing.md +415 -0
  16. package/templates/blockchain/.cursorrules/web3-integration.md +538 -0
  17. package/templates/blockchain/CLAUDE.md +389 -0
  18. package/templates/cli-tools/.cursorrules/architecture.md +412 -0
  19. package/templates/cli-tools/.cursorrules/arguments.md +406 -0
  20. package/templates/cli-tools/.cursorrules/distribution.md +546 -0
  21. package/templates/cli-tools/.cursorrules/error-handling.md +455 -0
  22. package/templates/cli-tools/.cursorrules/overview.md +136 -0
  23. package/templates/cli-tools/.cursorrules/testing.md +537 -0
  24. package/templates/cli-tools/.cursorrules/user-experience.md +545 -0
  25. package/templates/cli-tools/CLAUDE.md +356 -0
  26. package/templates/data-engineering/.cursorrules/data-modeling.md +367 -0
  27. package/templates/data-engineering/.cursorrules/data-quality.md +455 -0
  28. package/templates/data-engineering/.cursorrules/overview.md +85 -0
  29. package/templates/data-engineering/.cursorrules/performance.md +339 -0
  30. package/templates/data-engineering/.cursorrules/pipeline-design.md +280 -0
  31. package/templates/data-engineering/.cursorrules/security.md +460 -0
  32. package/templates/data-engineering/.cursorrules/testing.md +452 -0
  33. package/templates/data-engineering/CLAUDE.md +974 -0
  34. package/templates/devops-sre/.cursorrules/capacity-planning.md +653 -0
  35. package/templates/devops-sre/.cursorrules/change-management.md +584 -0
  36. package/templates/devops-sre/.cursorrules/chaos-engineering.md +651 -0
  37. package/templates/devops-sre/.cursorrules/disaster-recovery.md +641 -0
  38. package/templates/devops-sre/.cursorrules/incident-management.md +565 -0
  39. package/templates/devops-sre/.cursorrules/observability.md +714 -0
  40. package/templates/devops-sre/.cursorrules/overview.md +230 -0
  41. package/templates/devops-sre/.cursorrules/postmortems.md +588 -0
  42. package/templates/devops-sre/.cursorrules/runbooks.md +760 -0
  43. package/templates/devops-sre/.cursorrules/slo-sli.md +617 -0
  44. package/templates/devops-sre/.cursorrules/toil-reduction.md +567 -0
  45. package/templates/devops-sre/CLAUDE.md +1007 -0
  46. package/templates/documentation/.cursorrules/adr.md +277 -0
  47. package/templates/documentation/.cursorrules/api-documentation.md +411 -0
  48. package/templates/documentation/.cursorrules/code-comments.md +253 -0
  49. package/templates/documentation/.cursorrules/maintenance.md +260 -0
  50. package/templates/documentation/.cursorrules/overview.md +82 -0
  51. package/templates/documentation/.cursorrules/readme-standards.md +306 -0
  52. package/templates/documentation/CLAUDE.md +120 -0
  53. package/templates/fullstack/.cursorrules/api-contracts.md +331 -0
  54. package/templates/fullstack/.cursorrules/architecture.md +298 -0
  55. package/templates/fullstack/.cursorrules/overview.md +109 -0
  56. package/templates/fullstack/.cursorrules/shared-types.md +348 -0
  57. package/templates/fullstack/.cursorrules/testing.md +386 -0
  58. package/templates/fullstack/CLAUDE.md +349 -0
  59. package/templates/ml-ai/.cursorrules/data-engineering.md +483 -0
  60. package/templates/ml-ai/.cursorrules/deployment.md +601 -0
  61. package/templates/ml-ai/.cursorrules/model-development.md +538 -0
  62. package/templates/ml-ai/.cursorrules/monitoring.md +658 -0
  63. package/templates/ml-ai/.cursorrules/overview.md +131 -0
  64. package/templates/ml-ai/.cursorrules/security.md +637 -0
  65. package/templates/ml-ai/.cursorrules/testing.md +678 -0
  66. package/templates/ml-ai/CLAUDE.md +1136 -0
  67. package/templates/mobile/.cursorrules/navigation.md +246 -0
  68. package/templates/mobile/.cursorrules/offline-first.md +302 -0
  69. package/templates/mobile/.cursorrules/overview.md +71 -0
  70. package/templates/mobile/.cursorrules/performance.md +345 -0
  71. package/templates/mobile/.cursorrules/testing.md +339 -0
  72. package/templates/mobile/CLAUDE.md +233 -0
  73. package/templates/platform-engineering/.cursorrules/ci-cd.md +778 -0
  74. package/templates/platform-engineering/.cursorrules/developer-experience.md +632 -0
  75. package/templates/platform-engineering/.cursorrules/infrastructure-as-code.md +600 -0
  76. package/templates/platform-engineering/.cursorrules/kubernetes.md +710 -0
  77. package/templates/platform-engineering/.cursorrules/observability.md +747 -0
  78. package/templates/platform-engineering/.cursorrules/overview.md +215 -0
  79. package/templates/platform-engineering/.cursorrules/security.md +855 -0
  80. package/templates/platform-engineering/.cursorrules/testing.md +878 -0
  81. package/templates/platform-engineering/CLAUDE.md +850 -0
  82. package/templates/utility-agent/.cursorrules/action-control.md +284 -0
  83. package/templates/utility-agent/.cursorrules/context-management.md +186 -0
  84. package/templates/utility-agent/.cursorrules/hallucination-prevention.md +253 -0
  85. package/templates/utility-agent/.cursorrules/overview.md +78 -0
  86. package/templates/utility-agent/.cursorrules/token-optimization.md +369 -0
  87. package/templates/utility-agent/CLAUDE.md +513 -0
  88. package/templates/web-backend/.cursorrules/api-design.md +255 -0
  89. package/templates/web-backend/.cursorrules/authentication.md +309 -0
  90. package/templates/web-backend/.cursorrules/database-patterns.md +298 -0
  91. package/templates/web-backend/.cursorrules/error-handling.md +366 -0
  92. package/templates/web-backend/.cursorrules/overview.md +69 -0
  93. package/templates/web-backend/.cursorrules/security.md +358 -0
  94. package/templates/web-backend/.cursorrules/testing.md +395 -0
  95. package/templates/web-backend/CLAUDE.md +366 -0
  96. package/templates/web-frontend/.cursorrules/accessibility.md +296 -0
  97. package/templates/web-frontend/.cursorrules/component-patterns.md +204 -0
  98. package/templates/web-frontend/.cursorrules/overview.md +72 -0
  99. package/templates/web-frontend/.cursorrules/performance.md +325 -0
  100. package/templates/web-frontend/.cursorrules/state-management.md +227 -0
  101. package/templates/web-frontend/.cursorrules/styling.md +271 -0
  102. package/templates/web-frontend/.cursorrules/testing.md +311 -0
  103. package/templates/web-frontend/CLAUDE.md +399 -0
@@ -0,0 +1,710 @@
1
+ # Kubernetes Patterns
2
+
3
+ Guidelines for deploying and managing workloads on Kubernetes at scale.
4
+
5
+ ## Core Principles
6
+
7
+ 1. **Declarative Configuration** - Define desired state, let controllers reconcile
8
+ 2. **Resource Limits Always** - Every container needs requests and limits
9
+ 3. **Security by Default** - Non-root, read-only filesystems, no privilege escalation
10
+ 4. **High Availability** - Multiple replicas, spread across failure domains
11
+
12
+ ## Resource Management
13
+
14
+ ### Pod Specification
15
+
16
+ ```yaml
17
+ apiVersion: v1
18
+ kind: Pod
19
+ metadata:
20
+ name: api-server
21
+ labels:
22
+ app.kubernetes.io/name: api-server
23
+ app.kubernetes.io/version: "1.2.3"
24
+ app.kubernetes.io/component: backend
25
+ app.kubernetes.io/part-of: my-app
26
+ app.kubernetes.io/managed-by: helm
27
+ spec:
28
+ serviceAccountName: api-server
29
+
30
+ # Security context at pod level
31
+ securityContext:
32
+ runAsNonRoot: true
33
+ runAsUser: 1000
34
+ runAsGroup: 1000
35
+ fsGroup: 1000
36
+ seccompProfile:
37
+ type: RuntimeDefault
38
+
39
+ containers:
40
+ - name: api-server
41
+ image: company/api-server:v1.2.3
42
+
43
+ # Always specify resources
44
+ resources:
45
+ requests:
46
+ cpu: "100m"
47
+ memory: "256Mi"
48
+ limits:
49
+ cpu: "500m"
50
+ memory: "512Mi"
51
+
52
+ # Container security context
53
+ securityContext:
54
+ allowPrivilegeEscalation: false
55
+ readOnlyRootFilesystem: true
56
+ capabilities:
57
+ drop:
58
+ - ALL
59
+
60
+ # Health probes
61
+ livenessProbe:
62
+ httpGet:
63
+ path: /healthz
64
+ port: 8080
65
+ initialDelaySeconds: 15
66
+ periodSeconds: 10
67
+ timeoutSeconds: 5
68
+ failureThreshold: 3
69
+
70
+ readinessProbe:
71
+ httpGet:
72
+ path: /ready
73
+ port: 8080
74
+ initialDelaySeconds: 5
75
+ periodSeconds: 5
76
+ timeoutSeconds: 3
77
+ failureThreshold: 3
78
+
79
+ # Graceful shutdown
80
+ lifecycle:
81
+ preStop:
82
+ exec:
83
+ command: ["/bin/sh", "-c", "sleep 10"]
84
+
85
+ # Environment from ConfigMap/Secret
86
+ envFrom:
87
+ - configMapRef:
88
+ name: api-server-config
89
+ - secretRef:
90
+ name: api-server-secrets
91
+
92
+ # Volume mounts
93
+ volumeMounts:
94
+ - name: tmp
95
+ mountPath: /tmp
96
+ - name: cache
97
+ mountPath: /var/cache
98
+
99
+ volumes:
100
+ - name: tmp
101
+ emptyDir: {}
102
+ - name: cache
103
+ emptyDir:
104
+ sizeLimit: 100Mi
105
+
106
+ # Termination grace period
107
+ terminationGracePeriodSeconds: 30
108
+ ```
109
+
110
+ ### Deployment Best Practices
111
+
112
+ ```yaml
113
+ apiVersion: apps/v1
114
+ kind: Deployment
115
+ metadata:
116
+ name: api-server
117
+ annotations:
118
+ reloader.stakater.com/auto: "true" # Auto-restart on config changes
119
+ spec:
120
+ replicas: 3
121
+
122
+ # Rolling update strategy
123
+ strategy:
124
+ type: RollingUpdate
125
+ rollingUpdate:
126
+ maxSurge: 1
127
+ maxUnavailable: 0
128
+
129
+ selector:
130
+ matchLabels:
131
+ app.kubernetes.io/name: api-server
132
+
133
+ template:
134
+ metadata:
135
+ labels:
136
+ app.kubernetes.io/name: api-server
137
+ annotations:
138
+ prometheus.io/scrape: "true"
139
+ prometheus.io/port: "9090"
140
+ prometheus.io/path: "/metrics"
141
+ spec:
142
+ # Spread across zones
143
+ topologySpreadConstraints:
144
+ - maxSkew: 1
145
+ topologyKey: topology.kubernetes.io/zone
146
+ whenUnsatisfiable: DoNotSchedule
147
+ labelSelector:
148
+ matchLabels:
149
+ app.kubernetes.io/name: api-server
150
+
151
+ # Prefer spreading across nodes
152
+ affinity:
153
+ podAntiAffinity:
154
+ preferredDuringSchedulingIgnoredDuringExecution:
155
+ - weight: 100
156
+ podAffinityTerm:
157
+ labelSelector:
158
+ matchLabels:
159
+ app.kubernetes.io/name: api-server
160
+ topologyKey: kubernetes.io/hostname
161
+
162
+ containers:
163
+ - name: api-server
164
+ # ... container spec
165
+ ```
166
+
167
+ ### Horizontal Pod Autoscaler
168
+
169
+ ```yaml
170
+ apiVersion: autoscaling/v2
171
+ kind: HorizontalPodAutoscaler
172
+ metadata:
173
+ name: api-server
174
+ spec:
175
+ scaleTargetRef:
176
+ apiVersion: apps/v1
177
+ kind: Deployment
178
+ name: api-server
179
+
180
+ minReplicas: 3
181
+ maxReplicas: 20
182
+
183
+ metrics:
184
+ # CPU-based scaling
185
+ - type: Resource
186
+ resource:
187
+ name: cpu
188
+ target:
189
+ type: Utilization
190
+ averageUtilization: 70
191
+
192
+ # Memory-based scaling
193
+ - type: Resource
194
+ resource:
195
+ name: memory
196
+ target:
197
+ type: Utilization
198
+ averageUtilization: 80
199
+
200
+ # Custom metrics (requests per second)
201
+ - type: Pods
202
+ pods:
203
+ metric:
204
+ name: http_requests_per_second
205
+ target:
206
+ type: AverageValue
207
+ averageValue: 1000
208
+
209
+ behavior:
210
+ scaleDown:
211
+ stabilizationWindowSeconds: 300
212
+ policies:
213
+ - type: Percent
214
+ value: 10
215
+ periodSeconds: 60
216
+ scaleUp:
217
+ stabilizationWindowSeconds: 0
218
+ policies:
219
+ - type: Percent
220
+ value: 100
221
+ periodSeconds: 15
222
+ - type: Pods
223
+ value: 4
224
+ periodSeconds: 15
225
+ selectPolicy: Max
226
+ ```
227
+
228
+ ### Pod Disruption Budget
229
+
230
+ ```yaml
231
+ apiVersion: policy/v1
232
+ kind: PodDisruptionBudget
233
+ metadata:
234
+ name: api-server
235
+ spec:
236
+ # Ensure at least 2 pods are always available
237
+ minAvailable: 2
238
+ # OR use maxUnavailable
239
+ # maxUnavailable: 1
240
+ selector:
241
+ matchLabels:
242
+ app.kubernetes.io/name: api-server
243
+ ```
244
+
245
+ ## Networking
246
+
247
+ ### Service Definition
248
+
249
+ ```yaml
250
+ apiVersion: v1
251
+ kind: Service
252
+ metadata:
253
+ name: api-server
254
+ labels:
255
+ app.kubernetes.io/name: api-server
256
+ spec:
257
+ type: ClusterIP
258
+ selector:
259
+ app.kubernetes.io/name: api-server
260
+ ports:
261
+ - name: http
262
+ port: 80
263
+ targetPort: 8080
264
+ protocol: TCP
265
+ - name: metrics
266
+ port: 9090
267
+ targetPort: 9090
268
+ protocol: TCP
269
+ ```
270
+
271
+ ### Network Policies
272
+
273
+ ```yaml
274
+ # Default deny all ingress
275
+ apiVersion: networking.k8s.io/v1
276
+ kind: NetworkPolicy
277
+ metadata:
278
+ name: default-deny-ingress
279
+ namespace: production
280
+ spec:
281
+ podSelector: {}
282
+ policyTypes:
283
+ - Ingress
284
+
285
+ ---
286
+ # Allow traffic from ingress controller and specific pods
287
+ apiVersion: networking.k8s.io/v1
288
+ kind: NetworkPolicy
289
+ metadata:
290
+ name: api-server-network-policy
291
+ namespace: production
292
+ spec:
293
+ podSelector:
294
+ matchLabels:
295
+ app.kubernetes.io/name: api-server
296
+ policyTypes:
297
+ - Ingress
298
+ - Egress
299
+
300
+ ingress:
301
+ # Allow from ingress controller
302
+ - from:
303
+ - namespaceSelector:
304
+ matchLabels:
305
+ name: ingress-nginx
306
+ ports:
307
+ - protocol: TCP
308
+ port: 8080
309
+
310
+ # Allow from frontend pods
311
+ - from:
312
+ - podSelector:
313
+ matchLabels:
314
+ app.kubernetes.io/name: frontend
315
+ ports:
316
+ - protocol: TCP
317
+ port: 8080
318
+
319
+ # Allow Prometheus scraping
320
+ - from:
321
+ - namespaceSelector:
322
+ matchLabels:
323
+ name: monitoring
324
+ ports:
325
+ - protocol: TCP
326
+ port: 9090
327
+
328
+ egress:
329
+ # Allow DNS
330
+ - to:
331
+ - namespaceSelector: {}
332
+ podSelector:
333
+ matchLabels:
334
+ k8s-app: kube-dns
335
+ ports:
336
+ - protocol: UDP
337
+ port: 53
338
+
339
+ # Allow database access
340
+ - to:
341
+ - podSelector:
342
+ matchLabels:
343
+ app.kubernetes.io/name: postgresql
344
+ ports:
345
+ - protocol: TCP
346
+ port: 5432
347
+
348
+ # Allow external HTTPS
349
+ - to:
350
+ - ipBlock:
351
+ cidr: 0.0.0.0/0
352
+ ports:
353
+ - protocol: TCP
354
+ port: 443
355
+ ```
356
+
357
+ ### Ingress Configuration
358
+
359
+ ```yaml
360
+ apiVersion: networking.k8s.io/v1
361
+ kind: Ingress
362
+ metadata:
363
+ name: api-server
364
+ annotations:
365
+ nginx.ingress.kubernetes.io/ssl-redirect: "true"
366
+ nginx.ingress.kubernetes.io/proxy-body-size: "10m"
367
+ nginx.ingress.kubernetes.io/proxy-read-timeout: "60"
368
+ cert-manager.io/cluster-issuer: "letsencrypt-prod"
369
+ spec:
370
+ ingressClassName: nginx
371
+ tls:
372
+ - hosts:
373
+ - api.example.com
374
+ secretName: api-server-tls
375
+ rules:
376
+ - host: api.example.com
377
+ http:
378
+ paths:
379
+ - path: /
380
+ pathType: Prefix
381
+ backend:
382
+ service:
383
+ name: api-server
384
+ port:
385
+ number: 80
386
+ ```
387
+
388
+ ## Configuration Management
389
+
390
+ ### ConfigMap
391
+
392
+ ```yaml
393
+ apiVersion: v1
394
+ kind: ConfigMap
395
+ metadata:
396
+ name: api-server-config
397
+ data:
398
+ LOG_LEVEL: "info"
399
+ LOG_FORMAT: "json"
400
+ CACHE_TTL: "300"
401
+
402
+ # File-based config
403
+ config.yaml: |
404
+ server:
405
+ port: 8080
406
+ readTimeout: 30s
407
+ writeTimeout: 30s
408
+ features:
409
+ enableNewUI: true
410
+ enableBetaAPI: false
411
+ ```
412
+
413
+ ### External Secrets
414
+
415
+ ```yaml
416
+ apiVersion: external-secrets.io/v1beta1
417
+ kind: ExternalSecret
418
+ metadata:
419
+ name: api-server-secrets
420
+ spec:
421
+ refreshInterval: 1h
422
+
423
+ secretStoreRef:
424
+ kind: ClusterSecretStore
425
+ name: vault-backend
426
+
427
+ target:
428
+ name: api-server-secrets
429
+ creationPolicy: Owner
430
+ template:
431
+ type: Opaque
432
+ data:
433
+ DATABASE_URL: "postgresql://{{ .username }}:{{ .password }}@db.example.com:5432/api"
434
+
435
+ data:
436
+ - secretKey: username
437
+ remoteRef:
438
+ key: secret/data/api-server/database
439
+ property: username
440
+
441
+ - secretKey: password
442
+ remoteRef:
443
+ key: secret/data/api-server/database
444
+ property: password
445
+ ```
446
+
447
+ ## Helm Charts
448
+
449
+ ### Chart Structure
450
+
451
+ ```
452
+ charts/api-server/
453
+ ├── Chart.yaml
454
+ ├── values.yaml
455
+ ├── values-dev.yaml
456
+ ├── values-staging.yaml
457
+ ├── values-production.yaml
458
+ ├── templates/
459
+ │ ├── _helpers.tpl
460
+ │ ├── deployment.yaml
461
+ │ ├── service.yaml
462
+ │ ├── ingress.yaml
463
+ │ ├── hpa.yaml
464
+ │ ├── pdb.yaml
465
+ │ ├── networkpolicy.yaml
466
+ │ ├── configmap.yaml
467
+ │ ├── serviceaccount.yaml
468
+ │ ├── servicemonitor.yaml
469
+ │ └── NOTES.txt
470
+ └── tests/
471
+ └── test-connection.yaml
472
+ ```
473
+
474
+ ### Chart.yaml
475
+
476
+ ```yaml
477
+ apiVersion: v2
478
+ name: api-server
479
+ description: API Server Helm chart
480
+ type: application
481
+ version: 1.0.0
482
+ appVersion: "1.2.3"
483
+
484
+ dependencies:
485
+ - name: common
486
+ version: 1.x.x
487
+ repository: https://charts.example.com
488
+
489
+ maintainers:
490
+ - name: Platform Team
491
+ email: platform@example.com
492
+ ```
493
+
494
+ ### values.yaml
495
+
496
+ ```yaml
497
+ # Default values
498
+ replicaCount: 3
499
+
500
+ image:
501
+ repository: company/api-server
502
+ pullPolicy: IfNotPresent
503
+ tag: "" # Defaults to Chart appVersion
504
+
505
+ serviceAccount:
506
+ create: true
507
+ annotations: {}
508
+ name: ""
509
+
510
+ podAnnotations: {}
511
+
512
+ podSecurityContext:
513
+ runAsNonRoot: true
514
+ runAsUser: 1000
515
+ fsGroup: 1000
516
+
517
+ securityContext:
518
+ allowPrivilegeEscalation: false
519
+ readOnlyRootFilesystem: true
520
+ capabilities:
521
+ drop:
522
+ - ALL
523
+
524
+ service:
525
+ type: ClusterIP
526
+ port: 80
527
+
528
+ ingress:
529
+ enabled: false
530
+ className: nginx
531
+ annotations: {}
532
+ hosts: []
533
+ tls: []
534
+
535
+ resources:
536
+ requests:
537
+ cpu: 100m
538
+ memory: 256Mi
539
+ limits:
540
+ cpu: 500m
541
+ memory: 512Mi
542
+
543
+ autoscaling:
544
+ enabled: true
545
+ minReplicas: 3
546
+ maxReplicas: 20
547
+ targetCPUUtilizationPercentage: 70
548
+ targetMemoryUtilizationPercentage: 80
549
+
550
+ nodeSelector: {}
551
+ tolerations: []
552
+ affinity: {}
553
+
554
+ config:
555
+ logLevel: info
556
+ logFormat: json
557
+ ```
558
+
559
+ ### Template Helpers
560
+
561
+ ```yaml
562
+ # templates/_helpers.tpl
563
+ {{/*
564
+ Expand the name of the chart.
565
+ */}}
566
+ {{- define "api-server.name" -}}
567
+ {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
568
+ {{- end }}
569
+
570
+ {{/*
571
+ Create a default fully qualified app name.
572
+ */}}
573
+ {{- define "api-server.fullname" -}}
574
+ {{- if .Values.fullnameOverride }}
575
+ {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
576
+ {{- else }}
577
+ {{- $name := default .Chart.Name .Values.nameOverride }}
578
+ {{- if contains $name .Release.Name }}
579
+ {{- .Release.Name | trunc 63 | trimSuffix "-" }}
580
+ {{- else }}
581
+ {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
582
+ {{- end }}
583
+ {{- end }}
584
+ {{- end }}
585
+
586
+ {{/*
587
+ Common labels
588
+ */}}
589
+ {{- define "api-server.labels" -}}
590
+ helm.sh/chart: {{ include "api-server.chart" . }}
591
+ {{ include "api-server.selectorLabels" . }}
592
+ app.kubernetes.io/version: {{ .Values.image.tag | default .Chart.AppVersion | quote }}
593
+ app.kubernetes.io/managed-by: {{ .Release.Service }}
594
+ {{- end }}
595
+
596
+ {{/*
597
+ Selector labels
598
+ */}}
599
+ {{- define "api-server.selectorLabels" -}}
600
+ app.kubernetes.io/name: {{ include "api-server.name" . }}
601
+ app.kubernetes.io/instance: {{ .Release.Name }}
602
+ {{- end }}
603
+ ```
604
+
605
+ ## Multi-Cluster Strategies
606
+
607
+ ### Cluster Federation
608
+
609
+ ```yaml
610
+ # KubeFed FederatedDeployment
611
+ apiVersion: types.kubefed.io/v1beta1
612
+ kind: FederatedDeployment
613
+ metadata:
614
+ name: api-server
615
+ namespace: production
616
+ spec:
617
+ template:
618
+ spec:
619
+ replicas: 3
620
+ selector:
621
+ matchLabels:
622
+ app: api-server
623
+ template:
624
+ spec:
625
+ containers:
626
+ - name: api-server
627
+ image: company/api-server:v1.2.3
628
+
629
+ placement:
630
+ clusters:
631
+ - name: cluster-us-east
632
+ - name: cluster-us-west
633
+ - name: cluster-eu-west
634
+
635
+ overrides:
636
+ - clusterName: cluster-us-east
637
+ clusterOverrides:
638
+ - path: "/spec/replicas"
639
+ value: 5
640
+ ```
641
+
642
+ ### GitOps Multi-Cluster
643
+
644
+ ```yaml
645
+ # Argo CD ApplicationSet for multi-cluster
646
+ apiVersion: argoproj.io/v1alpha1
647
+ kind: ApplicationSet
648
+ metadata:
649
+ name: api-server
650
+ namespace: argocd
651
+ spec:
652
+ generators:
653
+ - list:
654
+ elements:
655
+ - cluster: cluster-us-east
656
+ url: https://us-east.k8s.example.com
657
+ values:
658
+ replicas: "5"
659
+ - cluster: cluster-us-west
660
+ url: https://us-west.k8s.example.com
661
+ values:
662
+ replicas: "3"
663
+ - cluster: cluster-eu-west
664
+ url: https://eu-west.k8s.example.com
665
+ values:
666
+ replicas: "3"
667
+
668
+ template:
669
+ metadata:
670
+ name: 'api-server-{{cluster}}'
671
+ spec:
672
+ project: default
673
+ source:
674
+ repoURL: https://github.com/company/gitops.git
675
+ targetRevision: HEAD
676
+ path: apps/api-server
677
+ helm:
678
+ values: |
679
+ replicaCount: {{values.replicas}}
680
+ destination:
681
+ server: '{{url}}'
682
+ namespace: production
683
+ ```
684
+
685
+ ## Troubleshooting Commands
686
+
687
+ ```bash
688
+ # Pod issues
689
+ kubectl describe pod <pod-name>
690
+ kubectl logs <pod-name> --previous
691
+ kubectl logs <pod-name> -c <container-name>
692
+ kubectl exec -it <pod-name> -- /bin/sh
693
+
694
+ # Resource usage
695
+ kubectl top pods
696
+ kubectl top nodes
697
+ kubectl describe node <node-name>
698
+
699
+ # Network debugging
700
+ kubectl run debug --rm -it --image=nicolaka/netshoot -- /bin/bash
701
+ kubectl port-forward svc/api-server 8080:80
702
+
703
+ # Events
704
+ kubectl get events --sort-by='.lastTimestamp'
705
+ kubectl get events --field-selector type=Warning
706
+
707
+ # Resource validation
708
+ kubectl diff -f manifest.yaml
709
+ kubectl apply --dry-run=server -f manifest.yaml
710
+ ```