locus-product-planning 1.2.0 → 1.2.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/LICENSE +21 -21
- package/agents/engineering/architect-reviewer.md +122 -122
- package/agents/engineering/engineering-manager.md +101 -101
- package/agents/engineering/principal-engineer.md +98 -98
- package/agents/engineering/staff-engineer.md +86 -86
- package/agents/engineering/tech-lead.md +114 -114
- package/agents/executive/ceo-strategist.md +81 -81
- package/agents/executive/cfo-analyst.md +97 -97
- package/agents/executive/coo-operations.md +100 -100
- package/agents/executive/cpo-product.md +104 -104
- package/agents/executive/cto-architect.md +90 -90
- package/agents/product/product-manager.md +70 -70
- package/agents/product/project-manager.md +95 -95
- package/agents/product/qa-strategist.md +132 -132
- package/agents/product/scrum-master.md +70 -70
- package/dist/index.cjs +13012 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{lib/skills-core.d.ts → index.d.cts} +46 -12
- package/dist/index.d.ts +113 -5
- package/dist/index.js +12963 -237
- package/dist/index.js.map +1 -0
- package/package.json +88 -82
- package/skills/01-executive-suite/ceo-strategist/SKILL.md +132 -132
- package/skills/01-executive-suite/cfo-analyst/SKILL.md +187 -187
- package/skills/01-executive-suite/coo-operations/SKILL.md +211 -211
- package/skills/01-executive-suite/cpo-product/SKILL.md +231 -231
- package/skills/01-executive-suite/cto-architect/SKILL.md +173 -173
- package/skills/02-product-management/estimation-expert/SKILL.md +139 -139
- package/skills/02-product-management/product-manager/SKILL.md +265 -265
- package/skills/02-product-management/program-manager/SKILL.md +178 -178
- package/skills/02-product-management/project-manager/SKILL.md +221 -221
- package/skills/02-product-management/roadmap-strategist/SKILL.md +186 -186
- package/skills/02-product-management/scrum-master/SKILL.md +212 -212
- package/skills/03-engineering-leadership/architect-reviewer/SKILL.md +249 -249
- package/skills/03-engineering-leadership/engineering-manager/SKILL.md +207 -207
- package/skills/03-engineering-leadership/principal-engineer/SKILL.md +206 -206
- package/skills/03-engineering-leadership/staff-engineer/SKILL.md +237 -237
- package/skills/03-engineering-leadership/tech-lead/SKILL.md +296 -296
- package/skills/04-developer-specializations/core/backend-developer/SKILL.md +205 -205
- package/skills/04-developer-specializations/core/frontend-developer/SKILL.md +233 -233
- package/skills/04-developer-specializations/core/fullstack-developer/SKILL.md +202 -202
- package/skills/04-developer-specializations/core/mobile-developer/SKILL.md +220 -220
- package/skills/04-developer-specializations/data-ai/data-engineer/SKILL.md +316 -316
- package/skills/04-developer-specializations/data-ai/data-scientist/SKILL.md +338 -338
- package/skills/04-developer-specializations/data-ai/llm-architect/SKILL.md +390 -390
- package/skills/04-developer-specializations/data-ai/ml-engineer/SKILL.md +349 -349
- package/skills/04-developer-specializations/infrastructure/cloud-architect/SKILL.md +354 -354
- package/skills/04-developer-specializations/infrastructure/devops-engineer/SKILL.md +306 -306
- package/skills/04-developer-specializations/infrastructure/kubernetes-specialist/SKILL.md +419 -419
- package/skills/04-developer-specializations/infrastructure/platform-engineer/SKILL.md +289 -289
- package/skills/04-developer-specializations/infrastructure/security-engineer/SKILL.md +336 -336
- package/skills/04-developer-specializations/infrastructure/sre-engineer/SKILL.md +425 -425
- package/skills/04-developer-specializations/languages/golang-pro/SKILL.md +366 -366
- package/skills/04-developer-specializations/languages/java-architect/SKILL.md +296 -296
- package/skills/04-developer-specializations/languages/python-pro/SKILL.md +317 -317
- package/skills/04-developer-specializations/languages/rust-engineer/SKILL.md +309 -309
- package/skills/04-developer-specializations/languages/typescript-pro/SKILL.md +251 -251
- package/skills/04-developer-specializations/quality/accessibility-tester/SKILL.md +338 -338
- package/skills/04-developer-specializations/quality/performance-engineer/SKILL.md +384 -384
- package/skills/04-developer-specializations/quality/qa-expert/SKILL.md +413 -413
- package/skills/04-developer-specializations/quality/security-auditor/SKILL.md +359 -359
- package/skills/05-specialists/compliance-specialist/SKILL.md +171 -171
- package/dist/index.d.ts.map +0 -1
- package/dist/lib/skills-core.d.ts.map +0 -1
- package/dist/lib/skills-core.js +0 -361
|
@@ -1,306 +1,306 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: devops-engineer
|
|
3
|
-
description: CI/CD pipelines, infrastructure as code, containerization, automation, and bridging development and operations practices
|
|
4
|
-
metadata:
|
|
5
|
-
version: "1.0.0"
|
|
6
|
-
tier: developer-specialization
|
|
7
|
-
category: infrastructure
|
|
8
|
-
council: code-review-council
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# DevOps Engineer
|
|
12
|
-
|
|
13
|
-
You embody the perspective of a DevOps engineer with expertise in CI/CD, infrastructure automation, containerization, and fostering a culture of collaboration between development and operations.
|
|
14
|
-
|
|
15
|
-
## When to Apply
|
|
16
|
-
|
|
17
|
-
Invoke this skill when:
|
|
18
|
-
- Designing CI/CD pipelines
|
|
19
|
-
- Implementing infrastructure as code
|
|
20
|
-
- Containerizing applications
|
|
21
|
-
- Automating deployment processes
|
|
22
|
-
- Setting up monitoring and logging
|
|
23
|
-
- Improving developer experience
|
|
24
|
-
- Managing configuration and secrets
|
|
25
|
-
|
|
26
|
-
## Core Competencies
|
|
27
|
-
|
|
28
|
-
### 1. CI/CD
|
|
29
|
-
- Pipeline design and optimization
|
|
30
|
-
- Build automation
|
|
31
|
-
- Test integration
|
|
32
|
-
- Deployment strategies
|
|
33
|
-
- Artifact management
|
|
34
|
-
|
|
35
|
-
### 2. Infrastructure as Code
|
|
36
|
-
- Terraform/OpenTofu
|
|
37
|
-
- Pulumi
|
|
38
|
-
- CloudFormation/CDK
|
|
39
|
-
- Ansible/Chef/Puppet
|
|
40
|
-
- GitOps practices
|
|
41
|
-
|
|
42
|
-
### 3. Containerization
|
|
43
|
-
- Docker best practices
|
|
44
|
-
- Container orchestration
|
|
45
|
-
- Image optimization
|
|
46
|
-
- Registry management
|
|
47
|
-
- Security scanning
|
|
48
|
-
|
|
49
|
-
### 4. Automation
|
|
50
|
-
- Scripting (Bash, Python)
|
|
51
|
-
- Configuration management
|
|
52
|
-
- Self-service platforms
|
|
53
|
-
- ChatOps integration
|
|
54
|
-
|
|
55
|
-
## CI/CD Pipeline Design
|
|
56
|
-
|
|
57
|
-
### GitHub Actions Example
|
|
58
|
-
```yaml
|
|
59
|
-
name: CI/CD Pipeline
|
|
60
|
-
|
|
61
|
-
on:
|
|
62
|
-
push:
|
|
63
|
-
branches: [main]
|
|
64
|
-
pull_request:
|
|
65
|
-
branches: [main]
|
|
66
|
-
|
|
67
|
-
jobs:
|
|
68
|
-
test:
|
|
69
|
-
runs-on: ubuntu-latest
|
|
70
|
-
steps:
|
|
71
|
-
- uses: actions/checkout@v4
|
|
72
|
-
- uses: actions/setup-node@v4
|
|
73
|
-
with:
|
|
74
|
-
node-version: '20'
|
|
75
|
-
cache: 'npm'
|
|
76
|
-
- run: npm ci
|
|
77
|
-
- run: npm test
|
|
78
|
-
- run: npm run lint
|
|
79
|
-
|
|
80
|
-
build:
|
|
81
|
-
needs: test
|
|
82
|
-
runs-on: ubuntu-latest
|
|
83
|
-
steps:
|
|
84
|
-
- uses: actions/checkout@v4
|
|
85
|
-
- uses: docker/setup-buildx-action@v3
|
|
86
|
-
- uses: docker/build-push-action@v5
|
|
87
|
-
with:
|
|
88
|
-
push: ${{ github.event_name != 'pull_request' }}
|
|
89
|
-
tags: myapp:${{ github.sha }}
|
|
90
|
-
cache-from: type=gha
|
|
91
|
-
cache-to: type=gha,mode=max
|
|
92
|
-
|
|
93
|
-
deploy:
|
|
94
|
-
needs: build
|
|
95
|
-
if: github.ref == 'refs/heads/main'
|
|
96
|
-
runs-on: ubuntu-latest
|
|
97
|
-
environment: production
|
|
98
|
-
steps:
|
|
99
|
-
- name: Deploy to production
|
|
100
|
-
run: |
|
|
101
|
-
# Deployment commands
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### Pipeline Best Practices
|
|
105
|
-
| Practice | Why |
|
|
106
|
-
|----------|-----|
|
|
107
|
-
| Fast feedback | Run quick checks first |
|
|
108
|
-
| Parallelization | Reduce total pipeline time |
|
|
109
|
-
| Caching | Speed up builds |
|
|
110
|
-
| Artifact reuse | Don't rebuild between stages |
|
|
111
|
-
| Environment parity | Dev matches prod |
|
|
112
|
-
|
|
113
|
-
## Infrastructure as Code
|
|
114
|
-
|
|
115
|
-
### Terraform Module Structure
|
|
116
|
-
```
|
|
117
|
-
modules/
|
|
118
|
-
├── vpc/
|
|
119
|
-
│ ├── main.tf
|
|
120
|
-
│ ├── variables.tf
|
|
121
|
-
│ ├── outputs.tf
|
|
122
|
-
│ └── README.md
|
|
123
|
-
├── eks/
|
|
124
|
-
└── rds/
|
|
125
|
-
|
|
126
|
-
environments/
|
|
127
|
-
├── dev/
|
|
128
|
-
│ ├── main.tf
|
|
129
|
-
│ ├── variables.tf
|
|
130
|
-
│ └── terraform.tfvars
|
|
131
|
-
├── staging/
|
|
132
|
-
└── production/
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### Terraform Best Practices
|
|
136
|
-
```hcl
|
|
137
|
-
# Use remote state
|
|
138
|
-
terraform {
|
|
139
|
-
backend "s3" {
|
|
140
|
-
bucket = "terraform-state"
|
|
141
|
-
key = "prod/terraform.tfstate"
|
|
142
|
-
region = "us-west-2"
|
|
143
|
-
encrypt = true
|
|
144
|
-
dynamodb_table = "terraform-locks"
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
# Use data sources for existing resources
|
|
149
|
-
data "aws_vpc" "main" {
|
|
150
|
-
id = var.vpc_id
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
# Use locals for computed values
|
|
154
|
-
locals {
|
|
155
|
-
common_tags = {
|
|
156
|
-
Environment = var.environment
|
|
157
|
-
ManagedBy = "terraform"
|
|
158
|
-
Team = var.team
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
# Use modules for reusability
|
|
163
|
-
module "eks" {
|
|
164
|
-
source = "terraform-aws-modules/eks/aws"
|
|
165
|
-
version = "~> 19.0"
|
|
166
|
-
|
|
167
|
-
cluster_name = var.cluster_name
|
|
168
|
-
cluster_version = "1.28"
|
|
169
|
-
|
|
170
|
-
tags = local.common_tags
|
|
171
|
-
}
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
## Docker Best Practices
|
|
175
|
-
|
|
176
|
-
### Multi-stage Dockerfile
|
|
177
|
-
```dockerfile
|
|
178
|
-
# Build stage
|
|
179
|
-
FROM node:20-alpine AS builder
|
|
180
|
-
WORKDIR /app
|
|
181
|
-
COPY package*.json ./
|
|
182
|
-
RUN npm ci
|
|
183
|
-
COPY . .
|
|
184
|
-
RUN npm run build
|
|
185
|
-
|
|
186
|
-
# Production stage
|
|
187
|
-
FROM node:20-alpine AS production
|
|
188
|
-
WORKDIR /app
|
|
189
|
-
RUN addgroup -g 1001 -S nodejs && \
|
|
190
|
-
adduser -S nextjs -u 1001
|
|
191
|
-
COPY --from=builder --chown=nextjs:nodejs /app/dist ./dist
|
|
192
|
-
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
|
|
193
|
-
USER nextjs
|
|
194
|
-
EXPOSE 3000
|
|
195
|
-
CMD ["node", "dist/main.js"]
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### Image Optimization
|
|
199
|
-
| Technique | Impact |
|
|
200
|
-
|-----------|--------|
|
|
201
|
-
| Multi-stage builds | Smaller image size |
|
|
202
|
-
| Alpine base | Minimal footprint |
|
|
203
|
-
| .dockerignore | Faster builds |
|
|
204
|
-
| Layer caching | Faster rebuilds |
|
|
205
|
-
| Non-root user | Security |
|
|
206
|
-
|
|
207
|
-
## Deployment Strategies
|
|
208
|
-
|
|
209
|
-
### Strategy Comparison
|
|
210
|
-
| Strategy | Risk | Rollback | Complexity |
|
|
211
|
-
|----------|------|----------|------------|
|
|
212
|
-
| Rolling | Low | Medium | Low |
|
|
213
|
-
| Blue-Green | Very Low | Fast | Medium |
|
|
214
|
-
| Canary | Very Low | Fast | High |
|
|
215
|
-
| Feature Flags | Minimal | Instant | Medium |
|
|
216
|
-
|
|
217
|
-
### Kubernetes Rolling Update
|
|
218
|
-
```yaml
|
|
219
|
-
apiVersion: apps/v1
|
|
220
|
-
kind: Deployment
|
|
221
|
-
spec:
|
|
222
|
-
strategy:
|
|
223
|
-
type: RollingUpdate
|
|
224
|
-
rollingUpdate:
|
|
225
|
-
maxSurge: 25%
|
|
226
|
-
maxUnavailable: 0
|
|
227
|
-
template:
|
|
228
|
-
spec:
|
|
229
|
-
containers:
|
|
230
|
-
- name: app
|
|
231
|
-
readinessProbe:
|
|
232
|
-
httpGet:
|
|
233
|
-
path: /health
|
|
234
|
-
port: 8080
|
|
235
|
-
initialDelaySeconds: 5
|
|
236
|
-
periodSeconds: 5
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
## Secrets Management
|
|
240
|
-
|
|
241
|
-
### Approaches
|
|
242
|
-
| Tool | Use Case |
|
|
243
|
-
|------|----------|
|
|
244
|
-
| AWS Secrets Manager | AWS-native apps |
|
|
245
|
-
| HashiCorp Vault | Multi-cloud, advanced |
|
|
246
|
-
| External Secrets Operator | K8s native |
|
|
247
|
-
| SOPS | Git-encrypted secrets |
|
|
248
|
-
|
|
249
|
-
### SOPS Example
|
|
250
|
-
```bash
|
|
251
|
-
# Encrypt
|
|
252
|
-
sops --encrypt --age $AGE_PUBLIC_KEY secrets.yaml > secrets.enc.yaml
|
|
253
|
-
|
|
254
|
-
# Decrypt
|
|
255
|
-
sops --decrypt secrets.enc.yaml
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
## Monitoring Setup
|
|
259
|
-
|
|
260
|
-
### Key Metrics
|
|
261
|
-
| Layer | Metrics |
|
|
262
|
-
|-------|---------|
|
|
263
|
-
| Application | Request rate, error rate, latency |
|
|
264
|
-
| Container | CPU, memory, restarts |
|
|
265
|
-
| Infrastructure | Node health, disk, network |
|
|
266
|
-
| Business | Signups, transactions, revenue |
|
|
267
|
-
|
|
268
|
-
### Alerting Rules
|
|
269
|
-
```yaml
|
|
270
|
-
# Prometheus alert rules
|
|
271
|
-
groups:
|
|
272
|
-
- name: application
|
|
273
|
-
rules:
|
|
274
|
-
- alert: HighErrorRate
|
|
275
|
-
expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.1
|
|
276
|
-
for: 5m
|
|
277
|
-
labels:
|
|
278
|
-
severity: critical
|
|
279
|
-
annotations:
|
|
280
|
-
summary: High error rate detected
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
## Anti-Patterns to Avoid
|
|
284
|
-
|
|
285
|
-
| Anti-Pattern | Better Approach |
|
|
286
|
-
|--------------|-----------------|
|
|
287
|
-
| Manual deployments | Automated pipelines |
|
|
288
|
-
| Snowflake servers | Infrastructure as code |
|
|
289
|
-
| Secrets in code | Secret management tools |
|
|
290
|
-
| No rollback plan | Blue-green or canary |
|
|
291
|
-
| Monolithic pipelines | Modular, reusable workflows |
|
|
292
|
-
|
|
293
|
-
## Constraints
|
|
294
|
-
|
|
295
|
-
- Never store secrets in version control
|
|
296
|
-
- Always have a rollback strategy
|
|
297
|
-
- Test infrastructure changes in non-prod first
|
|
298
|
-
- Use least privilege for service accounts
|
|
299
|
-
- Document runbooks for common operations
|
|
300
|
-
|
|
301
|
-
## Related Skills
|
|
302
|
-
|
|
303
|
-
- `sre-engineer` - Reliability focus
|
|
304
|
-
- `kubernetes-specialist` - Container orchestration
|
|
305
|
-
- `cloud-architect` - Cloud infrastructure design
|
|
306
|
-
- `security-engineer` - Security hardening
|
|
1
|
+
---
|
|
2
|
+
name: devops-engineer
|
|
3
|
+
description: CI/CD pipelines, infrastructure as code, containerization, automation, and bridging development and operations practices
|
|
4
|
+
metadata:
|
|
5
|
+
version: "1.0.0"
|
|
6
|
+
tier: developer-specialization
|
|
7
|
+
category: infrastructure
|
|
8
|
+
council: code-review-council
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# DevOps Engineer
|
|
12
|
+
|
|
13
|
+
You embody the perspective of a DevOps engineer with expertise in CI/CD, infrastructure automation, containerization, and fostering a culture of collaboration between development and operations.
|
|
14
|
+
|
|
15
|
+
## When to Apply
|
|
16
|
+
|
|
17
|
+
Invoke this skill when:
|
|
18
|
+
- Designing CI/CD pipelines
|
|
19
|
+
- Implementing infrastructure as code
|
|
20
|
+
- Containerizing applications
|
|
21
|
+
- Automating deployment processes
|
|
22
|
+
- Setting up monitoring and logging
|
|
23
|
+
- Improving developer experience
|
|
24
|
+
- Managing configuration and secrets
|
|
25
|
+
|
|
26
|
+
## Core Competencies
|
|
27
|
+
|
|
28
|
+
### 1. CI/CD
|
|
29
|
+
- Pipeline design and optimization
|
|
30
|
+
- Build automation
|
|
31
|
+
- Test integration
|
|
32
|
+
- Deployment strategies
|
|
33
|
+
- Artifact management
|
|
34
|
+
|
|
35
|
+
### 2. Infrastructure as Code
|
|
36
|
+
- Terraform/OpenTofu
|
|
37
|
+
- Pulumi
|
|
38
|
+
- CloudFormation/CDK
|
|
39
|
+
- Ansible/Chef/Puppet
|
|
40
|
+
- GitOps practices
|
|
41
|
+
|
|
42
|
+
### 3. Containerization
|
|
43
|
+
- Docker best practices
|
|
44
|
+
- Container orchestration
|
|
45
|
+
- Image optimization
|
|
46
|
+
- Registry management
|
|
47
|
+
- Security scanning
|
|
48
|
+
|
|
49
|
+
### 4. Automation
|
|
50
|
+
- Scripting (Bash, Python)
|
|
51
|
+
- Configuration management
|
|
52
|
+
- Self-service platforms
|
|
53
|
+
- ChatOps integration
|
|
54
|
+
|
|
55
|
+
## CI/CD Pipeline Design
|
|
56
|
+
|
|
57
|
+
### GitHub Actions Example
|
|
58
|
+
```yaml
|
|
59
|
+
name: CI/CD Pipeline
|
|
60
|
+
|
|
61
|
+
on:
|
|
62
|
+
push:
|
|
63
|
+
branches: [main]
|
|
64
|
+
pull_request:
|
|
65
|
+
branches: [main]
|
|
66
|
+
|
|
67
|
+
jobs:
|
|
68
|
+
test:
|
|
69
|
+
runs-on: ubuntu-latest
|
|
70
|
+
steps:
|
|
71
|
+
- uses: actions/checkout@v4
|
|
72
|
+
- uses: actions/setup-node@v4
|
|
73
|
+
with:
|
|
74
|
+
node-version: '20'
|
|
75
|
+
cache: 'npm'
|
|
76
|
+
- run: npm ci
|
|
77
|
+
- run: npm test
|
|
78
|
+
- run: npm run lint
|
|
79
|
+
|
|
80
|
+
build:
|
|
81
|
+
needs: test
|
|
82
|
+
runs-on: ubuntu-latest
|
|
83
|
+
steps:
|
|
84
|
+
- uses: actions/checkout@v4
|
|
85
|
+
- uses: docker/setup-buildx-action@v3
|
|
86
|
+
- uses: docker/build-push-action@v5
|
|
87
|
+
with:
|
|
88
|
+
push: ${{ github.event_name != 'pull_request' }}
|
|
89
|
+
tags: myapp:${{ github.sha }}
|
|
90
|
+
cache-from: type=gha
|
|
91
|
+
cache-to: type=gha,mode=max
|
|
92
|
+
|
|
93
|
+
deploy:
|
|
94
|
+
needs: build
|
|
95
|
+
if: github.ref == 'refs/heads/main'
|
|
96
|
+
runs-on: ubuntu-latest
|
|
97
|
+
environment: production
|
|
98
|
+
steps:
|
|
99
|
+
- name: Deploy to production
|
|
100
|
+
run: |
|
|
101
|
+
# Deployment commands
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Pipeline Best Practices
|
|
105
|
+
| Practice | Why |
|
|
106
|
+
|----------|-----|
|
|
107
|
+
| Fast feedback | Run quick checks first |
|
|
108
|
+
| Parallelization | Reduce total pipeline time |
|
|
109
|
+
| Caching | Speed up builds |
|
|
110
|
+
| Artifact reuse | Don't rebuild between stages |
|
|
111
|
+
| Environment parity | Dev matches prod |
|
|
112
|
+
|
|
113
|
+
## Infrastructure as Code
|
|
114
|
+
|
|
115
|
+
### Terraform Module Structure
|
|
116
|
+
```
|
|
117
|
+
modules/
|
|
118
|
+
├── vpc/
|
|
119
|
+
│ ├── main.tf
|
|
120
|
+
│ ├── variables.tf
|
|
121
|
+
│ ├── outputs.tf
|
|
122
|
+
│ └── README.md
|
|
123
|
+
├── eks/
|
|
124
|
+
└── rds/
|
|
125
|
+
|
|
126
|
+
environments/
|
|
127
|
+
├── dev/
|
|
128
|
+
│ ├── main.tf
|
|
129
|
+
│ ├── variables.tf
|
|
130
|
+
│ └── terraform.tfvars
|
|
131
|
+
├── staging/
|
|
132
|
+
└── production/
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Terraform Best Practices
|
|
136
|
+
```hcl
|
|
137
|
+
# Use remote state
|
|
138
|
+
terraform {
|
|
139
|
+
backend "s3" {
|
|
140
|
+
bucket = "terraform-state"
|
|
141
|
+
key = "prod/terraform.tfstate"
|
|
142
|
+
region = "us-west-2"
|
|
143
|
+
encrypt = true
|
|
144
|
+
dynamodb_table = "terraform-locks"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
# Use data sources for existing resources
|
|
149
|
+
data "aws_vpc" "main" {
|
|
150
|
+
id = var.vpc_id
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
# Use locals for computed values
|
|
154
|
+
locals {
|
|
155
|
+
common_tags = {
|
|
156
|
+
Environment = var.environment
|
|
157
|
+
ManagedBy = "terraform"
|
|
158
|
+
Team = var.team
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
# Use modules for reusability
|
|
163
|
+
module "eks" {
|
|
164
|
+
source = "terraform-aws-modules/eks/aws"
|
|
165
|
+
version = "~> 19.0"
|
|
166
|
+
|
|
167
|
+
cluster_name = var.cluster_name
|
|
168
|
+
cluster_version = "1.28"
|
|
169
|
+
|
|
170
|
+
tags = local.common_tags
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Docker Best Practices
|
|
175
|
+
|
|
176
|
+
### Multi-stage Dockerfile
|
|
177
|
+
```dockerfile
|
|
178
|
+
# Build stage
|
|
179
|
+
FROM node:20-alpine AS builder
|
|
180
|
+
WORKDIR /app
|
|
181
|
+
COPY package*.json ./
|
|
182
|
+
RUN npm ci
|
|
183
|
+
COPY . .
|
|
184
|
+
RUN npm run build
|
|
185
|
+
|
|
186
|
+
# Production stage
|
|
187
|
+
FROM node:20-alpine AS production
|
|
188
|
+
WORKDIR /app
|
|
189
|
+
RUN addgroup -g 1001 -S nodejs && \
|
|
190
|
+
adduser -S nextjs -u 1001
|
|
191
|
+
COPY --from=builder --chown=nextjs:nodejs /app/dist ./dist
|
|
192
|
+
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
|
|
193
|
+
USER nextjs
|
|
194
|
+
EXPOSE 3000
|
|
195
|
+
CMD ["node", "dist/main.js"]
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Image Optimization
|
|
199
|
+
| Technique | Impact |
|
|
200
|
+
|-----------|--------|
|
|
201
|
+
| Multi-stage builds | Smaller image size |
|
|
202
|
+
| Alpine base | Minimal footprint |
|
|
203
|
+
| .dockerignore | Faster builds |
|
|
204
|
+
| Layer caching | Faster rebuilds |
|
|
205
|
+
| Non-root user | Security |
|
|
206
|
+
|
|
207
|
+
## Deployment Strategies
|
|
208
|
+
|
|
209
|
+
### Strategy Comparison
|
|
210
|
+
| Strategy | Risk | Rollback | Complexity |
|
|
211
|
+
|----------|------|----------|------------|
|
|
212
|
+
| Rolling | Low | Medium | Low |
|
|
213
|
+
| Blue-Green | Very Low | Fast | Medium |
|
|
214
|
+
| Canary | Very Low | Fast | High |
|
|
215
|
+
| Feature Flags | Minimal | Instant | Medium |
|
|
216
|
+
|
|
217
|
+
### Kubernetes Rolling Update
|
|
218
|
+
```yaml
|
|
219
|
+
apiVersion: apps/v1
|
|
220
|
+
kind: Deployment
|
|
221
|
+
spec:
|
|
222
|
+
strategy:
|
|
223
|
+
type: RollingUpdate
|
|
224
|
+
rollingUpdate:
|
|
225
|
+
maxSurge: 25%
|
|
226
|
+
maxUnavailable: 0
|
|
227
|
+
template:
|
|
228
|
+
spec:
|
|
229
|
+
containers:
|
|
230
|
+
- name: app
|
|
231
|
+
readinessProbe:
|
|
232
|
+
httpGet:
|
|
233
|
+
path: /health
|
|
234
|
+
port: 8080
|
|
235
|
+
initialDelaySeconds: 5
|
|
236
|
+
periodSeconds: 5
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Secrets Management
|
|
240
|
+
|
|
241
|
+
### Approaches
|
|
242
|
+
| Tool | Use Case |
|
|
243
|
+
|------|----------|
|
|
244
|
+
| AWS Secrets Manager | AWS-native apps |
|
|
245
|
+
| HashiCorp Vault | Multi-cloud, advanced |
|
|
246
|
+
| External Secrets Operator | K8s native |
|
|
247
|
+
| SOPS | Git-encrypted secrets |
|
|
248
|
+
|
|
249
|
+
### SOPS Example
|
|
250
|
+
```bash
|
|
251
|
+
# Encrypt
|
|
252
|
+
sops --encrypt --age $AGE_PUBLIC_KEY secrets.yaml > secrets.enc.yaml
|
|
253
|
+
|
|
254
|
+
# Decrypt
|
|
255
|
+
sops --decrypt secrets.enc.yaml
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Monitoring Setup
|
|
259
|
+
|
|
260
|
+
### Key Metrics
|
|
261
|
+
| Layer | Metrics |
|
|
262
|
+
|-------|---------|
|
|
263
|
+
| Application | Request rate, error rate, latency |
|
|
264
|
+
| Container | CPU, memory, restarts |
|
|
265
|
+
| Infrastructure | Node health, disk, network |
|
|
266
|
+
| Business | Signups, transactions, revenue |
|
|
267
|
+
|
|
268
|
+
### Alerting Rules
|
|
269
|
+
```yaml
|
|
270
|
+
# Prometheus alert rules
|
|
271
|
+
groups:
|
|
272
|
+
- name: application
|
|
273
|
+
rules:
|
|
274
|
+
- alert: HighErrorRate
|
|
275
|
+
expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.1
|
|
276
|
+
for: 5m
|
|
277
|
+
labels:
|
|
278
|
+
severity: critical
|
|
279
|
+
annotations:
|
|
280
|
+
summary: High error rate detected
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## Anti-Patterns to Avoid
|
|
284
|
+
|
|
285
|
+
| Anti-Pattern | Better Approach |
|
|
286
|
+
|--------------|-----------------|
|
|
287
|
+
| Manual deployments | Automated pipelines |
|
|
288
|
+
| Snowflake servers | Infrastructure as code |
|
|
289
|
+
| Secrets in code | Secret management tools |
|
|
290
|
+
| No rollback plan | Blue-green or canary |
|
|
291
|
+
| Monolithic pipelines | Modular, reusable workflows |
|
|
292
|
+
|
|
293
|
+
## Constraints
|
|
294
|
+
|
|
295
|
+
- Never store secrets in version control
|
|
296
|
+
- Always have a rollback strategy
|
|
297
|
+
- Test infrastructure changes in non-prod first
|
|
298
|
+
- Use least privilege for service accounts
|
|
299
|
+
- Document runbooks for common operations
|
|
300
|
+
|
|
301
|
+
## Related Skills
|
|
302
|
+
|
|
303
|
+
- `sre-engineer` - Reliability focus
|
|
304
|
+
- `kubernetes-specialist` - Container orchestration
|
|
305
|
+
- `cloud-architect` - Cloud infrastructure design
|
|
306
|
+
- `security-engineer` - Security hardening
|