Index of every page on this site: llms.txt
All skills
jeremylongshore avatar

/creating-kubernetes-deployments

@0d57af8
Run it yourself

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. Use when working with creating kubernetes deployments. Trigger with 'creating', 'kubernetes', 'deployments'.

Use this Skill: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/creating-kubernetes-deployments

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesimplementation.md

≈1.3k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Kubernetes Deployments - Implementation Details

Configuration

Namespace Setup

Always deploy workloads into dedicated namespaces with resource quotas:

apiVersion: v1
kind: Namespace
metadata:
  name: production
  labels:
    env: production
    team: backend
---
apiVersion: v1
kind: ResourceQuota
metadata:
  name: production-quota
  namespace: production
spec:
  hard:
    requests.cpu: "20"
    requests.memory: 40Gi
    limits.cpu: "40"
    limits.memory: 80Gi
    pods: "50"
    services: "20"
---
apiVersion: v1
kind: LimitRange
metadata:
  name: default-limits
  namespace: production
spec:
  limits:
  - default:
      cpu: 500m
      memory: 512Mi
    defaultRequest:
      cpu: 100m
      memory: 256Mi
    type: Container

Kustomize Project Layout

k8s/
├── base/
│   ├── kustomization.yaml
│   ├── deployment.yaml
│   ├── service.yaml
│   ├── hpa.yaml
│   └── network-policy.yaml
├── overlays/
│   ├── dev/
│   │   ├── kustomization.yaml
│   │   └── patch-replicas.yaml
│   ├── staging/
│   │   ├── kustomization.yaml
│   │   └── patch-resources.yaml
│   └── prod/
│       ├── kustomization.yaml
│       ├── patch-replicas.yaml
│       └── patch-resources.yaml
└── components/
    ├── monitoring/
    │   └── kustomization.yaml
    └── istio/
        └── kustomization.yaml

Advanced Patterns

Pod Disruption Budget

Maintain availability during voluntary disruptions (node upgrades, scaling):

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: my-api-pdb
spec:
  minAvailable: 2
  selector:
    matchLabels:
      app: my-api

Topology Spread Constraints

Distribute pods across zones for high availability:

spec:
  template:
    spec:
      topologySpreadConstraints:
      - maxSkew: 1
        topologyKey: topology.kubernetes.io/zone
        whenUnsatisfiable: DoNotSchedule
        labelSelector:
          matchLabels:
            app: my-api
      - maxSkew: 1
        topologyKey: kubernetes.io/hostname
        whenUnsatisfiable: ScheduleAnyway
        labelSelector:
          matchLabels:
            app: my-api

Init Containers for Dependencies

Wait for database or external service before starting main container:

spec:
  template:
    spec:
      initContainers:
      - name: wait-for-db
        image: busybox:1.36
        command: ['sh', '-c',
          'until nc -z postgres-svc 5432; do echo "waiting for db"; sleep 2; done']
      - name: run-migrations
        image: my-registry/my-api:v1.0.0
        command: ['npm', 'run', 'migrate']
        envFrom:
        - secretRef:
            name: db-credentials

Graceful Shutdown

Configure preStop hooks and terminationGracePeriodSeconds:

spec:
  template:
    spec:
      terminationGracePeriodSeconds: 60
      containers:
      - name: my-api
        lifecycle:
          preStop:
            exec:
              command: ["/bin/sh", "-c", "sleep 10"]
        # Connections drain during the sleep period

Network Policy for Zero Trust

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: my-api-netpol
spec:
  podSelector:
    matchLabels:
      app: my-api
  policyTypes:
  - Ingress
  - Egress
  ingress:
  - from:
    - podSelector:
        matchLabels:
          app: api-gateway
    ports:
    - port: 8080
      protocol: TCP
  egress:
  - to:
    - podSelector:
        matchLabels:
          app: postgres
    ports:
    - port: 5432
      protocol: TCP
  - to:  # Allow DNS
    - namespaceSelector: {}
    ports:
    - port: 53
      protocol: UDP

Troubleshooting

Debugging Pod Scheduling

# Check why pod is pending
kubectl describe pod POD_NAME -n NAMESPACE | grep -A 10 Events

# Check node resources
kubectl top nodes
kubectl describe node NODE_NAME | grep -A 5 "Allocated resources"

# Check for taints preventing scheduling
kubectl get nodes -o json | jq '.items[] | {name: .metadata.name, taints: .spec.taints}'

Debugging CrashLoopBackOff

# Check current logs
kubectl logs POD_NAME -n NAMESPACE --tail=50

# Check previous container logs
kubectl logs POD_NAME -n NAMESPACE --previous

# Get container exit code
kubectl get pod POD_NAME -n NAMESPACE -o jsonpath='{.status.containerStatuses[0].lastState.terminated.exitCode}'

# Run shell in a debug container
kubectl debug POD_NAME -n NAMESPACE --image=busybox -it -- sh

Rollback a Failed Deployment

# Check rollout history
kubectl rollout history deployment/my-api -n NAMESPACE

# Rollback to previous revision
kubectl rollout undo deployment/my-api -n NAMESPACE

# Rollback to specific revision
kubectl rollout undo deployment/my-api -n NAMESPACE --to-revision=3

Tons of Skills by Intent Solutions | jeremylongshore.com

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill provides a comprehensive set of templates and scripts for creating and managing production-ready Kubernetes deployments. It includes extensive documentation on best practices for security, resource management, and troubleshooting. No security issues were detected.

  • Socket2mo

    1 alert: gptAnomaly

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 0d57af8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month
What it can do
Reads files Edits files Runs commands
version
1.29.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
[
  "devops",
  "deployment",
  "kubernetes",
  "scaling"
]
All 6 allowed tools
ReadWriteEditGrepGlobBash(kubectl:*)
Other metadata
compatibility
Designed for Claude Code

README badge

README badge for jeremylongshore/tons-of-skills-marketplace/creating-kubernetes-deployments