Skill v1.0.1
currentAutomated scan100/1001 files
version: "1.0.1" name: kubernetes-deployment description: Deploy, manage, and scale applications on Kubernetes clusters using manifests, Helm charts, and autoscaling configurations. license: MIT metadata: author: awesome-ai-agent-skills version: 1.0.0
Kubernetes Deployment
This skill enables the agent to deploy and manage applications on Kubernetes clusters. The agent can generate deployment manifests, services, ingress rules, Helm charts, and autoscaling configurations. It handles the full lifecycle from initial deployment through scaling, rolling updates, and troubleshooting, following production best practices for resource management, security, and reliability.
Workflow
- Configure Cluster Access: The agent verifies that
kubectlis configured with the correct cluster context and namespace. It checks connectivity withkubectl cluster-infoand confirms that the user has sufficient RBAC permissions to create and manage resources in the target namespace. If a kubeconfig is not present, the agent guides the user through authentication (e.g.,aws eks update-kubeconfig,gcloud container clusters get-credentials).
- Define Deployment Manifests: The agent creates Kubernetes deployment manifests specifying the container image, replica count, resource requests and limits, environment variables, liveness and readiness probes, and pod anti-affinity rules. Labels and annotations are applied consistently for service discovery, monitoring, and operations. The agent uses specific image tags (never
latest) and setsimagePullPolicyappropriately.
- Configure Services and Ingress: The agent creates Service resources to expose deployments within the cluster (ClusterIP) or externally (LoadBalancer, NodePort). For HTTP workloads, the agent configures Ingress resources with TLS termination using cert-manager, path-based routing, and rate limiting annotations. The agent selects the appropriate service type based on the deployment environment and traffic requirements.
- Apply Manifests and Verify Rollout: The agent applies manifests using
kubectl apply -fand monitors the rollout withkubectl rollout status. It verifies that all pods reach the Running state, health checks pass, and the service endpoints are registered. If a rollout stalls, the agent checks pod events withkubectl describe podand logs withkubectl logsto diagnose the issue, and can executekubectl rollout undoto revert to the previous version.
- Configure Autoscaling: The agent sets up Horizontal Pod Autoscalers (HPA) to scale the replica count based on CPU utilization, memory usage, or custom metrics. It defines minimum and maximum replica counts, scale-up and scale-down behavior, and stabilization windows to prevent thrashing. For workloads with variable resource needs, the agent can also configure Vertical Pod Autoscalers (VPA).
- Manage with Helm Charts: For complex applications with multiple environments, the agent packages Kubernetes manifests into Helm charts with templated values. Helm enables versioned releases, atomic upgrades with automatic rollback on failure, and environment-specific value overrides. The agent uses
helm upgrade --installfor idempotent deployments andhelm diffto preview changes before applying.
Supported Technologies
- Orchestration: Kubernetes (EKS, GKE, AKS, self-managed), k3s, kind, minikube
- Package Management: Helm 3, Kustomize
- Autoscaling: HPA, VPA, KEDA, Cluster Autoscaler
- Networking: Nginx Ingress Controller, Traefik, Istio, Cilium
- Certificate Management: cert-manager, Let's Encrypt
- CI/CD Integration: ArgoCD, Flux, GitHub Actions, GitLab CI
Usage
Provide the agent with your application's container image, resource requirements, desired replica count, and target Kubernetes cluster details.
Example prompt:
Deploy my app to the production EKS cluster:- Image: myregistry.io/myapp:v2.1.0- 3 replicas with CPU/memory limits- Liveness and readiness probes on /health- Expose via Ingress at api.example.com with TLS- HPA scaling between 3-10 replicas based on CPU
Examples
Example 1: Production Deployment with Service and Ingress
deployment.yaml:
apiVersion: apps/v1kind: Deploymentmetadata:name: myappnamespace: productionlabels:app: myappversion: v2.1.0spec:replicas: 3revisionHistoryLimit: 5strategy:type: RollingUpdaterollingUpdate:maxSurge: 1maxUnavailable: 0selector:matchLabels:app: myapptemplate:metadata:labels:app: myappversion: v2.1.0spec:serviceAccountName: myappterminationGracePeriodSeconds: 60affinity:podAntiAffinity:preferredDuringSchedulingIgnoredDuringExecution:- weight: 100podAffinityTerm:labelSelector:matchExpressions:- key: appoperator: Invalues: [myapp]topologyKey: kubernetes.io/hostnamecontainers:- name: myappimage: myregistry.io/myapp:v2.1.0ports:- containerPort: 3000name: httpenv:- name: NODE_ENVvalue: "production"- name: DATABASE_URLvalueFrom:secretKeyRef:name: myapp-secretskey: database-urlresources:requests:cpu: 250mmemory: 256Milimits:cpu: "1"memory: 512MilivenessProbe:httpGet:path: /healthport: httpinitialDelaySeconds: 30periodSeconds: 10timeoutSeconds: 5failureThreshold: 3readinessProbe:httpGet:path: /healthport: httpinitialDelaySeconds: 5periodSeconds: 5timeoutSeconds: 3failureThreshold: 3lifecycle:preStop:exec:command: ["/bin/sh", "-c", "sleep 15"]
service.yaml:
apiVersion: v1kind: Servicemetadata:name: myappnamespace: productionspec:selector:app: myappports:- protocol: TCPport: 80targetPort: httptype: ClusterIP
ingress.yaml:
apiVersion: networking.k8s.io/v1kind: Ingressmetadata:name: myappnamespace: productionannotations:cert-manager.io/cluster-issuer: letsencrypt-prodnginx.ingress.kubernetes.io/rate-limit: "100"spec:ingressClassName: nginxtls:- hosts:- api.example.comsecretName: myapp-tlsrules:- host: api.example.comhttp:paths:- path: /pathType: Prefixbackend:service:name: myappport:number: 80
Example 2: Horizontal Pod Autoscaler with Helm Deployment
Install or upgrade using Helm with custom values:
helm upgrade --install myapp ./charts/myapp \--namespace production \--set image.tag=v2.1.0 \--set replicaCount=3 \--set autoscaling.enabled=true \--values values-production.yaml \--wait --timeout 5m \--atomic
hpa.yaml — Horizontal Pod Autoscaler:
apiVersion: autoscaling/v2kind: HorizontalPodAutoscalermetadata:name: myappnamespace: productionspec:scaleTargetRef:apiVersion: apps/v1kind: Deploymentname: myappminReplicas: 3maxReplicas: 10metrics:- type: Resourceresource:name: cputarget:type: UtilizationaverageUtilization: 70- type: Resourceresource:name: memorytarget:type: UtilizationaverageUtilization: 80behavior:scaleUp:stabilizationWindowSeconds: 60policies:- type: Percentvalue: 50periodSeconds: 60scaleDown:stabilizationWindowSeconds: 300policies:- type: Percentvalue: 25periodSeconds: 120
Deployment steps:
kubectl create namespace production(if it does not exist)kubectl apply -f deployment.yaml -f service.yaml -f ingress.yamlkubectl apply -f hpa.yamlkubectl rollout status deployment/myapp -n productionkubectl get hpa myapp -n productionto verify autoscaler targets
Best Practices
- Always set resource requests and limits: Every container should define CPU and memory requests (for scheduling) and limits (to prevent noisy-neighbor issues). Without requests, the scheduler cannot make informed placement decisions, and without limits, a single pod can consume all node resources.
- Configure liveness and readiness probes: Liveness probes allow Kubernetes to restart containers that are stuck or deadlocked. Readiness probes prevent traffic from being routed to pods that are not yet ready to serve requests. Set appropriate
initialDelaySecondsto avoid killing pods during startup. - Use namespaces for isolation: Separate environments (dev, staging, production) and teams into distinct namespaces. Apply ResourceQuotas and LimitRanges per namespace to prevent any single team or environment from consuming excessive cluster resources.
- Implement RBAC with least privilege: Create service accounts with minimal permissions for each application. Avoid using the
defaultservice account or grantingcluster-adminto workloads. Use Roles and RoleBindings scoped to the namespace rather than ClusterRoles when possible. - Use Helm for repeatable deployments: Helm charts package manifests with templated values, enabling consistent deployments across environments. Use
--atomicfor automatic rollback on failure and--waitto block until resources are healthy. - Set pod disruption budgets: Define PodDisruptionBudgets (PDBs) to ensure a minimum number of replicas remain available during voluntary disruptions like node drains and cluster upgrades. For example,
minAvailable: 2ensures at least 2 pods are running at all times.
Edge Cases
- CrashLoopBackOff: A pod repeatedly crashes and Kubernetes applies exponential backoff delays between restart attempts. Diagnose with
kubectl logs <pod> --previousto see the crash output andkubectl describe pod <pod>for events. Common causes include misconfigured environment variables, missing secrets, or failed database connections. - ImagePullBackOff: The container runtime cannot pull the specified image. This occurs when the image tag does not exist, the registry requires authentication, or there is a network issue. Verify the image exists with
docker pull, checkimagePullSecretson the pod spec, and ensure the node has network access to the registry. - Pod eviction under node pressure: When a node runs low on memory or disk, the kubelet evicts pods starting with those exceeding their resource requests (BestEffort pods first, then Burstable). Set appropriate resource requests to ensure critical pods are categorized as Guaranteed QoS class and are evicted last.
- Stuck rollouts and deadlines: A deployment rollout can stall if new pods fail readiness checks. The default
progressDeadlineSecondsis 600 seconds, after which Kubernetes marks the rollout as failed. Usekubectl rollout undo deployment/myappto revert immediately rather than waiting for the deadline. - DNS resolution failures in new namespaces: Pods in newly created namespaces may experience temporary DNS resolution failures if CoreDNS has not yet updated its internal records. Application containers should implement retry logic with backoff for initial service discovery calls.
- Helm release conflicts: If a previous
helm upgradewas interrupted (e.g., by a timeout), the release may be in apending-upgradeorfailedstate. Usehelm history myappto inspect the state andhelm rollback myapp <revision>to recover before attempting another upgrade.