Small script and take a note to interact between kubectl
and your kubernetes cluster.
You can explore command with kubectl
in some place, including
Helpful command
Get base64 decode of secret with no more 3th party
kubectl get secrets -n < namespac e > < secre t > -o go-template='{{range $k,$v := .data}}{{"### "}}{{$k}}{{"\n"}}{{$v|base64decode}}{{"\n\n"}}{{end}}'
Debug your node via kubectl
kubectl debug node/my-node -it --image= < im g >
Check the resource of workload with resource-capacity
extension
Download via krew
, find out the step at krew installing
# Extension: https://github.com/robscott/kube-capacity
# Check the available resources
kubectl resource-capacity -a
# Check detail resource utilize of all workload
kubectl resource-capacity -p --util
Scale down the statefulset
application
# Use scale option
kubectl scale --replicas= 0 sts < sts nam e >
# Or we can use patch or edit option
kubectl patch statefulsets < stateful-set-nam e > -p '{"spec":{"replicas":<new-replicas>}}'
You need to consider when apply scaling down can not working because βcannot scale down a StatefulSet when any of the stateful Pods it manages is unhealthy. Scaling down only takes place after those stateful Pods become running and ready.β . Read more in: Scale a StatefulSet
Delete pods
with not on state Running
k delete pods -n < name-spac e > --field-selector=status.phase!=Running
kubectlΒ create secret generic accounts-identityserver-certificate --from-file=certificate.pfxΒ --dry-run=client -oΒ yaml Β > Β certificate_sec.yamlΒ
Check currently config context
kubectl config view --minify
Change default storage class for your node
kubectl patch storageclass < sc-specifi c > -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'