(4)kubectl delete 通过配置文件名、stdin、资源名称或label选择器来删除资源。 支持JSON和YAML格式文件。可以只指定一种类型的参数:文件名、资源名称或label选择器。 有些资源,如pod,支持优雅的(graceful)删除,因为这些资源一般是集群中的实体,所以删除不可能会立即生效,这些资源在强制终止之前默认定义了一个周期(宽...
kubectl exec 用于在一个正在运行的容器执行命令。跟 docker 的 exec 命令类似。 代码语言:javascript 复制 # Get output from running 'date' from pod 123456-7890, using the first container by default kubectl exec 123456-7890 date # Get output from running 'date' in ruby-container from pod 123456-...
$ kubectl config view $ kubectl config view –o jsonpath='{.users[?(@.name == "e2e")].user.password}' kubectl cp− 将文件和目录复制到容器和从容器复制。 $ kubectl cp <Files fromsource> <Files to Destinatiion> $ kubectl cp /tmp/foo <some-pod>:/tmp/bar -c <specific-container> k...
容器内执行命令:kubectl exec -ti <pod-name> sh 容器日志:kubectl logs [-f] <pod-name> 导出服务:kubectl expose deploy <name> --port=80 Base64 解码: kubectl get secret SECRET -o go-template='{{ .data.KEY | base64decode }}' 注意,kubectl run 仅支持 Pod、Replication Controller、Deployment...
as schedulabledrain Drain node in preparation for maintenancetaint Update the taints on one or more nodesTroubleshooting and Debugging Commands:describe Show details of a specific resource or group of resourceslogs Print the logs for a container in a podattach Attach to a running containerexec Execut...
describe Show details of a specific resource or group of resources logs Print the logsfora containerina pod attach Attach to a running container exec Execute a commandina container port-forward Forward one or more local ports to a pod
kubectl exec 在指定容器内执行命令 kubectl port-forward 将本机指定端口映射到pod资源对象的端口 kubectl proxy 将本机指定端口映射到kube-apiserver kubectl cp 用于pod与主机交换文件 kubectl auth 检查验证 (6) Advanced Commands 高级命令 kubectl diff 对比本地json/yaml文件与kube-apiserver中运行的配置文件是否有...
If you need specific information about a resource, you can use thegetcommand for more detailed information. On the other hand, if you want to check the status of a resource, such as a pod that is not in the running state, you can use thedescribecommand to obtain more detailed status in...
# Run busybox container k run busybox --image=busybox:1.28 --rm --restart=Never -it sh # Connect to a specific container in a Pod k exec -it busybox -c busybox2 -- /bin/sh # adding limits and requests in command kubectl run nginx --image=nginx --restart=Never --requests='cpu...
容器内执行命令:kubectl exec -ti <pod-name> sh 容器日志:kubectl logs [-f] <pod-name> 导出服务:kubectl expose deploy <name> --port=80 Base64 解码: kubectl get secret SECRET -o go-template='{{ .data.KEY | base64decode }}'