Skip to content
creating-kubernetes-deployments logo

Creating Kubernetes Deployments

creating-kubernetes-deployments

Deploy applications to Kubernetes with production-ready manifests. Supports Deployments, Services, Ingress, HPA, ConfigMaps, Secrets, StatefulSets, and NetworkPolicies. Includes health checks, resource limits, auto-scaling, and TLS termination.

SKILL.md

Full skill instructions

Creating Kubernetes Deployments

Generate production-ready Kubernetes manifests with health checks, resource limits, and security best practices.

Quick Start

Basic Deployment + Service

# deployment.yaml
apiVersion: apps/​v1
kind: Deployment
metadata:
  name: my-api
  labels:
    app: my-api
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-api
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
  template:
    metadata:
      labels:
        app: my-api
    spec:
      containers:
      - name: my-api
        image: my-registry/​my-api:v1.0.0
        ports:
        - containerPort: 8080
        resources:
          requests:
            cpu: 100m
            memory: 256Mi
          limits:
            cpu: 500m
            memory: 512Mi
        livenessProbe:
          httpGet:
            path: /​healthz
            port: 8080
          initialDelaySeconds: 30
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: /​readyz
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
  name: my-api
spec:
  type: ClusterIP
  selector:
    app: my-api
  ports:
  - port: 80
    targetPort: 8080

Deployment Strategies

StrategyUse CaseConfiguration
RollingUpdateZero-downtime updatesmaxSurge: 25%, maxUnavailable: 25%
RecreateStateful apps, incompatible versionstype: Recreate
Blue-GreenInstant rollbackTwo deployments, switch Service selector
CanaryGradual rolloutMultiple deployments with weighted traffic

Blue-Green Deployment

# Blue deployment (current production)
apiVersion: apps/​v1
kind: Deployment
metadata:
  name: my-api-blue
  labels:
    app: my-api
    version: blue
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-api
      version: blue
  template:
    metadata:
      labels:
        app: my-api
        version: blue
    spec:
      containers:
      - name: my-api
        image: my-registry/​my-api:v1.0.0
---
# Service points to blue
apiVersion: v1
kind: Service
metadata:
  name: my-api
spec:
  selector:
    app: my-api
    version: blue  # Switch to 'green' for deployment
  ports:
  - port: 80
    targetPort: 8080

Service Types

TypeUse CaseAccess
ClusterIPInternal servicesmy-api.namespace.svc.cluster.local
NodePortDevelopment, debugging<NodeIP>:<NodePort>
LoadBalancerExternal traffic (cloud)Cloud provider LB IP
ExternalNameExternal service proxyDNS CNAME

Ingress with TLS

apiVersion: networking.k8s.io/​v1
kind: Ingress
metadata:
  name: my-api-ingress
  annotations:
    cert-manager.io/​cluster-issuer: letsencrypt-prod
    nginx.ingress.kubernetes.io/​ssl-redirect: "true"
spec:
  ingressClassName: nginx
  tls:
  - hosts:
    - api.example.com
    secretName: api-tls-secret
  rules:
  - host: api.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: my-api
            port:
              number: 80

Resource Limits

Always set resource requests and limits:

resources:
  requests:    # Guaranteed resources
    cpu: 100m  # 0.1 CPU core
    memory: 256Mi
  limits:      # Maximum allowed
    cpu: 500m  # 0.5 CPU core
    memory: 512Mi
Workload TypeCPU RequestMemory RequestCPU LimitMemory Limit
Web API100m-500m256Mi-512Mi500m-1000m512Mi-1Gi
Worker250m-1000m512Mi-1Gi1000m-2000m1Gi-2Gi
Database500m-2000m1Gi-4Gi2000m-4000m4Gi-8Gi

Health Checks

Liveness Probe (Is container running?)

livenessProbe:
  httpGet:
    path: /​healthz
    port: 8080
  initialDelaySeconds: 30  # Wait for app startup
  periodSeconds: 10         # Check every 10s
  timeoutSeconds: 5         # Timeout per check
  failureThreshold: 3       # Restart after 3 failures

Readiness Probe (Ready for traffic?)

readinessProbe:
  httpGet:
    path: /​readyz
    port: 8080
  initialDelaySeconds: 5    # Quick check after start
  periodSeconds: 5          # Check every 5s
  successThreshold: 1       # 1 success = ready
  failureThreshold: 3       # Remove from LB after 3 failures

Startup Probe (Slow-starting apps)

startupProbe:
  httpGet:
    path: /​healthz
    port: 8080
  initialDelaySeconds: 0
  periodSeconds: 10
  failureThreshold: 30      # Allow 5 minutes to start (30 * 10s)

Horizontal Pod Autoscaler

apiVersion: autoscaling/​v2
kind: HorizontalPodAutoscaler
metadata:
  name: my-api-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/​v1
    kind: Deployment
    name: my-api
  minReplicas: 2
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 70
  - type: Resource
    resource:
      name: memory
      target:
        type: Utilization
        averageUtilization: 80
  behavior:
    scaleDown:
      stabilizationWindowSeconds: 300  # Wait 5min before scale down

