Useful kubectl and helm commands

Some commands you also might find useful when working with kubectl

Posted April 21, 2022 by Adrian Wyssmann


Sort events by creationTimestamp:

kubectl get events --sort-by='.metadata.creationTimestamp' -A

Sort events by lastTimestamp’:

kubectl get events --sort-by='.lastTimestamp'

Check which serviceentries have exportTo defined.

The exportTo field allows for control over the visibility of a service declaration to other namespaces in the mesh. By default, a service is exported to all namespaces. You can restricts the visibility to the current namespace, represented by ., so that it cannot be used by other namespaces.

kubectl get serviceentries --all-namespaces -o jsonpath="{range .items[*]}{.metadata.namespace}{'\t'}{}{'\t'}{.spec.exportTo}{'\n'}{end}" --context sit | awk '{printf "%-40s %-60s %-10s\n", $1,$2,$3}'


With the following command you can get the custom helm values applied to a helm releas:

helm -n <namespace> get all <release-name>

Edit this page