kubectl help
[root@host ~]# kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.3", GitCommit:"2e7996e3e2712684bc73f0dec0200d64eec7fe40", GitTreeState:"clean", BuildDate:"2020-05-20T12:52:00Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.3", GitCommit:"2e7996e3e2712684bc73f0dec0200d64eec7fe40", GitTreeState:"clean", BuildDate:"2020-05-20T12:43:34Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
root@host ~]# kubectl cluster-info
Kubernetes master is running at https://192.168.31.27:6443
KubeDNS is running at https://192.168.31.27:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
[root@host68 ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
host68 Ready master 131d v1.18.3
host69 Ready <none> 70d v1.18.6
host70 Ready <none> 38d v1.18.3
host71 Ready <none> 70d v1.18.6
host72 Ready <none> 66d v1.18.3
host73 Ready <none> 66d v1.18.3
host74 Ready <none> 126d v1.18.3
[root@vip-068 ~]# kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default gitlab-86hgh 1/1 Running 0 124d
default mysql-qqghr 1/1 Running 0 129d
es es-46tml 1/1 Running 0 37d
es es-5twv5 1/1 Running 1 37d
es es-g4tnp 1/1 Running 0 29d
es es-vx9r9 1/1 Running 0 30d
es es-xj8kk 1/1 Running 0 27d
kubectl get pod -o=custom-columns=NAME:.metadata.name,STATUS:.status.phase,NODE:.spec.nodeName --all-namespaces
[root@host68 ~]# kubectl -n es get pod es-46tml -o jsonpath="{.spec['containers','initContainers'][*].name}"
es
# 或者
kubectl -n es describe pod es-46tml
# 命令
kubectl -n <namespace> -c <container> exec <pod_name> -- ls -la /
# 示例
kubectl -n es -c es exec es-46tml -- ls -la /usr/share/elasticsearch/config
[root@host68 ~]# kubectl -n es -c es exec es-46tml -- ls -la /usr/share/elasticsearch/config
total 1360
drwxrwxr-x 1 elasticsearch root 4096 Oct 12 13:28 .
drwxrwxr-x 1 elasticsearch root 4096 Sep 5 06:03 ..
-rw-rw---- 1 elasticsearch root 199 Sep 5 06:03 elasticsearch.keystore
-rw-rw---- 1 elasticsearch root 53 May 28 16:33 elasticsearch.yml
-rw-rw---- 1 elasticsearch root 2301 May 28 16:28 jvm.options
drwxrwxr-x 2 elasticsearch root 4096 May 28 16:31 jvm.options.d
-rw-rw---- 1 elasticsearch root 7860 May 28 16:33 log4j2.properties
-rw-rw---- 1 elasticsearch root 473 May 28 16:32 role_mapping.yml
-rw-rw---- 1 elasticsearch root 197 May 28 16:32 roles.yml
-rw-r--r-- 1 root root 1345763 Oct 12 13:28 synonym.txt
-rw-rw---- 1 elasticsearch root 0 May 28 16:32 users
-rw-rw---- 1 elasticsearch root 0 May 28 16:32 users_roles
kubectl -n es -c es exec es-46tml -- rm /usr/share/elasticsearch/config/synonym.txt
kubectl -n es -c es exec es-46tml -- mkdir /usr/share/elasticsearch/config/analysis
# 拷贝
kubectl -n es -c es cp synonym.txt es-46tml:/usr/share/elasticsearch/config/analysis
# 查看
[root@host68 test]# kubectl -n es -c es exec es-46tml -- ls -la /usr/share/elasticsearch/config/analysis
total 1324
drwxr-xr-x 2 root root 4096 Oct 13 05:57 .
drwxrwxr-x 1 elasticsearch root 4096 Oct 13 05:56 ..
-rw-r--r-- 1 root root 1345763 Oct 13 05:57 synonym.txt
qbit snap
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。