Skip to content

Instantly share code, notes, and snippets.

@haphan
Last active December 19, 2019 07:39
Show Gist options
  • Select an option

  • Save haphan/bfc119a2c7d8e1af9ea67021e57b5bb4 to your computer and use it in GitHub Desktop.

Select an option

Save haphan/bfc119a2c7d8e1af9ea67021e57b5bb4 to your computer and use it in GitHub Desktop.

K8S cheatsheet

Trouble removing namespace

Sometimes removing namespace is stucked at terminating state. Removing finalizer: ["kubernetes"] is a terriable idea.

As advised( by @alvaroaleman, try to instead find out which resources in the NS are pending deletio

#Checking if any apiservice is unavailable and hence doesn't serve its resources
kubectl get apiservice|grep False

# Finding all resources that still exist via
kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get -n $your-ns-to-delete

Apiservices and api-resources

kubectl get apiservice -o wide
kubectl api-resources

Microk8s

# Reload api server after csr template update
snap set microk8s csr-refresh=true

Batch suspend cronjob

for name in `kubectl get cronjob -o custom-columns=:.metadata.name`; \
  do kubectl patch cronjobs $name -p '{"spec" : {"suspend" : true }}'; \
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment