Skip to content

Tips

Should I Use ReplicatSet ?

No. Use Deployment instead.

Deployment is an object which can own ReplicaSets and update them and their Pods via declarative, server-side rolling updates. While ReplicaSets can be used independently, today they're mainly used by Deployments as a mechanism to orchestrate Pod creation, deletion and updates. When you use Deployments you don't have to worry about managing the ReplicaSets that they create. Deployments own and manage their ReplicaSets. As such, it is recommended to use Deployments when you want ReplicaSets

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

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 a object, to print fields you can use :

kubectl describe secret <secret name>

Curl a 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