kubectl命令管理
Posted zc1741845455
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了kubectl命令管理相关的知识,希望对你有一定的参考价值。
kubectl命令管理
查看更多帮助命令
[[email protected] ~]# kubectl --help
创建一个命名空间
[[email protected] ~]# kubectl create namespace yunjisuan
namespace "yunjisuan" created
[[email protected] ~]# kubectl get namespace /ns 都可以
查看信息所有
[[email protected] ~]# kubectl get all
NAME READY STATUS RESTARTS AGE
po/nginx-5fc8fd597f-4q22p 1/1 Running 0 9m
po/nginx-5fc8fd597f-8h94r 1/1 Running 0 11m
po/nginx-5fc8fd597f-ppfhf 1/1 Running 0 11m
查看资源的yaml文件信息,并可以修改
我直接修改nginx的版本号为1.12
[[email protected] ~]# kubectl edit deploy/nginx
template:
metadata:
creationTimestamp: null
labels:
run: nginx
spec:
containers:
- image: nginx:1.12
imagePullPolicy: Always
查看yaml文件资源已经修改成功
[[email protected]-master ~]# kubectl describe po/nginx-5fc8fd597f-4q22p
nginx:
Container ID: docker://706661f913c042c2aa2edfd2d649eccade76b9bad71e53052f69588749580f4e
Image: nginx:1.12
查看进群信息
[[email protected] ~]# kubectl cluster-info
Kubernetes master is running at http://localhost:8080
kubernetes-dashboard is running at http://localhost:8080/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy
To further debug and diagnose cluster problems, use ‘kubectl cluster-info dump‘.
查看pod日志
[[email protected] ~]# kubectl logs nginx-5fc8fd597f-4q22p
进入pod
[[email protected] ~]# kubectl exec -it nginx-5fc8fd597f-4q22p bash
查看pod目录文件
[[email protected] ~]# kubectl exec -it nginx-5fc8fd597f-4q22p -- ls
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
查看版本
[[email protected] ~]# kubectl version
删除资源
[[email protected] ~]# kubectl delete deploy/nginx
[[email protected] ~]# kubectl delete svc/nginx
查看资源
[[email protected] ~]# kubectl get all
以上是关于kubectl命令管理的主要内容,如果未能解决你的问题,请参考以下文章