win10家庭版安装k8s单节点环境

青春壹個敷衍的年華 提交于 2020-12-17 19:31:30

1: 安装 hype-V

首先 win10家庭版 要开启 hype-V 新建如下内容的hype-v.bat文件

pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hyper-v.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL

然后保存,然后右键以管理员身份运行,等待运行完成提示重启电脑,重启即可

安装docker

https://www.docker.com/get-started 下载win版本 安装即可

拉取阿里云的镜像

阿里云专门搞了一个win的镜像加载工具,镜像源在阿里云,比较快
git clone https://github.com/AliyunContainerService/k8s-for-docker-desktop.git
cd k8s-for-docker-desktop
在Windows上,使用 PowerShell
 .\load_images.ps1
 
 docker image
 docker/desktop-kubernetes                                        kubernetes-v1.19.3-cni-v0.8.5-critools-v1.17.0   7f85afe431d8   2 months ago    285MB
k8s.gcr.io/kube-proxy                                            v1.19.3                                          cdef7632a242   2 months ago    118MB
k8s.gcr.io/kube-controller-manager                               v1.19.3                                          9b60aca1d818   2 months ago    111MB
k8s.gcr.io/kube-scheduler                                        v1.19.3                                          aaefbfa906bd   2 months ago    45.7MB
k8s.gcr.io/kube-apiserver                                        v1.19.3                                          a301be0cd44b   2 months ago    119MB
k8s.gcr.io/etcd                                                  3.4.13-0                                         0369cf4303ff   3 months ago    253MB
k8s.gcr.io/coredns                                               1.7.0                                            bfe3a36ebd25   6 months ago    45.2MB
docker/desktop-storage-provisioner                               v1.1                                             e704287ce753   8 months ago    41.8MB
docker/desktop-vpnkit-controller                                 v1.0                                             79da37e5a3aa   9 months ago    36.6MB
k8s.gcr.io/pause                                                 3.2                                              80d28bedfe5d   10 months ago   683kB
quay.io/kubernetes-ingress-controller/nginx-ingress-controller   0.26.1                                           29024c9c6e70   14 months ago   483MB

设置 docker-desktop,运行k8s

打开docker-desktop ,设置---》kubernetes --》选上enable kubernetes --》等待环境启动即可

root@ubuntu:~# kubectl get pod  -A
NAMESPACE     NAME                                     READY   STATUS    RESTARTS   AGE
default       busybox                                  1/1     Running   0          17m
kube-system   coredns-f9fd979d6-557wm                  1/1     Running   0          18m
kube-system   coredns-f9fd979d6-hdjtk                  1/1     Running   0          18m
kube-system   etcd-docker-desktop                      1/1     Running   0          17m
kube-system   kube-apiserver-docker-desktop            1/1     Running   0          17m
kube-system   kube-controller-manager-docker-desktop   1/1     Running   0          17m
kube-system   kube-proxy-bpm5z                         1/1     Running   0          18m
kube-system   kube-scheduler-docker-desktop            1/1     Running   0          17m
kube-system   storage-provisioner                      1/1     Running   0          17m
kube-system   vpnkit-controller                        1/1     Running   0          17m


root@ubuntu:~# kubectl exec -it busybox -- ping -c 3  baidu.com
PING baidu.com (39.156.69.79): 56 data bytes
64 bytes from 39.156.69.79: seq=0 ttl=37 time=53.290 ms
64 bytes from 39.156.69.79: seq=1 ttl=37 time=50.378 ms
64 bytes from 39.156.69.79: seq=2 ttl=37 time=81.427 ms

--- baidu.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 50.378/61.698/81.427 ms

问题

第一次启动k8s可能没有安装coredns,没事,进入到docker-desktop设置 k8s-> reset kubernetes cluster 然后等待再次运行,可能就coredns就安装了

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!