windows 安装 kubectl与使用

官方参考来源

下载地址

参考教程

安装

复制在文件夹,在windows 环境变量中添加路径

测试

kubectl version --client

kubectl cluster-info

创建一个HTTP 服务器

kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.10
kubectl expose deployment hello-minikube --type=NodePort --port=8080

hello-minikube Pod 开始运行,但是必须等到 Pod 启动 ,测试Pod是否运行

 kubectl get pod

以下两个状态一个创建过程中,一个已经成功运行
在这里插入图片描述
可以通过以下命令得到暴露的服务, 把获取的url 粘贴到浏览器能看到本地集群的细节

minikube service hello-minikube --url

删除服务

kubectl delete services hello-minikube
kubectl delete deployment hello-minikube

开启第二个终端窗口去运行代理,代理可以通过CTRL+C的方式终止

kubectl proxy

使用 kubectl 进行故障排除

kubectl get - 列出资源
kubectl describe - 显示有关资源的详细信息
kubectl logs - 打印 pod 和其中容器的日志
kubectl exec - 在 pod 中的容器上执行命令

kubectl get nodes			查看node节点信息
kubectl describe node k8s-node-01	查看某个node的详细信息

删除的方法

1、先删除pod
2、再删除对应的deployment

kubectl get pod -n hello-minikube
kubectl delete pod jello-minikube-dsf44735dhd -n hello-minikube
kubectl get pod -n hello-minikube
kubectl get deployment -n hello-minikube
kubectl delete deployment hello-minikube-n hello-minikube
kubectl get deployment -n hello-minikube
kubectl get pod -n hello-minikube

另外一种安装方法

choco install kubernetes-cli
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值