有些朋友问怎么在windows上调试自己的环境,刚好最近也在自己的虚拟环境调试,就整理下了文档
以kubectl和helm以及kustomize为例
下载对应的包
你要正常使用当你包,必须是与你kubernetes版本匹配的,这些信息在他们的readme.md中都有介绍
假如你的k8s 是1.20的,那你就不能使用与此版本差距太大的版本以免出现未知的问题
而其他的大版本的包使用方式一直在发送变化
https://dl.k8s.io/release/v1.20.11/bin/windows/amd64/kubectl.exe
https://get.helm.sh/helm-v3.8.2-windows-amd64.zip
https://github.com/kubernetes-sigs/kustomize/releases/tag/kustomize%2Fv3.10.0
将exe放置在一个位置,比如:C:k8sbin
PS C:k8sbin> dir
目录: C:k8sbin
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2022-04-14 1:47 46256128 helm.exe
-a---- 2022-04-16 12:59 41438208 kubectl.exe
-a---- 2021-02-10 8:03 15297536 kustomize.exe
以win10为例,在左下角的搜索栏中,或者有一个放大镜,输入"环境变量"
重新打开一个窗口
PS C:WINDOWSsystem32> kubectl.exe version
Client Version: version.Info{Major:"1", Minor:"16+", GitVersion:"v1.16.6-beta.0", GitCommit:"e7f962ba86f4ce7033828210ca3556393c377bcc", GitTreeState:"clean", BuildDate:"2020-01-15T08:26:26Z", GoVersion:"go1.13.5", Compiler:"gc", Platform:"windows/amd64"}
Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.
PS C:WINDOWSsystem32> kustomize.exe version
{Version:kustomize/v3.10.0 GitCommit:602ad8aa98e2e17f6c9119e027a09757e63c8bec BuildDate:2021-02-10T00:00:50Z GoOs:windows GoArch:amd64}
PS C:WINDOWSsystem32> helm version
version.BuildInfo{Version:"v3.8.2", GitCommit:"6e3701edea09e5d55a8ca2aae03a68917630e91b", GitTreeState:"clean", GoVersion:"go1.17.5"}
PS C:WINDOWSsystem32>
将kubernetes的config文件拿到本地
cat /etc/kubernetes/kubelet.kubeconfig
在windwos上当前用户的加目录创建.kube,并将kubelet.kubeconfig 内容复制到一个config的文件中
C:UsersAdministrator.kubeconfig
get
PS C:UsersAdministrator.kube> kubectl.exe get pod
NAME READY STATUS RESTARTS AGE
dpment-linuxea-6bdfbd7b77-fr4pn 1/1 Running 9 10d
dpment-linuxea-a-5b98f7fb86-9ff2f 1/1 Running 17 23d
hello-run-96whr-pod 0/1 Completed 0 10d
hello-run-pod 0/1 Completed 0 10d
mysql-1649582722-dbcdcb895-tjvsr 1/1 Running 6 5d20h
nfs-client-provisioner-597f7dd4b-h2nsg 1/1 Running 71 248d
testv1-9c974bd5d-gl52m 1/1 Running 9 10d
testv2-5767685995-mjd6c 1/1 Running 16 22d
traefik-6866c896d5-dqlv6 1/1 Running 9 10d
ubuntu 0/1 Error 0 5d19h
whoami-7d666f84d8-8wmk4 1/1 Running 15 20d
whoami-7d666f84d8-vlgb9 1/1 Running 9 10d
whoamitcp-744cc4b47-24prx 1/1 Running 9 10d
whoamitcp-744cc4b47-xrgqp 1/1 Running 9 10d
whoamiudp-58f6cf7b8-b6njt 1/1 Running 9 10d
whoamiudp-58f6cf7b8-jnq6c 1/1 Running 15 20d
PS C:UsersAdministrator.kube>
如下图
挂在windows共享目录
- 仅限于内网共享使用
如果是传统的共享,你需要创建用户,需要共享文件,权限指定,而后使用netstat -aon来过滤139,145,138端口权限是否开启
添加用户权限到共享文件夹
查看是否打开共享
yum install cifs-utils -y
挂载
mount -t cifs -o username=share,password=share //172.16.100.3/helm /data/helm
[root@liinuxea.com /data]# mkdir helm
[root@liinuxea.com /data]# mount -t cifs -o username=share,password=share //172.16.100.3/helm /data/helm
[root@liinuxea.com /data]# df -h|grep helm
//172.16.100.3/helm 282G 275G 6.5G 98% /data/helm