ConfigMaps and Secrets

ConfigMap (Non-sensitive config)

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-api-config
data:
  LOG_LEVEL: "info"
  API_ENDPOINT: "https://api.example.com"
  config.yaml: |
    server:
      port: 8080
    features:
      enabled: true

Secret (Sensitive data - base64 encoded)

apiVersion: v1
kind: Secret
metadata:
  name: my-api-secrets
type: Opaque
data:
  API_KEY: YXBpLWtleS1oZXJl          # echo -n "api-key-here" | base64
  DATABASE_URL: cG9zdGdyZXM6Ly8uLi4=  # echo -n "postgres://..." | base64

Using in Deployment

spec:
  containers:
  - name: my-api
    envFrom:
    - configMapRef:
        name: my-api-config
    - secretRef:
        name: my-api-secrets
    volumeMounts:
    - name: config-volume
      mountPath: /​app/​config
  volumes:
  - name: config-volume
    configMap:
      name: my-api-config

Instructions

  1. Gather Requirements

    • Application name, container image, port
    • Replica count and resource requirements
    • Health check endpoints
    • External access requirements (Ingress/​LoadBalancer)
  2. Generate Base Manifests

    • Create Deployment with resource limits and probes
    • Create Service (ClusterIP for internal, LoadBalancer for external)
    • Add ConfigMap for configuration
    • Add Secret for sensitive data
  3. Add Production Features

    • Configure Ingress with TLS if external access needed
    • Add HPA for auto-scaling
    • Add NetworkPolicy for security
    • Add PodDisruptionBudget for availability
  4. Validate and Apply

    # Validate manifests
    kubectl apply -f manifests/ --dry-run=server
    
    # Apply to cluster
    kubectl apply -f manifests/
    
    # Watch rollout
    kubectl rollout status deployment/​my-api
    

Error Handling

See {baseDir}/​references/​errors.md for comprehensive troubleshooting.

ErrorQuick Fix
ImagePullBackOffCheck image name, tag, registry credentials
CrashLoopBackOffCheck logs: kubectl logs <pod>
OOMKilledIncrease memory limits
PendingCheck resources: kubectl describe pod <pod>

Examples

See {baseDir}/​references/​examples.md for detailed walkthroughs.

Resources

More DevOps & CI/CD skills

Project scaffolding, deployment configuration, and CI/CD setup for Google ADK agents.

6K 472.6K
View

Set up tracing, logging, and monitoring for deployed ADK agents across Cloud Trace, BigQuery, and third-party platforms.

6K 472.6K
View

Enterprise Azure infrastructure architect generating Bicep or Terraform from workload descriptions.

1.5K 454.3K
View
azure-kubernetes logo
DevOps & CI/CD

azure-kubernetes

Plan and configure production-ready Azure Kubernetes Service clusters with Day-0 and Day-1 best practices.

1.5K 447.1K
View

Raw mechanical interfaces fusing Swiss typographic print with military terminal aesthetics. Rigid grids, extreme type scale contrast, utilitarian color, analog degradation effects. For data-heavy dashboards, portfolios, or editorial sites that need to feel like declassified blueprints.

92.7K 354.9K
View
just-scrape logo
DevOps & CI/CD

just-scrape

Web search, scraping, extraction, crawling, and monitoring via ScrapeGraph AI CLI.

69 245K
View

Skill for working with Firebase Hosting (Classic). Use this when you want to deploy static web apps, Single Page Apps (SPAs), or simple microservices. Do NOT use for Firebase App Hosting.

462 159.7K
View

Deploy and manage web apps with Firebase App Hosting. Use this skill when deploying Next.js/Angular apps with backends.

462 159.1K
View
deploy-to-vercel logo
DevOps & CI/CD

deploy-to-vercel

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

31.9K 146.6K
View
programmatic-seo logo
DevOps & CI/CD

programmatic-seo

Build SEO-optimized pages at scale using templates, data, and proven playbook patterns.

53.3K 140.1K
View

Design and build isolated, reusable Convex backend components with clear boundaries and app-facing wrappers.

63 123.5K
View

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".

31.9K 116.1K
View

Coding & apps AI tools

Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View
I
Coding & apps

Imagica

Build a no-code AI app in minutes.

Freemium
View
E
Coding & apps

Emergent.sh

An IDE for code migration from legacy to modern frameworks through coding agents.

Freemium
View
Wonder Dynamics logo
Coding & apps

Wonder Dynamics

Automate CGI animation in live-action scenes

Paid
View
M
Coding & apps

Mixo

Launch a website in seconds with AI.

Paid
View
AI Code Convert logo
Coding & apps

AI Code Convert

Streamline Your Coding Experience with AI Code Helper

Free
View