kashinoki38 blog

something like tech blog

【備忘】Kubernetesコマンド

Kubernetesコマンド備忘っす。

全リソース出力

$ kubectl get "$(kubectl api-resources --namespaced=true --verbs=list -o name | tr "\n" "," | sed -e 's/,$//')"

EvictedなPod削除

$ kubectl get pods -A | awk '{if ($4 ~ /Evicted/) system ("kubectl delete pods -n istio-system " $2)}'

LocalポートからPodのポートへのポートフォワード

$ kubectl port-forward -n istio-system  $(kubectl get pod  -l app=prometheus -n istio-system -o template --template "{{(index .items 0).metadata.name}}") 9090:9090

pod間のポート通信疎通

$ kubectl exec -it sample-pod //bin/sh
$ wget http://10.0.0.0:9090/ -qO -

pod内のコンテナ一覧出力

$ kubectl get pods istio-pilot-664c9fcbd4-58q52  -n istio-system -o jsonpath='{.spec.containers[*].name}'