Spec Explorer
- kube-spec.dev: A handy tool for exploring Kubernetes resource specifications.
- Link: https://kubespec.dev
Running a One-Time Job from a CronJob
-
To execute a job based on an existing CronJob, use the following command:
kubectl create job --from=cronjob/<cronjob-name> <job-name> -n <namespace-name>
Spawning a Curl Container for Debugging
-
To quickly spin up a
curlcontainer with specific security and resource constraints, use:kubectl run debug-curl \ --image=curlimages/curl \ --overrides='{ "apiVersion": "v1", "spec": { "securityContext": { "runAsNonRoot": true, "runAsUser": 1000, "runAsGroup": 1000 }, "containers": [ { "name": "debug-curl", "image": "curlimages/curl", "resources": { "requests": { "cpu": "100m", "memory": "128Mi" }, "limits": { "cpu": "200m", "memory": "256Mi" } }, "command": ["/bin/sh", "-c", "sleep infinity"] } ] } }'- This command creates a
debug-curlpod with a non-root user context and resource requests/limits. - Connect to the shell using:
kubectl exec -it pod/debug-curl sh- Delete container using
kubectl delete pod/debug-curl - This command creates a
Getting Kubernetes Events
-
To view Kubernetes events sorted by creation timestamp, use:
kubectl get events --sort-by='.metadata.creationTimestamp' -o wide | less- The
lesscommand enables easy scrolling and searching through the event list.
- The
Explaining Specific Kubernetes Fields
-
To get detailed information about a specific field in a Kubernetes resource specification, use
kubectl explain:kubectl explain "postgrescluster.spec.backups.pgbackrest.repos.s3" # sample field- Replace
"postgrescluster.spec.backups.pgbackrest.repos.s3"with the desired field path. This is very usefull for understanding the expected structure and values of kubernetes resources.
- Replace