Skip to content

Tips

Use Short Names

With the cli kubectl you can use resources shortnames instead of long name.

For example

kubectl get statefulset

is equal to

kubectl get sts

Hereafter are commonly used shortnames:

Short name Full Name
cm configmaps
ds daemonsets
deploy deployments
ep endpoints
ing ingresses
ns namespaces
no nodes
pvc persistentvolumeclaims
pv persistentvolumes
po pods
rs replicasets
quota resourcequotas
sa serviceaccounts
svc services
sts statefulset

To show all shortnames use kubectl api-resources.

kubectl api-resources
Print Resources

To print all the resources from a given namespace:

kubectl get all -n namespace_name

To print a resource type from all namespaces:

kubectl get svc --all-namespaces
Decode a Secret
kubectl get secret <secret_name> -n <namespace_name> \
    -o jsonpath='{.data.MINIO_SECRET_KEY}' | base64 --decode

The jsonPath is used to retrieve a specific field of an object, to print fields you can use :

kubectl describe secret <secret name>
Curl an internal Service

If you want to test an internal service (type: ClusterIP) by sending curl commands, you need to create a Pod and run curl commands from it.

kubectl run -it --rm --restart=Never debugcurl --image=curlimages/curl -- sh
Search for a pod

To search the pod running your application, you'll only need your application name.

kubectl get pods -l app=<name> --all-namespaces

Search for a log

To search for a specific log, you'll only need your pod's name and namespace. If you don't, check the associated tip.

kubectl logs <pod> -n <namespace> | grep "<log>"