Kubernetes基本命令

# 查看test空间的service
kubectl get svc -n test


# 查看test空间中cms的yaml文件
kubectl get svc cms -o=yaml  -n test


# 查看集群节点
kubectl get nodes


# 查看有哪些空间名
kubectl get namespace


# 查看test空间的项目状态
kubectl get pods -n test


# -o wide显示所有具体信息
kubectl get pods -n test -o wide


# 查看test命名空间中名称为cms的pod的日志
kubectl logs -f cms -n test


# 查看test命名空间中cms的k8s执行动作
kubectl describe pods cms -n test


# 删除容器
kubectl delete -f nginx.yaml


# 创建容器
kubectl create -f nginx.yaml


# 查看test命名空间中所有应用映射的dns(负载)地址
kubectl get svc -n test -o wide


# 查看test命名空间中所有pod的具体信息
kubectl get pods -n test -o wide


# 查看test命名空间中cms应用映射的dns(负载)地址详细信息
kubectl describe svc cms -n test


# 查看namespace为common的yaml文件
kubectl get ns common  -o yaml


# 查看test 命名空间下fastdfs-0的yaml文件
kubectl get pod -n testfastdfs-0 -o yaml


# 查看test命名空间下<podname>的描述信息
kubectl describe pod <podname> -n test


# 编辑运行的资源对象nginx
kubectl edit deploy nginx


# 复制pod:mymss-** 的/etc/hosts的文件到本地/tmp目录
kubectl cp mymss-**:/etc/hosts /tmp


# 回滚nginx到当前版本的上一个版本
kubectl rollout undo deployment nginx


# 回滚nginx到指定的revision=2版本
kubectl rollout undo deployment nginx --to-revision=2


# 重启pod
方法1:
kubectl get pod {podname} -n {namespace} -o yaml | kubectl replace --force -f -
方法2:
kubectl rollout restart deployment xxxx
说明:会先删除旧的pod再启动新pod

在这里插入图片描述

# 查看test命名空间下的项目

kubectl get deployment -n test

# 修改tes命名t空间下项目jenkins的pods节点数从1改为0
kubectl scale --current-replicas=1 --replicas=0 deployment/jenkins -n test


# 把pod的节点改为1

kubectl scale deployment.apps/mymss-deployment --replicas=1 -n test

通过k8s服务器登录容器

nginx-554c8d959-5gzgm     实例(POD)

test     命名空间

kubectl exec -it nginx-554c8d959-5gzgm /bin/bash -n test
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

运维那些事~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值