specweave 0.3.13 → 0.4.1
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/CLAUDE.md +506 -17
- package/README.md +100 -58
- package/bin/install-all.sh +9 -2
- package/bin/install-hooks.sh +57 -0
- package/bin/specweave.js +16 -0
- package/dist/adapters/adapter-base.d.ts +21 -0
- package/dist/adapters/adapter-base.d.ts.map +1 -1
- package/dist/adapters/adapter-base.js +28 -0
- package/dist/adapters/adapter-base.js.map +1 -1
- package/dist/adapters/adapter-interface.d.ts +41 -0
- package/dist/adapters/adapter-interface.d.ts.map +1 -1
- package/dist/adapters/claude/adapter.d.ts +36 -0
- package/dist/adapters/claude/adapter.d.ts.map +1 -1
- package/dist/adapters/claude/adapter.js +135 -0
- package/dist/adapters/claude/adapter.js.map +1 -1
- package/dist/adapters/copilot/adapter.d.ts +25 -0
- package/dist/adapters/copilot/adapter.d.ts.map +1 -1
- package/dist/adapters/copilot/adapter.js +112 -0
- package/dist/adapters/copilot/adapter.js.map +1 -1
- package/dist/adapters/cursor/adapter.d.ts +36 -0
- package/dist/adapters/cursor/adapter.d.ts.map +1 -1
- package/dist/adapters/cursor/adapter.js +140 -0
- package/dist/adapters/cursor/adapter.js.map +1 -1
- package/dist/adapters/generic/adapter.d.ts +25 -0
- package/dist/adapters/generic/adapter.d.ts.map +1 -1
- package/dist/adapters/generic/adapter.js +111 -0
- package/dist/adapters/generic/adapter.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +103 -1
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/plugin.d.ts +37 -0
- package/dist/cli/commands/plugin.d.ts.map +1 -0
- package/dist/cli/commands/plugin.js +296 -0
- package/dist/cli/commands/plugin.js.map +1 -0
- package/dist/core/agent-model-manager.d.ts +52 -0
- package/dist/core/agent-model-manager.d.ts.map +1 -0
- package/dist/core/agent-model-manager.js +120 -0
- package/dist/core/agent-model-manager.js.map +1 -0
- package/dist/core/cost-tracker.d.ts +108 -0
- package/dist/core/cost-tracker.d.ts.map +1 -0
- package/dist/core/cost-tracker.js +281 -0
- package/dist/core/cost-tracker.js.map +1 -0
- package/dist/core/model-selector.d.ts +57 -0
- package/dist/core/model-selector.d.ts.map +1 -0
- package/dist/core/model-selector.js +115 -0
- package/dist/core/model-selector.js.map +1 -0
- package/dist/core/phase-detector.d.ts +62 -0
- package/dist/core/phase-detector.d.ts.map +1 -0
- package/dist/core/phase-detector.js +229 -0
- package/dist/core/phase-detector.js.map +1 -0
- package/dist/core/plugin-detector.d.ts +96 -0
- package/dist/core/plugin-detector.d.ts.map +1 -0
- package/dist/core/plugin-detector.js +349 -0
- package/dist/core/plugin-detector.js.map +1 -0
- package/dist/core/plugin-loader.d.ts +111 -0
- package/dist/core/plugin-loader.d.ts.map +1 -0
- package/dist/core/plugin-loader.js +319 -0
- package/dist/core/plugin-loader.js.map +1 -0
- package/dist/core/plugin-manager.d.ts +144 -0
- package/dist/core/plugin-manager.d.ts.map +1 -0
- package/dist/core/plugin-manager.js +393 -0
- package/dist/core/plugin-manager.js.map +1 -0
- package/dist/core/schemas/plugin-manifest.schema.json +253 -0
- package/dist/core/types/plugin.d.ts +252 -0
- package/dist/core/types/plugin.d.ts.map +1 -0
- package/dist/core/types/plugin.js +48 -0
- package/dist/core/types/plugin.js.map +1 -0
- package/dist/integrations/jira/jira-mapper.d.ts +2 -2
- package/dist/integrations/jira/jira-mapper.js +2 -2
- package/dist/types/cost-tracking.d.ts +43 -0
- package/dist/types/cost-tracking.d.ts.map +1 -0
- package/dist/types/cost-tracking.js +8 -0
- package/dist/types/cost-tracking.js.map +1 -0
- package/dist/types/model-selection.d.ts +53 -0
- package/dist/types/model-selection.d.ts.map +1 -0
- package/dist/types/model-selection.js +12 -0
- package/dist/types/model-selection.js.map +1 -0
- package/dist/utils/cost-reporter.d.ts +58 -0
- package/dist/utils/cost-reporter.d.ts.map +1 -0
- package/dist/utils/cost-reporter.js +224 -0
- package/dist/utils/cost-reporter.js.map +1 -0
- package/dist/utils/pricing-constants.d.ts +70 -0
- package/dist/utils/pricing-constants.d.ts.map +1 -0
- package/dist/utils/pricing-constants.js +71 -0
- package/dist/utils/pricing-constants.js.map +1 -0
- package/package.json +13 -9
- package/src/adapters/adapter-base.ts +33 -0
- package/src/adapters/adapter-interface.ts +46 -0
- package/src/adapters/claude/adapter.ts +164 -0
- package/src/adapters/copilot/adapter.ts +138 -0
- package/src/adapters/cursor/adapter.ts +170 -0
- package/src/adapters/generic/adapter.ts +137 -0
- package/src/agents/architect/AGENT.md +3 -0
- package/src/agents/code-reviewer.md +156 -0
- package/src/agents/data-scientist/AGENT.md +181 -0
- package/src/agents/database-optimizer/AGENT.md +147 -0
- package/src/agents/devops/AGENT.md +3 -0
- package/src/agents/diagrams-architect/AGENT.md +3 -0
- package/src/agents/docs-writer/AGENT.md +3 -0
- package/src/agents/kubernetes-architect/AGENT.md +142 -0
- package/src/agents/ml-engineer/AGENT.md +150 -0
- package/src/agents/mlops-engineer/AGENT.md +201 -0
- package/src/agents/network-engineer/AGENT.md +149 -0
- package/src/agents/observability-engineer/AGENT.md +213 -0
- package/src/agents/payment-integration/AGENT.md +35 -0
- package/src/agents/performance/AGENT.md +3 -0
- package/src/agents/performance-engineer/AGENT.md +153 -0
- package/src/agents/pm/AGENT.md +3 -0
- package/src/agents/qa-lead/AGENT.md +3 -0
- package/src/agents/security/AGENT.md +3 -0
- package/src/agents/sre/AGENT.md +3 -0
- package/src/agents/tdd-orchestrator/AGENT.md +169 -0
- package/src/agents/tech-lead/AGENT.md +3 -0
- package/src/commands/specweave.costs.md +261 -0
- package/src/commands/specweave.increment.md +48 -4
- package/src/commands/specweave.ml-pipeline.md +292 -0
- package/src/commands/specweave.monitor-setup.md +501 -0
- package/src/commands/specweave.slo-implement.md +1055 -0
- package/src/commands/specweave.sync-github.md +1 -1
- package/src/commands/specweave.tdd-cycle.md +199 -0
- package/src/commands/specweave.tdd-green.md +842 -0
- package/src/commands/specweave.tdd-red.md +135 -0
- package/src/commands/specweave.tdd-refactor.md +165 -0
- package/src/hooks/post-increment-plugin-detect.sh +142 -0
- package/src/hooks/post-task-completion.sh +53 -11
- package/src/hooks/pre-task-plugin-detect.sh +96 -0
- package/src/skills/SKILLS-INDEX.md +18 -10
- package/src/skills/billing-automation/SKILL.md +559 -0
- package/src/skills/distributed-tracing/SKILL.md +438 -0
- package/src/skills/e2e-playwright/README.md +1 -1
- package/src/skills/e2e-playwright/package.json +1 -1
- package/src/skills/gitops-workflow/SKILL.md +285 -0
- package/src/skills/gitops-workflow/references/argocd-setup.md +134 -0
- package/src/skills/gitops-workflow/references/sync-policies.md +131 -0
- package/src/skills/grafana-dashboards/SKILL.md +369 -0
- package/src/skills/helm-chart-scaffolding/SKILL.md +544 -0
- package/src/skills/helm-chart-scaffolding/assets/Chart.yaml.template +42 -0
- package/src/skills/helm-chart-scaffolding/assets/values.yaml.template +185 -0
- package/src/skills/helm-chart-scaffolding/references/chart-structure.md +500 -0
- package/src/skills/helm-chart-scaffolding/scripts/validate-chart.sh +244 -0
- package/src/skills/k8s-manifest-generator/SKILL.md +511 -0
- package/src/skills/k8s-manifest-generator/assets/configmap-template.yaml +296 -0
- package/src/skills/k8s-manifest-generator/assets/deployment-template.yaml +203 -0
- package/src/skills/k8s-manifest-generator/assets/service-template.yaml +171 -0
- package/src/skills/k8s-manifest-generator/references/deployment-spec.md +753 -0
- package/src/skills/k8s-manifest-generator/references/service-spec.md +724 -0
- package/src/skills/k8s-security-policies/SKILL.md +334 -0
- package/src/skills/k8s-security-policies/assets/network-policy-template.yaml +177 -0
- package/src/skills/k8s-security-policies/references/rbac-patterns.md +187 -0
- package/src/skills/ml-pipeline-workflow/SKILL.md +245 -0
- package/src/skills/paypal-integration/SKILL.md +467 -0
- package/src/skills/pci-compliance/SKILL.md +466 -0
- package/src/skills/prometheus-configuration/SKILL.md +392 -0
- package/src/skills/slo-implementation/SKILL.md +329 -0
- package/src/skills/stripe-integration/SKILL.md +442 -0
- package/src/skills/tdd-workflow/SKILL.md +378 -0
- package/src/templates/README.md.template +1 -1
- package/src/skills/bmad-method-expert/SKILL.md +0 -626
- package/src/skills/bmad-method-expert/scripts/analyze-project.js +0 -318
- package/src/skills/bmad-method-expert/scripts/check-setup.js +0 -208
- package/src/skills/bmad-method-expert/scripts/generate-template.js +0 -1149
- package/src/skills/bmad-method-expert/scripts/validate-documents.js +0 -340
- package/src/skills/context-optimizer/SKILL.md +0 -588
- package/src/skills/figma-designer/SKILL.md +0 -149
- package/src/skills/figma-implementer/SKILL.md +0 -148
- package/src/skills/figma-mcp-connector/SKILL.md +0 -136
- package/src/skills/figma-to-code/SKILL.md +0 -128
- package/src/skills/spec-kit-expert/SKILL.md +0 -1010
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: k8s-manifest-generator
|
|
3
|
+
description: Create production-ready Kubernetes manifests for Deployments, Services, ConfigMaps, and Secrets following best practices and security standards. Use when generating Kubernetes YAML manifests, creating K8s resources, or implementing production-grade Kubernetes configurations.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Kubernetes Manifest Generator
|
|
7
|
+
|
|
8
|
+
Step-by-step guidance for creating production-ready Kubernetes manifests including Deployments, Services, ConfigMaps, Secrets, and PersistentVolumeClaims.
|
|
9
|
+
|
|
10
|
+
## Purpose
|
|
11
|
+
|
|
12
|
+
This skill provides comprehensive guidance for generating well-structured, secure, and production-ready Kubernetes manifests following cloud-native best practices and Kubernetes conventions.
|
|
13
|
+
|
|
14
|
+
## When to Use This Skill
|
|
15
|
+
|
|
16
|
+
Use this skill when you need to:
|
|
17
|
+
- Create new Kubernetes Deployment manifests
|
|
18
|
+
- Define Service resources for network connectivity
|
|
19
|
+
- Generate ConfigMap and Secret resources for configuration management
|
|
20
|
+
- Create PersistentVolumeClaim manifests for stateful workloads
|
|
21
|
+
- Follow Kubernetes best practices and naming conventions
|
|
22
|
+
- Implement resource limits, health checks, and security contexts
|
|
23
|
+
- Design manifests for multi-environment deployments
|
|
24
|
+
|
|
25
|
+
## Step-by-Step Workflow
|
|
26
|
+
|
|
27
|
+
### 1. Gather Requirements
|
|
28
|
+
|
|
29
|
+
**Understand the workload:**
|
|
30
|
+
- Application type (stateless/stateful)
|
|
31
|
+
- Container image and version
|
|
32
|
+
- Environment variables and configuration needs
|
|
33
|
+
- Storage requirements
|
|
34
|
+
- Network exposure requirements (internal/external)
|
|
35
|
+
- Resource requirements (CPU, memory)
|
|
36
|
+
- Scaling requirements
|
|
37
|
+
- Health check endpoints
|
|
38
|
+
|
|
39
|
+
**Questions to ask:**
|
|
40
|
+
- What is the application name and purpose?
|
|
41
|
+
- What container image and tag will be used?
|
|
42
|
+
- Does the application need persistent storage?
|
|
43
|
+
- What ports does the application expose?
|
|
44
|
+
- Are there any secrets or configuration files needed?
|
|
45
|
+
- What are the CPU and memory requirements?
|
|
46
|
+
- Does the application need to be exposed externally?
|
|
47
|
+
|
|
48
|
+
### 2. Create Deployment Manifest
|
|
49
|
+
|
|
50
|
+
**Follow this structure:**
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
apiVersion: apps/v1
|
|
54
|
+
kind: Deployment
|
|
55
|
+
metadata:
|
|
56
|
+
name: <app-name>
|
|
57
|
+
namespace: <namespace>
|
|
58
|
+
labels:
|
|
59
|
+
app: <app-name>
|
|
60
|
+
version: <version>
|
|
61
|
+
spec:
|
|
62
|
+
replicas: 3
|
|
63
|
+
selector:
|
|
64
|
+
matchLabels:
|
|
65
|
+
app: <app-name>
|
|
66
|
+
template:
|
|
67
|
+
metadata:
|
|
68
|
+
labels:
|
|
69
|
+
app: <app-name>
|
|
70
|
+
version: <version>
|
|
71
|
+
spec:
|
|
72
|
+
containers:
|
|
73
|
+
- name: <container-name>
|
|
74
|
+
image: <image>:<tag>
|
|
75
|
+
ports:
|
|
76
|
+
- containerPort: <port>
|
|
77
|
+
name: http
|
|
78
|
+
resources:
|
|
79
|
+
requests:
|
|
80
|
+
memory: "256Mi"
|
|
81
|
+
cpu: "250m"
|
|
82
|
+
limits:
|
|
83
|
+
memory: "512Mi"
|
|
84
|
+
cpu: "500m"
|
|
85
|
+
livenessProbe:
|
|
86
|
+
httpGet:
|
|
87
|
+
path: /health
|
|
88
|
+
port: http
|
|
89
|
+
initialDelaySeconds: 30
|
|
90
|
+
periodSeconds: 10
|
|
91
|
+
readinessProbe:
|
|
92
|
+
httpGet:
|
|
93
|
+
path: /ready
|
|
94
|
+
port: http
|
|
95
|
+
initialDelaySeconds: 5
|
|
96
|
+
periodSeconds: 5
|
|
97
|
+
env:
|
|
98
|
+
- name: ENV_VAR
|
|
99
|
+
value: "value"
|
|
100
|
+
envFrom:
|
|
101
|
+
- configMapRef:
|
|
102
|
+
name: <app-name>-config
|
|
103
|
+
- secretRef:
|
|
104
|
+
name: <app-name>-secret
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Best practices to apply:**
|
|
108
|
+
- Always set resource requests and limits
|
|
109
|
+
- Implement both liveness and readiness probes
|
|
110
|
+
- Use specific image tags (never `:latest`)
|
|
111
|
+
- Apply security context for non-root users
|
|
112
|
+
- Use labels for organization and selection
|
|
113
|
+
- Set appropriate replica count based on availability needs
|
|
114
|
+
|
|
115
|
+
**Reference:** See `references/deployment-spec.md` for detailed deployment options
|
|
116
|
+
|
|
117
|
+
### 3. Create Service Manifest
|
|
118
|
+
|
|
119
|
+
**Choose the appropriate Service type:**
|
|
120
|
+
|
|
121
|
+
**ClusterIP (internal only):**
|
|
122
|
+
```yaml
|
|
123
|
+
apiVersion: v1
|
|
124
|
+
kind: Service
|
|
125
|
+
metadata:
|
|
126
|
+
name: <app-name>
|
|
127
|
+
namespace: <namespace>
|
|
128
|
+
labels:
|
|
129
|
+
app: <app-name>
|
|
130
|
+
spec:
|
|
131
|
+
type: ClusterIP
|
|
132
|
+
selector:
|
|
133
|
+
app: <app-name>
|
|
134
|
+
ports:
|
|
135
|
+
- name: http
|
|
136
|
+
port: 80
|
|
137
|
+
targetPort: 8080
|
|
138
|
+
protocol: TCP
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**LoadBalancer (external access):**
|
|
142
|
+
```yaml
|
|
143
|
+
apiVersion: v1
|
|
144
|
+
kind: Service
|
|
145
|
+
metadata:
|
|
146
|
+
name: <app-name>
|
|
147
|
+
namespace: <namespace>
|
|
148
|
+
labels:
|
|
149
|
+
app: <app-name>
|
|
150
|
+
annotations:
|
|
151
|
+
service.beta.kubernetes.io/aws-load-balancer-type: nlb
|
|
152
|
+
spec:
|
|
153
|
+
type: LoadBalancer
|
|
154
|
+
selector:
|
|
155
|
+
app: <app-name>
|
|
156
|
+
ports:
|
|
157
|
+
- name: http
|
|
158
|
+
port: 80
|
|
159
|
+
targetPort: 8080
|
|
160
|
+
protocol: TCP
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Reference:** See `references/service-spec.md` for service types and networking
|
|
164
|
+
|
|
165
|
+
### 4. Create ConfigMap
|
|
166
|
+
|
|
167
|
+
**For application configuration:**
|
|
168
|
+
|
|
169
|
+
```yaml
|
|
170
|
+
apiVersion: v1
|
|
171
|
+
kind: ConfigMap
|
|
172
|
+
metadata:
|
|
173
|
+
name: <app-name>-config
|
|
174
|
+
namespace: <namespace>
|
|
175
|
+
data:
|
|
176
|
+
APP_MODE: production
|
|
177
|
+
LOG_LEVEL: info
|
|
178
|
+
DATABASE_HOST: db.example.com
|
|
179
|
+
# For config files
|
|
180
|
+
app.properties: |
|
|
181
|
+
server.port=8080
|
|
182
|
+
server.host=0.0.0.0
|
|
183
|
+
logging.level=INFO
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Best practices:**
|
|
187
|
+
- Use ConfigMaps for non-sensitive data only
|
|
188
|
+
- Organize related configuration together
|
|
189
|
+
- Use meaningful names for keys
|
|
190
|
+
- Consider using one ConfigMap per component
|
|
191
|
+
- Version ConfigMaps when making changes
|
|
192
|
+
|
|
193
|
+
**Reference:** See `assets/configmap-template.yaml` for examples
|
|
194
|
+
|
|
195
|
+
### 5. Create Secret
|
|
196
|
+
|
|
197
|
+
**For sensitive data:**
|
|
198
|
+
|
|
199
|
+
```yaml
|
|
200
|
+
apiVersion: v1
|
|
201
|
+
kind: Secret
|
|
202
|
+
metadata:
|
|
203
|
+
name: <app-name>-secret
|
|
204
|
+
namespace: <namespace>
|
|
205
|
+
type: Opaque
|
|
206
|
+
stringData:
|
|
207
|
+
DATABASE_PASSWORD: "changeme"
|
|
208
|
+
API_KEY: "secret-api-key"
|
|
209
|
+
# For certificate files
|
|
210
|
+
tls.crt: |
|
|
211
|
+
-----BEGIN CERTIFICATE-----
|
|
212
|
+
...
|
|
213
|
+
-----END CERTIFICATE-----
|
|
214
|
+
tls.key: |
|
|
215
|
+
-----BEGIN PRIVATE KEY-----
|
|
216
|
+
...
|
|
217
|
+
-----END PRIVATE KEY-----
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**Security considerations:**
|
|
221
|
+
- Never commit secrets to Git in plain text
|
|
222
|
+
- Use Sealed Secrets, External Secrets Operator, or Vault
|
|
223
|
+
- Rotate secrets regularly
|
|
224
|
+
- Use RBAC to limit secret access
|
|
225
|
+
- Consider using Secret type: `kubernetes.io/tls` for TLS secrets
|
|
226
|
+
|
|
227
|
+
### 6. Create PersistentVolumeClaim (if needed)
|
|
228
|
+
|
|
229
|
+
**For stateful applications:**
|
|
230
|
+
|
|
231
|
+
```yaml
|
|
232
|
+
apiVersion: v1
|
|
233
|
+
kind: PersistentVolumeClaim
|
|
234
|
+
metadata:
|
|
235
|
+
name: <app-name>-data
|
|
236
|
+
namespace: <namespace>
|
|
237
|
+
spec:
|
|
238
|
+
accessModes:
|
|
239
|
+
- ReadWriteOnce
|
|
240
|
+
storageClassName: gp3
|
|
241
|
+
resources:
|
|
242
|
+
requests:
|
|
243
|
+
storage: 10Gi
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**Mount in Deployment:**
|
|
247
|
+
```yaml
|
|
248
|
+
spec:
|
|
249
|
+
template:
|
|
250
|
+
spec:
|
|
251
|
+
containers:
|
|
252
|
+
- name: app
|
|
253
|
+
volumeMounts:
|
|
254
|
+
- name: data
|
|
255
|
+
mountPath: /var/lib/app
|
|
256
|
+
volumes:
|
|
257
|
+
- name: data
|
|
258
|
+
persistentVolumeClaim:
|
|
259
|
+
claimName: <app-name>-data
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Storage considerations:**
|
|
263
|
+
- Choose appropriate StorageClass for performance needs
|
|
264
|
+
- Use ReadWriteOnce for single-pod access
|
|
265
|
+
- Use ReadWriteMany for multi-pod shared storage
|
|
266
|
+
- Consider backup strategies
|
|
267
|
+
- Set appropriate retention policies
|
|
268
|
+
|
|
269
|
+
### 7. Apply Security Best Practices
|
|
270
|
+
|
|
271
|
+
**Add security context to Deployment:**
|
|
272
|
+
|
|
273
|
+
```yaml
|
|
274
|
+
spec:
|
|
275
|
+
template:
|
|
276
|
+
spec:
|
|
277
|
+
securityContext:
|
|
278
|
+
runAsNonRoot: true
|
|
279
|
+
runAsUser: 1000
|
|
280
|
+
fsGroup: 1000
|
|
281
|
+
seccompProfile:
|
|
282
|
+
type: RuntimeDefault
|
|
283
|
+
containers:
|
|
284
|
+
- name: app
|
|
285
|
+
securityContext:
|
|
286
|
+
allowPrivilegeEscalation: false
|
|
287
|
+
readOnlyRootFilesystem: true
|
|
288
|
+
capabilities:
|
|
289
|
+
drop:
|
|
290
|
+
- ALL
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**Security checklist:**
|
|
294
|
+
- [ ] Run as non-root user
|
|
295
|
+
- [ ] Drop all capabilities
|
|
296
|
+
- [ ] Use read-only root filesystem
|
|
297
|
+
- [ ] Disable privilege escalation
|
|
298
|
+
- [ ] Set seccomp profile
|
|
299
|
+
- [ ] Use Pod Security Standards
|
|
300
|
+
|
|
301
|
+
### 8. Add Labels and Annotations
|
|
302
|
+
|
|
303
|
+
**Standard labels (recommended):**
|
|
304
|
+
|
|
305
|
+
```yaml
|
|
306
|
+
metadata:
|
|
307
|
+
labels:
|
|
308
|
+
app.kubernetes.io/name: <app-name>
|
|
309
|
+
app.kubernetes.io/instance: <instance-name>
|
|
310
|
+
app.kubernetes.io/version: "1.0.0"
|
|
311
|
+
app.kubernetes.io/component: backend
|
|
312
|
+
app.kubernetes.io/part-of: <system-name>
|
|
313
|
+
app.kubernetes.io/managed-by: kubectl
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**Useful annotations:**
|
|
317
|
+
|
|
318
|
+
```yaml
|
|
319
|
+
metadata:
|
|
320
|
+
annotations:
|
|
321
|
+
description: "Application description"
|
|
322
|
+
contact: "team@example.com"
|
|
323
|
+
prometheus.io/scrape: "true"
|
|
324
|
+
prometheus.io/port: "9090"
|
|
325
|
+
prometheus.io/path: "/metrics"
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### 9. Organize Multi-Resource Manifests
|
|
329
|
+
|
|
330
|
+
**File organization options:**
|
|
331
|
+
|
|
332
|
+
**Option 1: Single file with `---` separator**
|
|
333
|
+
```yaml
|
|
334
|
+
# app-name.yaml
|
|
335
|
+
---
|
|
336
|
+
apiVersion: v1
|
|
337
|
+
kind: ConfigMap
|
|
338
|
+
...
|
|
339
|
+
---
|
|
340
|
+
apiVersion: v1
|
|
341
|
+
kind: Secret
|
|
342
|
+
...
|
|
343
|
+
---
|
|
344
|
+
apiVersion: apps/v1
|
|
345
|
+
kind: Deployment
|
|
346
|
+
...
|
|
347
|
+
---
|
|
348
|
+
apiVersion: v1
|
|
349
|
+
kind: Service
|
|
350
|
+
...
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
**Option 2: Separate files**
|
|
354
|
+
```
|
|
355
|
+
manifests/
|
|
356
|
+
├── configmap.yaml
|
|
357
|
+
├── secret.yaml
|
|
358
|
+
├── deployment.yaml
|
|
359
|
+
├── service.yaml
|
|
360
|
+
└── pvc.yaml
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
**Option 3: Kustomize structure**
|
|
364
|
+
```
|
|
365
|
+
base/
|
|
366
|
+
├── kustomization.yaml
|
|
367
|
+
├── deployment.yaml
|
|
368
|
+
├── service.yaml
|
|
369
|
+
└── configmap.yaml
|
|
370
|
+
overlays/
|
|
371
|
+
├── dev/
|
|
372
|
+
│ └── kustomization.yaml
|
|
373
|
+
└── prod/
|
|
374
|
+
└── kustomization.yaml
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### 10. Validate and Test
|
|
378
|
+
|
|
379
|
+
**Validation steps:**
|
|
380
|
+
|
|
381
|
+
```bash
|
|
382
|
+
# Dry-run validation
|
|
383
|
+
kubectl apply -f manifest.yaml --dry-run=client
|
|
384
|
+
|
|
385
|
+
# Server-side validation
|
|
386
|
+
kubectl apply -f manifest.yaml --dry-run=server
|
|
387
|
+
|
|
388
|
+
# Validate with kubeval
|
|
389
|
+
kubeval manifest.yaml
|
|
390
|
+
|
|
391
|
+
# Validate with kube-score
|
|
392
|
+
kube-score score manifest.yaml
|
|
393
|
+
|
|
394
|
+
# Check with kube-linter
|
|
395
|
+
kube-linter lint manifest.yaml
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
**Testing checklist:**
|
|
399
|
+
- [ ] Manifest passes dry-run validation
|
|
400
|
+
- [ ] All required fields are present
|
|
401
|
+
- [ ] Resource limits are reasonable
|
|
402
|
+
- [ ] Health checks are configured
|
|
403
|
+
- [ ] Security context is set
|
|
404
|
+
- [ ] Labels follow conventions
|
|
405
|
+
- [ ] Namespace exists or is created
|
|
406
|
+
|
|
407
|
+
## Common Patterns
|
|
408
|
+
|
|
409
|
+
### Pattern 1: Simple Stateless Web Application
|
|
410
|
+
|
|
411
|
+
**Use case:** Standard web API or microservice
|
|
412
|
+
|
|
413
|
+
**Components needed:**
|
|
414
|
+
- Deployment (3 replicas for HA)
|
|
415
|
+
- ClusterIP Service
|
|
416
|
+
- ConfigMap for configuration
|
|
417
|
+
- Secret for API keys
|
|
418
|
+
- HorizontalPodAutoscaler (optional)
|
|
419
|
+
|
|
420
|
+
**Reference:** See `assets/deployment-template.yaml`
|
|
421
|
+
|
|
422
|
+
### Pattern 2: Stateful Database Application
|
|
423
|
+
|
|
424
|
+
**Use case:** Database or persistent storage application
|
|
425
|
+
|
|
426
|
+
**Components needed:**
|
|
427
|
+
- StatefulSet (not Deployment)
|
|
428
|
+
- Headless Service
|
|
429
|
+
- PersistentVolumeClaim template
|
|
430
|
+
- ConfigMap for DB configuration
|
|
431
|
+
- Secret for credentials
|
|
432
|
+
|
|
433
|
+
### Pattern 3: Background Job or Cron
|
|
434
|
+
|
|
435
|
+
**Use case:** Scheduled tasks or batch processing
|
|
436
|
+
|
|
437
|
+
**Components needed:**
|
|
438
|
+
- CronJob or Job
|
|
439
|
+
- ConfigMap for job parameters
|
|
440
|
+
- Secret for credentials
|
|
441
|
+
- ServiceAccount with RBAC
|
|
442
|
+
|
|
443
|
+
### Pattern 4: Multi-Container Pod
|
|
444
|
+
|
|
445
|
+
**Use case:** Application with sidecar containers
|
|
446
|
+
|
|
447
|
+
**Components needed:**
|
|
448
|
+
- Deployment with multiple containers
|
|
449
|
+
- Shared volumes between containers
|
|
450
|
+
- Init containers for setup
|
|
451
|
+
- Service (if needed)
|
|
452
|
+
|
|
453
|
+
## Templates
|
|
454
|
+
|
|
455
|
+
The following templates are available in the `assets/` directory:
|
|
456
|
+
|
|
457
|
+
- `deployment-template.yaml` - Standard deployment with best practices
|
|
458
|
+
- `service-template.yaml` - Service configurations (ClusterIP, LoadBalancer, NodePort)
|
|
459
|
+
- `configmap-template.yaml` - ConfigMap examples with different data types
|
|
460
|
+
- `secret-template.yaml` - Secret examples (to be generated, not committed)
|
|
461
|
+
- `pvc-template.yaml` - PersistentVolumeClaim templates
|
|
462
|
+
|
|
463
|
+
## Reference Documentation
|
|
464
|
+
|
|
465
|
+
- `references/deployment-spec.md` - Detailed Deployment specification
|
|
466
|
+
- `references/service-spec.md` - Service types and networking details
|
|
467
|
+
|
|
468
|
+
## Best Practices Summary
|
|
469
|
+
|
|
470
|
+
1. **Always set resource requests and limits** - Prevents resource starvation
|
|
471
|
+
2. **Implement health checks** - Ensures Kubernetes can manage your application
|
|
472
|
+
3. **Use specific image tags** - Avoid unpredictable deployments
|
|
473
|
+
4. **Apply security contexts** - Run as non-root, drop capabilities
|
|
474
|
+
5. **Use ConfigMaps and Secrets** - Separate config from code
|
|
475
|
+
6. **Label everything** - Enables filtering and organization
|
|
476
|
+
7. **Follow naming conventions** - Use standard Kubernetes labels
|
|
477
|
+
8. **Validate before applying** - Use dry-run and validation tools
|
|
478
|
+
9. **Version your manifests** - Keep in Git with version control
|
|
479
|
+
10. **Document with annotations** - Add context for other developers
|
|
480
|
+
|
|
481
|
+
## Troubleshooting
|
|
482
|
+
|
|
483
|
+
**Pods not starting:**
|
|
484
|
+
- Check image pull errors: `kubectl describe pod <pod-name>`
|
|
485
|
+
- Verify resource availability: `kubectl get nodes`
|
|
486
|
+
- Check events: `kubectl get events --sort-by='.lastTimestamp'`
|
|
487
|
+
|
|
488
|
+
**Service not accessible:**
|
|
489
|
+
- Verify selector matches pod labels: `kubectl get endpoints <service-name>`
|
|
490
|
+
- Check service type and port configuration
|
|
491
|
+
- Test from within cluster: `kubectl run debug --rm -it --image=busybox -- sh`
|
|
492
|
+
|
|
493
|
+
**ConfigMap/Secret not loading:**
|
|
494
|
+
- Verify names match in Deployment
|
|
495
|
+
- Check namespace
|
|
496
|
+
- Ensure resources exist: `kubectl get configmap,secret`
|
|
497
|
+
|
|
498
|
+
## Next Steps
|
|
499
|
+
|
|
500
|
+
After creating manifests:
|
|
501
|
+
1. Store in Git repository
|
|
502
|
+
2. Set up CI/CD pipeline for deployment
|
|
503
|
+
3. Consider using Helm or Kustomize for templating
|
|
504
|
+
4. Implement GitOps with ArgoCD or Flux
|
|
505
|
+
5. Add monitoring and observability
|
|
506
|
+
|
|
507
|
+
## Related Skills
|
|
508
|
+
|
|
509
|
+
- `helm-chart-scaffolding` - For templating and packaging
|
|
510
|
+
- `gitops-workflow` - For automated deployments
|
|
511
|
+
- `k8s-security-policies` - For advanced security configurations
|