K

Kubernetes Deployment Sync

Generates and synchronizes Kubernetes deployment manifests, services, and ingress configs from your application code. Detects ports, environment variables, and health checks automatically.

CommandCommunitydevopsv1.0.0MIT
0 views0 copies

Command

/k8s-sync

Description

Analyzes your application to generate production-ready Kubernetes manifests. Detects the application type (Node.js, Python, Go, etc.), identifies exposed ports, environment variables, and health endpoints, then generates Deployment, Service, Ingress, ConfigMap, and HPA manifests.

Behavior

  1. Detect Application Type -- Scan package.json, requirements.txt, go.mod, Dockerfile to determine the runtime
  2. Extract Configuration -- Find exposed ports, environment variables, health check endpoints
  3. Generate Manifests -- Create Kubernetes YAML files in k8s/ directory:
    • deployment.yaml -- Pod spec with resource limits, probes, and security context
    • service.yaml -- ClusterIP service exposing detected ports
    • ingress.yaml -- Ingress with TLS configuration (if hostname provided)
    • configmap.yaml -- Non-secret environment variables
    • hpa.yaml -- HorizontalPodAutoscaler with sensible defaults
  4. Diff Existing -- If manifests already exist, show diff and confirm before overwriting

Output Format

Generated files are placed in the k8s/ directory at the project root:

k8s/
ā”œā”€ā”€ deployment.yaml
ā”œā”€ā”€ service.yaml
ā”œā”€ā”€ ingress.yaml
ā”œā”€ā”€ configmap.yaml
└── hpa.yaml

Each file includes comments explaining the configuration choices.

Examples

Usage

/k8s-sync
/k8s-sync --namespace production --replicas 3
/k8s-sync --hostname api.example.com --tls

Generated Deployment (excerpt)

apiVersion: apps/v1 kind: Deployment metadata: name: my-app namespace: default labels: app.kubernetes.io/name: my-app app.kubernetes.io/managed-by: claude-k8s-sync spec: replicas: 2 selector: matchLabels: app.kubernetes.io/name: my-app template: spec: containers: - name: my-app image: my-app:latest # TODO: Pin to specific tag ports: - containerPort: 3000 # Detected from package.json start script resources: requests: cpu: 100m memory: 128Mi limits: cpu: 500m memory: 256Mi readinessProbe: httpGet: path: /health # Detected from route definitions port: 3000 envFrom: - configMapRef: name: my-app-config

Parameters

ParameterDefaultDescription
--namespacedefaultTarget Kubernetes namespace
--replicas2Initial replica count
--hostnamenoneIngress hostname (skips ingress if not set)
--tlsfalseEnable TLS on ingress
--registrynoneContainer registry prefix
Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates