Kubernetes集群命令行工具kube_ctl 常用命令

Kubernetes集群命令行工具kube_ctl 常用命令

kubectl是Kubernetes集群的命令行工具,通过kubectl能够对集群本身进行管理,并能够在集群上进行容器化应用的安装部署。

1、配置kubectl 命令自动补全

[root@k8s-master ~]#source <(kubectl completion bash)

2、K8S集群创建好后查看集群信息

[root@k8s-master ~]# kubectl cluster-info

Kubernetes master is running at https://10.0.0.15:6443

KubeDNS is running at https://10.0.0.15:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

[root@k8s-master ~]#

3、查看deployment资源的详细信息


[root@k8s-master ~]# kubectl describe deployment test-nginx

4、deployment 扩容

[root@k8s-master ~]# kubectl scale deployment --replicas=2 test-nginx

deployment.apps/test-nginx scaled

5、通过kubectl命令行创建deployment


[root@k8s-master ~]# kubectl run nginx-deploy --image=nginx:1.14-alpine --port=80 --dry-run=true

nginx-deploy:是我们创建 deployment 的名字

--image: 指定使用的镜像

--port=80 :容器暴露的端口,该端口只能在 K8S 集群中访问

-dry-run=true : 检测语法是否错误,不会正式创建

6、通过Kubectl命令行创建service

[root@k8s-master ~]# kubectl expose deployment nginx-deploy --name=nginx --port=80 --protocol=TCP
service/nginx exposed
[root@k8s-master ~]# kubectl get svc
NAME        TYPE        CLUSTER-IP      EXTERNAL-IP  PORT(S)  AGE
kubernetes  ClusterIP  
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值