Expert guidance for managing, deploying, and troubleshooting Kubernetes Pods with best practices and advanced configurations
This skill provides comprehensive guidance for managing Kubernetes Pods, including creation, configuration, troubleshooting, and best practices based on official Kubernetes documentation.
This skill helps you work with Kubernetes Pods effectively by:
When a user asks for help with Kubernetes Pods, follow these steps:
First, determine what the user needs:
When creating or modifying pods:
**Basic Pod Structure:**
```yaml
apiVersion: v1
kind: Pod
metadata:
name: pod-name
namespace: default
labels:
app: app-name
annotations:
description: "Pod description"
spec:
containers:
- name: container-name
image: image:tag
ports:
- containerPort: 8080
```
**Apply these best practices:**
Configure appropriate resource constraints:
```yaml
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
```
**Guidelines:**
Implement probes for reliability:
```yaml
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
startupProbe:
httpGet:
path: /startup
port: 8080
failureThreshold: 30
periodSeconds: 10
```
**Probe types:**
When pods need persistent or shared storage:
```yaml
volumes:
persistentVolumeClaim:
claimName: data-pvc
configMap:
name: app-config
secret:
secretName: app-secrets
volumeMounts:
mountPath: /data
mountPath: /config
readOnly: true
mountPath: /secrets
readOnly: true
```
Apply security best practices:
```yaml
securityContext:
runAsNonRoot: true
runAsUser: 1000
fsGroup: 2000
seccompProfile:
type: RuntimeDefault
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
```
**Security checklist:**
For multi-container patterns:
```yaml
initContainers:
image: busybox:1.28
command: ['sh', '-c', 'setup-script.sh']
containers:
image: app:latest
image: logger:latest
```
**Use cases:**
When debugging pod issues:
**Check pod status:**
```bash
kubectl get pods
kubectl describe pod <pod-name>
kubectl logs <pod-name>
kubectl logs <pod-name> -c <container-name>
kubectl logs <pod-name> --previous
```
**Common issues and solutions:**
**Interactive debugging:**
```bash
kubectl exec -it <pod-name> -- /bin/sh
kubectl port-forward <pod-name> 8080:80
kubectl cp <pod-name>:/path/to/file ./local-file
```
**Pod Disruption Budgets:**
```yaml
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: app-pdb
spec:
minAvailable: 2
selector:
matchLabels:
app: myapp
```
**Pod Topology Spread Constraints:**
```yaml
topologySpreadConstraints:
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: myapp
```
**Node Affinity:**
```yaml
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: disktype
operator: In
values:
- ssd
```
Before applying configurations:
1. **Always specify resource requests and limits**
2. **Implement health checks (liveness, readiness, startup probes)**
3. **Use meaningful labels and annotations**
4. **Configure security contexts (non-root, capabilities, seccomp)**
5. **Use ConfigMaps and Secrets for configuration**
6. **Implement proper logging and monitoring**
7. **Test configurations before production deployment**
8. **Document pod specifications with annotations**
9. **Use namespaces for logical separation**
10. **Monitor resource usage and adjust limits accordingly**
**Stateless Application Pod:**
**Stateful Application Pod:**
**Batch Job Pod:**
**DaemonSet Pod:**
When generating pod configurations:
1. Provide complete, valid YAML manifests
2. Include inline comments explaining key configurations
3. Add validation commands to verify the configuration
4. Include relevant kubectl commands for deployment and monitoring
5. Suggest appropriate testing and rollout strategies
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/kubernetes-pod-management-expert/raw