kubernetes cli插件

时间:Jan. 25, 2019 分类:

目录:

在kubernetes的1.12的插件,可以是任意语言,只要是一个可执行文件即可,加载方式是放在PATH下

$ go get k8s.io/sample-cli-plugin/cmd
$ sudo /usr/bin/cp /root/go/src/k8s.io/sample-cli-plugin/cmd/kubectl-ns.go /usr/bin/
$ kubectl ns kube-system
namespace changed to "kube-system"
$ kubectl get pod
NAME                             READY   STATUS    RESTARTS   AGE
coredns-86c58d9df4-ksk6j         1/1     Running   2          2d9h
coredns-86c58d9df4-rxkmt         1/1     Running   2          2d9h
es-client-79ffbbc576-d6gpl       1/1     Running   1          42h
es-client-79ffbbc576-qtskv       1/1     Running   0          42h
es-data-0                        1/1     Running   0          41h
es-data-1                        1/1     Running   0          41h
es-master-7d9c845d86-fswgk       1/1     Running   1          42h
es-master-7d9c845d86-stv9r       1/1     Running   0          42h
es-master-7d9c845d86-xs7cf       1/1     Running   1          42h
etcd-master                      1/1     Running   2          8d
kibana-58fb5cccf7-7csxk          1/1     Running   0          38h
kube-apiserver-master            1/1     Running   2          8d
kube-controller-manager-master   1/1     Running   4          8d
kube-flannel-ds-amd64-26l9f      1/1     Running   2          8d
kube-flannel-ds-amd64-4khwn      1/1     Running   3          8d
kube-flannel-ds-amd64-c5nzw      1/1     Running   3          8d
kube-proxy-4cstd                 1/1     Running   3          8d
kube-proxy-lbknw                 1/1     Running   3          8d
kube-proxy-sjhpk                 1/1     Running   2          8d
kube-scheduler-master            1/1     Running   4          8d

可以看到get pod的时候获取的都是kube-system的namespace下的pod