k3s-kubernetes
Skill1 starsChanged 5 months agoMITView on GitHub
Use this skill for K3s Kubernetes — Deployments, Services, Traefik IngressRoute, ConfigMaps and Secrets, PersistentVolumeClaims, private registry, rolling updates, debugging pods, and namespace management. Activate for kubectl commands, K3s cluster operations, or any Kubernetes manifest work.
In this repository20 other files it gives its agents.
- cad-designSkill
- cloudflare-tunnelSkill
- context-engineeringSkill
- create-branchSkill
- create-releaseSkill
- digital-fabricationSkill
- docker-swarmSkill
- grafana-prometheusSkill
- linux-server-adminSkill
- merge-prSkill
- mikrotik-routerosSkill
- network-engineerSkill
- nextjs-deploymentSkill
- open-projectSkill
- open-prSkill
- proxmox-homelabSkill
- pr-reviewSkill
- python-fastapiSkill
- thai-dev-workflowSkill
- wireguard-vpnSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 160
imagePullPolicy: use Always for latest tag.
- Distinctive: line 313
No resource requests/limits — pods compete unbounded.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
K3s Kubernetes
Core Resources
Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
namespace: apps
spec:
replicas: 2
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: registry.local:5000/myapp:1.0.0
ports:
- containerPort: 3000
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: myapp-secret
key: DATABASE_URL
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 512Mi
readinessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 5
periodSeconds: 10Service
apiVersion: v1
kind: Service
metadata:
name: myapp-svc
namespace: apps
spec:
selector:
app: myapp
ports:
- port: 3000
targetPort: 3000Traefik IngressRoute (K3s default ingress)
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: myapp
namespace: apps
spec:
entryPoints:
- web
routes:
- match: Host(`myapp.example.com`)
kind: Rule
services:
- name: myapp-svc
port: 3000ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: myapp-config
namespace: apps
data:
APP_ENV: production
LOG_LEVEL: info
config.json: |
{
"feature_flags": { "new_ui": true }
}Secret
apiVersion: v1
kind: Secret
metadata:
name: myapp-secret
namespace: apps
type: Opaque
stringData:
DATABASE_URL: postgres://user:password@postgres:5432/mydb
JWT_SECRET: your-secret-keyPersistentVolumeClaim (local-path — K3s default)
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: myapp-data
namespace: apps
spec:
accessModes: [ReadWriteOnce]
storageClassName: local-path
resources:
requests:
storage: 5GiMount in Deployment:
volumeMounts:
- name: data
mountPath: /app/data
volumes:
- name: data
persistentVolumeClaim:
claimName: myapp-dataPrivate Registry
K3s registries.yaml:
# /etc/rancher/k3s/registries.yaml
mirrors:
"registry.local:5000":
endpoint:
- "http://registry.local:5000"Restart K3s after editing: systemctl restart k3s
Build, tag, push:
docker build -t myapp:1.0.0 .
docker tag myapp:1.0.0 registry.local:5000/myapp:1.0.0
docker push registry.local:5000/myapp:1.0.0imagePullPolicy: use Always for latest tag; IfNotPresent for versioned tags.
Rolling Updates
# Update image (triggers rolling update)
kubectl set image deployment/myapp myapp=registry.local:5000/myapp:1.1.0 -n apps
# Watch rollout
kubectl rollout status deployment/myapp -n apps
# Rollback
kubectl rollout undo deployment/myapp -n apps
# Rollout history
kubectl rollout history deployment/myapp -n appsZero-downtime strategy:
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0 # never take a pod down before replacement is ready
maxSurge: 1 # one extra pod during updateRestart Deployments After Config Changes
kubectl rollout restart deployment/myapp -n apps
# After: ConfigMap or Secret changes don't auto-restart pods — must restart manuallyDebugging
# Pod status
kubectl get pods -n apps
kubectl describe pod POD_NAME -n apps # events, image pull errors, OOMKill
# Logs
kubectl logs -n apps deploy/myapp --tail=100
kubectl logs -n apps deploy/myapp -f # follow
kubectl logs -n apps POD_NAME -c container-name # specific container
# Shell into running pod
kubectl exec -it POD_NAME -n apps -- /bin/sh
# Shell into debug container (if no shell in image)
kubectl debug -it POD_NAME -n apps --image=busybox --target=myapp
# Check resource usage
kubectl top pods -n apps
kubectl top nodes
# Events across namespace
kubectl get events -n apps --sort-by='.lastTimestamp'Common failure modes:
| Status | Cause | Fix |
ImagePullBackOff | Registry unreachable or wrong tag | Check registries.yaml, image name, push status |
CrashLoopBackOff | App crashes on start | kubectl logs for last exit, check env/secrets |
Pending | No schedulable node | kubectl describe pod → events: resource limits, taints |
OOMKilled | Memory limit exceeded | Increase limits.memory or fix memory leak |
Error: secret not found | Secret missing | kubectl get secret -n apps |
Useful Operations
# Apply all manifests in directory
kubectl apply -f ~/k3s-manifests/apps/
# Dry run (validate without applying)
kubectl apply -f manifest.yaml --dry-run=server
# Get resource YAML
kubectl get deployment myapp -n apps -o yaml
# Port-forward for local testing
kubectl port-forward svc/myapp-svc 3000:3000 -n apps
# Copy files to/from pod
kubectl cp local-file.txt apps/POD_NAME:/app/data/
# Scale deployment
kubectl scale deployment myapp --replicas=3 -n apps
# Delete and recreate (force redeploy)
kubectl delete pod -l app=myapp -n apps # pods restart from Deployment
# All resources in namespace
kubectl get all -n appsNamespace Management
# Create namespace
kubectl create namespace staging
# Set default namespace for context
kubectl config set-context --current --namespace=apps
# Resource quota for namespace
kubectl create quota apps-quota --hard=cpu=4,memory=8Gi -n appsK3s Cluster Operations
# K3s service control (on server/control-plane node)
systemctl status k3s
systemctl restart k3s
journalctl -u k3s -f
# K3s agent (on worker nodes)
systemctl status k3s-agent
systemctl restart k3s-agent
# Node status
kubectl get nodes -o wide
# Drain node for maintenance
kubectl drain NODE_NAME --ignore-daemonsets --delete-emptydir-data
kubectl uncordon NODE_NAME # re-enable scheduling after maintenance
# Kubeconfig location
cat /etc/rancher/k3s/k3s.yaml
# Copy to ~/.kube/config and replace 127.0.0.1 with server IP for remote accessTopology Spread (Multi-Node HA)
# Spread pods across nodes — add to pod spec
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: myappAnti-Patterns
latesttag in production — breaksIfNotPresent, no rollback possible. Always use versioned tags.- Secrets in ConfigMap — ConfigMaps are not encrypted at rest. Use Secret type.
- No resource requests/limits — pods compete unbounded; one misbehaving app OOMKills others.
- ConfigMap/Secret changes not triggering restart — add
kubectl rollout restartto deploy pipeline. - Storing state in pod filesystem — ephemeral; use PVC or external storage.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

