k8s基本命令

问题:常用的命令有哪些?有什么用?怎么用?

解答

kubectl edit

k8s修改资源设置

po
kubectl edit po <your_poName>
svc
kubectl edit svc <svc_name>
deploy
kubectl edit deploy <deployment_name>
(repulicate set)rs
kubectl edit rs <republicateSet_name>

kubectl exec

如同docker exec ,进入到pod容器里面的命令

kubectl cp

拷贝pod里面数据,pod里面容器需要安装tar的命令,从报错信息可以获取。

[root@host1 test]# kubectl cp pod-834063700-d9x0p:/entry/cpfile /test/cpfile
exec: "tar": executable file not found in $PATH
#安装tar
[root@pod-834063700-d9x0p entry]# yum -y install tar
Loaded plugins: fastestmirror
[root@host1 test]# kubectl cp pod-834063700-d9x0p:/entry/cpfile /test/cpfile 
tar: Removing leading `/' from member names

[root@host1 test]# ls
 cpfile             cp    

kubectl get

svc

kubectl get svc --namespace==kube.system
pod
kubectl get po --namespace=kube-system
#或者
kubectl get pods -n kube-system
NAME                                        READY     STATUS             RESTARTS   AGE
calico-etcd-j48s1                           1/1       Running            0          6d
calico-node-123s0                           1/2       CrashLoopBackOff   1898       6d
calico-policy-controller-1727037546-m46kq   1/1       Running            0          6d
etcd-host1.ambari.com                       1/1       Running            0          6d
kube-apiserver-host1.ambari.com             1/1       Running            0          6d
kube-controller-manager-host1.ambari.com    1/1       Running            0          6d
kubectl get pods --all-namespaces
namespace
kubectl get namespace
NAME          STATUS    AGE
default       Active    6d
kube-public   Active    6d
kube-system   Active    6d
events
kubectl get events --all-namespaces

kubectl describe

pod
kubectl describe po --namespace=kube-system calico-node-123s0

参考

1.http://blog.csdn.net/liumiaocn/article/details/73925301
2.k8s api server

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