kubectl get all コマンドを使ってpod,service,deployment などの情報を一度に取得する

個人メモです。

`kubectl get all` コマンドを使うと pod,service,deployment などが取得できる

```
# default ネームスペースの情報郡を取得
$kubectl get all
NAME       READY   STATUS    RESTARTS   AGE
pod/test   1/1     Running   0          47s

NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
service/kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   46m

# 特定ネームスペースの情報郡を取得する
$kubectl get all -n kube-system
NAME                                       READY   STATUS    RESTARTS   AGE
pod/coredns-f9fd979d6-gs5lb                1/1     Running   0          46m
pod/coredns-f9fd979d6-j9sqw                1/1     Running   0          46m
pod/etcd-controlplane                      1/1     Running   0          46m
pod/kube-apiserver-controlplane            1/1     Running   0          46m
pod/kube-controller-manager-controlplane   1/1     Running   0          46m
pod/kube-flannel-ds-amd64-l56nm            1/1     Running   0          46m
pod/kube-flannel-ds-amd64-vph8g            1/1     Running   0          45m
pod/kube-proxy-6w9j9                       1/1     Running   0          45m
pod/kube-proxy-g5bm4                       1/1     Running   0          46m
pod/kube-scheduler-controlplane            1/1     Running   0          46m

NAME               TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                  AGE
service/kube-dns   ClusterIP   10.96.0.10   <none>        53/UDP,53/TCP,9153/TCP   46m

NAME                                     DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
daemonset.apps/kube-flannel-ds-amd64     2         2         2       2            2           <none>                   46m
daemonset.apps/kube-flannel-ds-arm       0         0         0       0            0           <none>                   46m
daemonset.apps/kube-flannel-ds-arm64     0         0         0       0            0           <none>                   46m
daemonset.apps/kube-flannel-ds-ppc64le   0         0         0       0            0           <none>                   46m
daemonset.apps/kube-flannel-ds-s390x     0         0         0       0            0           <none>                   46m
daemonset.apps/kube-proxy                2         2         2       2            2           kubernetes.io/os=linux   46m

NAME                      READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/coredns   2/2     2            2           46m

NAME                                DESIRED   CURRENT   READY   AGE
replicaset.apps/coredns-f9fd979d6   2         2         2       46m
```

すべてのネームスペースを指定する場合 `--all-namespaces` もしくは `-A` を指定する。

[kubectl Cheat Sheet](https://kubernetes.io/docs/reference/kubectl/cheatsheet/)

>kubectl get pods --all-namespaces             # List all pods in all namespaces

># All images running in a cluster
>kubectl get pods -A -o=custom-columns='DATA:spec.containers[*].image'

```
# すべてのネームスペースの情報郡を取得する
$kubectl get all --all-namespaces
NAMESPACE     NAME                                       READY   STATUS    RESTARTS   AGE
default       pod/test                                   1/1     Running   0          85s
kube-system   pod/coredns-f9fd979d6-gs5lb                1/1     Running   0          46m
kube-system   pod/coredns-f9fd979d6-j9sqw                1/1     Running   0          46m
kube-system   pod/etcd-controlplane                      1/1     Running   0          46m
kube-system   pod/kube-apiserver-controlplane            1/1     Running   0          46m
kube-system   pod/kube-controller-manager-controlplane   1/1     Running   0          46m
kube-system   pod/kube-flannel-ds-amd64-l56nm            1/1     Running   0          46m
kube-system   pod/kube-flannel-ds-amd64-vph8g            1/1     Running   0          46m
kube-system   pod/kube-proxy-6w9j9                       1/1     Running   0          46m
kube-system   pod/kube-proxy-g5bm4                       1/1     Running   0          46m
kube-system   pod/kube-scheduler-controlplane            1/1     Running   0          46m

NAMESPACE     NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                  AGE
default       service/kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP                  46m
kube-system   service/kube-dns     ClusterIP   10.96.0.10   <none>        53/UDP,53/TCP,9153/TCP   46m

NAMESPACE     NAME                                     DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
kube-system   daemonset.apps/kube-flannel-ds-amd64     2         2         2       2            2           <none>                   46m
kube-system   daemonset.apps/kube-flannel-ds-arm       0         0         0       0            0           <none>                   46m
kube-system   daemonset.apps/kube-flannel-ds-arm64     0         0         0       0            0           <none>                   46m
kube-system   daemonset.apps/kube-flannel-ds-ppc64le   0         0         0       0            0           <none>                   46m
kube-system   daemonset.apps/kube-flannel-ds-s390x     0         0         0       0            0           <none>                   46m
kube-system   daemonset.apps/kube-proxy                2         2         2       2            2           kubernetes.io/os=linux   46m

NAMESPACE     NAME                      READY   UP-TO-DATE   AVAILABLE   AGE
kube-system   deployment.apps/coredns   2/2     2            2           46m

NAMESPACE     NAME                                DESIRED   CURRENT   READY   AGE
kube-system   replicaset.apps/coredns-f9fd979d6   2         2         2       46m
```

なお、`kubectl get all` はすべての情報を取得している訳ではないので注意

https://github.com/superbrothers/text.superbrothers.dev/blob/master/content/190616-kubectl-get-all-does-not-include-most-resources.md