domain-cloud-native

domain-cloud-native

Beliebt

Use when building cloud-native apps. Keywords: kubernetes, k8s, docker, container, grpc, tonic, microservice, service mesh, observability, tracing, metrics, health check, cloud, deployment, 云原生, 微服务, 容器

534Sterne
53Forks
Aktualisiert 1/24/2026
SKILL.md
readonlyread-only
name
domain-cloud-native
description

"Use when building cloud-native apps. Keywords: kubernetes, k8s, docker, container, grpc, tonic, microservice, service mesh, observability, tracing, metrics, health check, cloud, deployment, 云原生, 微服务, 容器"

Cloud-Native Domain

Layer 3: Domain Constraints

Domain Constraints → Design Implications

Domain Rule Design Constraint Rust Implication
12-Factor Config from env Environment-based config
Observability Metrics + traces tracing + opentelemetry
Health checks Liveness/readiness Dedicated endpoints
Graceful shutdown Clean termination Signal handling
Horizontal scale Stateless design No local state
Container-friendly Small binaries Release optimization

Critical Constraints

Stateless Design

RULE: No local persistent state
WHY: Pods can be killed/rescheduled anytime
RUST: External state (Redis, DB), no static mut

Graceful Shutdown

RULE: Handle SIGTERM, drain connections
WHY: Zero-downtime deployments
RUST: tokio::signal + graceful shutdown

Observability

RULE: Every request must be traceable
WHY: Debugging distributed systems
RUST: tracing spans, opentelemetry export

Trace Down ↓

From constraints to design (Layer 2):

"Need distributed tracing"
    ↓ m12-lifecycle: Span lifecycle
    ↓ tracing + opentelemetry

"Need graceful shutdown"
    ↓ m07-concurrency: Signal handling
    ↓ m12-lifecycle: Connection draining

"Need health checks"
    ↓ domain-web: HTTP endpoints
    ↓ m06-error-handling: Health status

Key Crates

Purpose Crate
gRPC tonic
Kubernetes kube, kube-runtime
Docker bollard
Tracing tracing, opentelemetry
Metrics prometheus, metrics
Config config, figment
Health HTTP endpoints

Design Patterns

Pattern Purpose Implementation
gRPC services Service mesh tonic + tower
K8s operators Custom resources kube-runtime Controller
Observability Debugging tracing + OTEL
Health checks Orchestration /health, /ready
Config 12-factor Env vars + secrets

Code Pattern: Graceful Shutdown

use tokio::signal;

async fn run_server() -> anyhow::Result<()> {
    let app = Router::new()
        .route("/health", get(health))
        .route("/ready", get(ready));

    let addr = SocketAddr::from(([0, 0, 0, 0], 8080));

    axum::Server::bind(&addr)
        .serve(app.into_make_service())
        .with_graceful_shutdown(shutdown_signal())
        .await?;

    Ok(())
}

async fn shutdown_signal() {
    signal::ctrl_c().await.expect("failed to listen for ctrl+c");
    tracing::info!("shutdown signal received");
}

Health Check Pattern

async fn health() -> StatusCode {
    StatusCode::OK
}

async fn ready(State(db): State<Arc<DbPool>>) -> StatusCode {
    match db.ping().await {
        Ok(_) => StatusCode::OK,
        Err(_) => StatusCode::SERVICE_UNAVAILABLE,
    }
}

Common Mistakes

Mistake Domain Violation Fix
Local file state Not stateless External storage
No SIGTERM handling Hard kills Graceful shutdown
No tracing Can't debug tracing spans
Static config Not 12-factor Env vars

Trace to Layer 1

Constraint Layer 2 Pattern Layer 1 Implementation
Stateless External state Arc for external
Graceful shutdown Signal handling tokio::signal
Tracing Span lifecycle tracing + OTEL
Health checks HTTP endpoints Dedicated routes

Related Skills

When See
Async patterns m07-concurrency
HTTP endpoints domain-web
Error handling m13-domain-error
Resource lifecycle m12-lifecycle

You Might Also Like

Related Skills

create-pr

create-pr

170Kdev-devops

Creates GitHub pull requests with properly formatted titles that pass the check-pr-title CI validation. Use when creating PRs, submitting changes for review, or when the user says /pr or asks to create a pull request.

n8n-io avatarn8n-io
Holen

Guide for performing Chromium version upgrades in the Electron project. Use when working on the roller/chromium/main branch to fix patch conflicts during `e sync --3`. Covers the patch application workflow, conflict resolution, analyzing upstream Chromium changes, and proper commit formatting for patch fixes.

electron avatarelectron
Holen
pr-creator

pr-creator

92Kdev-devops

Use this skill when asked to create a pull request (PR). It ensures all PRs follow the repository's established templates and standards.

google-gemini avatargoogle-gemini
Holen
clawdhub

clawdhub

87Kdev-devops

Use the ClawdHub CLI to search, install, update, and publish agent skills from clawdhub.com. Use when you need to fetch new skills on the fly, sync installed skills to latest or a specific version, or publish new/updated skill folders with the npm-installed clawdhub CLI.

moltbot avatarmoltbot
Holen
tmux

tmux

87Kdev-devops

Remote-control tmux sessions for interactive CLIs by sending keystrokes and scraping pane output.

moltbot avatarmoltbot
Holen
create-pull-request

create-pull-request

57Kdev-devops

Create a GitHub pull request following project conventions. Use when the user asks to create a PR, submit changes for review, or open a pull request. Handles commit analysis, branch management, and PR creation using the gh CLI tool.

cline avatarcline
Holen