DEVOPS-CLOUD SuperSkill
Заменяет: devops-automation, docker-best-practices, kubernetes-operations, ci-cd-pipelines, monitoring-observability, aws-cloud-patterns (6 скилов)
Триггеры: "docker", "kubernetes", "CI/CD", "деплой", "AWS", "nginx", "systemd", "devops", "monitoring", "Helm"
Атомов: 87
КОГДА ПРИМЕНЯТЬ
Настройка CI/CD pipeline (GitHub Actions, GitLab CI)
Docker: Dockerfile, compose, оптимизация образов
Kubernetes: манифесты, Helm charts, troubleshooting
Мониторинг: OpenTelemetry, Prometheus, Grafana
AWS: Lambda, ECS, DynamoDB, CDK/Terraform
Деплой: blue-green, canary, rolling updates
КЛЮЧЕВЫЕ ПРИНЦИПЫ
Multi-stage Docker builds : deps → build → runtime. Final stage только runtime artifacts + non-root user
K8s: always set resources : requests + limits на каждом контейнере, topologySpreadConstraints для HA
CI/CD: concurrency + needs : cancel-in-progress: true для stale runs, needs для зависимостей между jobs
Observability = traces + metrics + logs : OpenTelemetry SDK → OTLP collector → backends. Structured JSON logging
AWS Lambda: init outside handler : SDK clients вне handler для переиспользования между invocations
DynamoDB: access patterns first : Single-table design, composite keys (PK + SK), GSI для альтернативных запросов
IaC: CDK/Terraform over console : Всё в коде, state в remote backend, plan перед apply
ПАТТЕРНЫ И ТЕХНИКИ
Docker
FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --only=production
FROM node:22-alpine AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:22-alpine AS runtime
WORKDIR /app
RUN addgroup -g 1001 -S app && adduser -S app -u 1001 -G app
COPY --from=deps /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist
USER app
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://localhost:3000/healthz || exit 1
CMD ["node", "dist/server.js"]
Docker Compose
services:
api:
build: { context: ., target: runtime }
depends_on:
db: { condition: service_healthy }
deploy:
resources: { limits: { memory: 512M } }
restart: unless-stopped
GitHub Actions
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
services:
postgres:
image: postgres:16
options: --health-cmd pg_isready --health-interval 10s
Kubernetes
spec:
containers:
- resources:
requests: { cpu: 100m, memory: 128Mi }
limits: { cpu: 500m, memory: 512Mi }
livenessProbe:
httpGet: { path: /healthz, port: 8080 }
readinessProbe:
httpGet: { path: /ready, port: 8080 }
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
Helm Chart
chart/
Chart.yaml # metadata + dependencies
values.yaml # default values
templates/
deployment.yaml
service.yaml
ingress.yaml
_helpers.tpl # template helpers
OpenTelemetry
const sdk = new NodeSDK({
serviceName: "order-service",
traceExporter: new OTLPTraceExporter({ url: "http://collector:4318/v1/traces" }),
metricReader: new PeriodicExportingMetricReader({
exporter: new OTLPMetricExporter(),
exportIntervalMillis: 15000,
}),
instrumentations: [new HttpInstrumentation(), new PgInstrumentation()],
});
Custom spans: tracer.startActiveSpan("name", async (span) => { ... span.end() })
Custom metrics: counter, histogram, gauge через meter.create*()
AWS Lambda + DynamoDB
// Init outside handler
const client = DynamoDBDocumentClient.from(new DynamoDBClient({}));
export const handler: APIGatewayProxyHandlerV2 = async (event) => {
const result = await client.send(
new GetCommand({ TableName: process.env.TABLE_NAME!, Key: { pk: id } })
);
return { statusCode: 200, body: JSON.stringify(result.Item) };
};
Structured Logging
logger.info("order_created", {
orderId, customerId, amount,
traceId: span.spanContext().traceId
});
Всегда JSON format, severity levels, correlation IDs
Никогда PII в логах без маскирования
ЧЕКЛИСТ
Docker: non-root user, multi-stage, .dockerignore, HEALTHCHECK
K8s: resource limits, probes, topology spread, secrets через SecretRef
CI/CD: concurrency cancellation, cache dependencies, matrix testing
Monitoring: traces + metrics + structured logs connected
Alerts: на SLO breach, не на каждую ошибку
IaC: remote state, план перед apply, модульная структура
ПРИМЕРЫ
Full CI/CD → Deploy pipeline
jobs:
lint: { runs-on: ubuntu-latest, steps: [checkout, setup-node, npm ci, npm run lint] }
test: { needs: lint, strategy: { matrix: { node: [20, 22] } } }
build: { needs: test, steps: [docker build, docker push] }
deploy: { needs: build, if: "github.ref == 'refs/heads/main'", environment: production }
1 --- 2 name: nebo-devops-cloud 3 description: DEVOPS-CLOUD SuperSkill 4 --- 5 6 # DEVOPS-CLOUD SuperSkill 7 > Заменяет: devops-automation, docker-best-practices, kubernetes-operations, ci-cd-pipelines, monitoring-observability, aws-cloud-patterns (6 скилов) 8 > Триггеры: "docker", "kubernetes", "CI/CD", "деплой", "AWS", "nginx", "systemd", "devops", "monitoring", "Helm" 9 > Атомов: 87 10 11 ## КОГДА ПРИМЕНЯТЬ 12 - Настройка CI/CD pipeline (GitHub Actions, GitLab CI) 13 - Docker: Dockerfile, compose, оптимизация образов 14 - Kubernetes: манифесты, Helm charts, troubleshooting 15 - Мониторинг: OpenTelemetry, Prometheus, Grafana 16 - AWS: Lambda, ECS, DynamoDB, CDK/Terraform 17 - Деплой: blue-green, canary, rolling updates 18 19 ## КЛЮЧЕВЫЕ ПРИНЦИПЫ 20 21 1. **Multi-stage Docker builds**: deps → build → runtime. Final stage только runtime artifacts + non-root user 22 2. **K8s: always set resources**: requests + limits на каждом контейнере, topologySpreadConstraints для HA 23 3. **CI/CD: concurrency + needs**: `cancel-in-progress: true` для stale runs, `needs` для зависимостей между jobs 24 4. **Observability = traces + metrics + logs**: OpenTelemetry SDK → OTLP collector → backends. Structured JSON logging 25 5. **AWS Lambda: init outside handler**: SDK clients вне handler для переиспользования между invocations 26 6. **DynamoDB: access patterns first**: Single-table design, composite keys (PK + SK), GSI для альтернативных запросов 27 7. **IaC: CDK/Terraform over console**: Всё в коде, state в remote backend, plan перед apply 28 29 ## ПАТТЕРНЫ И ТЕХНИКИ 30 31 ### Docker 32 ```dockerfile 33 FROM node:22-alpine AS deps 34 WORKDIR /app 35 COPY package.json package-lock.json ./ 36 RUN npm ci --only=production 37 38 FROM node:22-alpine AS build 39 WORKDIR /app 40 COPY package.json package-lock.json ./ 41 RUN npm ci 42 COPY . . 43 RUN npm run build 44 45 FROM node:22-alpine AS runtime 46 WORKDIR /app 47 RUN addgroup -g 1001 -S app && adduser -S app -u 1001 -G app 48 COPY --from=deps /app/node_modules ./node_modules 49 COPY --from=build /app/dist ./dist 50 USER app 51 EXPOSE 3000 52 HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://localhost:3000/healthz || exit 1 53 CMD ["node", "dist/server.js"] 54 ``` 55 56 ### Docker Compose 57 ```yaml 58 services: 59 api: 60 build: { context: ., target: runtime } 61 depends_on: 62 db: { condition: service_healthy } 63 deploy: 64 resources: { limits: { memory: 512M } } 65 restart: unless-stopped 66 ``` 67 68 ### GitHub Actions 69 ```yaml 70 concurrency: 71 group: ${{ github.workflow }}-${{ github.ref }} 72 cancel-in-progress: true 73 74 jobs: 75 test: 76 services: 77 postgres: 78 image: postgres:16 79 options: --health-cmd pg_isready --health-interval 10s 80 ``` 81 82 ### Kubernetes 83 ```yaml 84 spec: 85 containers: 86 - resources: 87 requests: { cpu: 100m, memory: 128Mi } 88 limits: { cpu: 500m, memory: 512Mi } 89 livenessProbe: 90 httpGet: { path: /healthz, port: 8080 } 91 readinessProbe: 92 httpGet: { path: /ready, port: 8080 } 93 topologySpreadConstraints: 94 - maxSkew: 1 95 topologyKey: kubernetes.io/hostname 96 whenUnsatisfiable: DoNotSchedule 97 ``` 98 99 ### Helm Chart 100 ``` 101 chart/ 102 Chart.yaml # metadata + dependencies 103 values.yaml # default values 104 templates/ 105 deployment.yaml 106 service.yaml 107 ingress.yaml 108 _helpers.tpl # template helpers 109 ``` 110 111 ### OpenTelemetry 112 ```typescript 113 const sdk = new NodeSDK({ 114 serviceName: "order-service", 115 traceExporter: new OTLPTraceExporter({ url: "http://collector:4318/v1/traces" }), 116 metricReader: new PeriodicExportingMetricReader({ 117 exporter: new OTLPMetricExporter(), 118 exportIntervalMillis: 15000, 119 }), 120 instrumentations: [new HttpInstrumentation(), new PgInstrumentation()], 121 }); 122 ``` 123 - Custom spans: `tracer.startActiveSpan("name", async (span) => { ... span.end() })` 124 - Custom metrics: counter, histogram, gauge через `meter.create*()` 125 126 ### AWS Lambda + DynamoDB 127 ```typescript 128 // Init outside handler 129 const client = DynamoDBDocumentClient.from(new DynamoDBClient({})); 130 131 export const handler: APIGatewayProxyHandlerV2 = async (event) => { 132 const result = await client.send( 133 new GetCommand({ TableName: process.env.TABLE_NAME!, Key: { pk: id } }) 134 ); 135 return { statusCode: 200, body: JSON.stringify(result.Item) }; 136 }; 137 ``` 138 139 ### Structured Logging 140 ```typescript 141 logger.info("order_created", { 142 orderId, customerId, amount, 143 traceId: span.spanContext().traceId 144 }); 145 ``` 146 - Всегда JSON format, severity levels, correlation IDs 147 - Никогда PII в логах без маскирования 148 149 ## ЧЕКЛИСТ 150 - [ ] Docker: non-root user, multi-stage, .dockerignore, HEALTHCHECK 151 - [ ] K8s: resource limits, probes, topology spread, secrets через SecretRef 152 - [ ] CI/CD: concurrency cancellation, cache dependencies, matrix testing 153 - [ ] Monitoring: traces + metrics + structured logs connected 154 - [ ] Alerts: на SLO breach, не на каждую ошибку 155 - [ ] IaC: remote state, план перед apply, модульная структура 156 157 ## ПРИМЕРЫ 158 159 ### Full CI/CD → Deploy pipeline 160 ```yaml 161 jobs: 162 lint: { runs-on: ubuntu-latest, steps: [checkout, setup-node, npm ci, npm run lint] } 163 test: { needs: lint, strategy: { matrix: { node: [20, 22] } } } 164 build: { needs: test, steps: [docker build, docker push] } 165 deploy: { needs: build, if: "github.ref == 'refs/heads/main'", environment: production } 166 ```