Skip to content

kubectl

kubectl 常用命令

查看容器日志

kubectl logs 

命令行创建

kubectl run nginx --image=nginx:latest --image-pull-policy=IfNotPresent

导出yaml文件

kubectl get pods -o yaml > pod.yaml

exec

kubectlexec -it exec-pod -c busybox -- sh

cp

要保证容器中有 tar 命令, 没有就需要装一下

kubectl cp exec-pod:etc/hosts /tmp/hosts

Comments