Docker容器微服务架构和实践虚拟化技术

Win10: WSL&Minikube&Helm

2018-09-13  本文已影响4人  qingguee

最近拿到新的工作机,需要搭一个win10上面的minikube 和docker的开发环境。做个记录。

整体思想是在WSL(Microsoft-Windows-Subsystem-Linux)中使用kubectl 和docker的 Client端,链接使用hyper-v中的minikube cluster和docker 虚拟机。

缺陷

把方案缺陷和注意事项列一下

安装需求

安装WSL(Windows Subsystem for Linux)

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

打开Hyper-V

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
PS C:\tools\cmder> DISM /Online /Enable-Feature /All /FeatureName:Microsoft-Hyper-V

Deployment Image Servicing and Management tool
Version: 10.0.16299.15

Image Version: 10.0.16299.611

Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.
PS C:\tools\cmder>

创建 virtual switch for minikube

安装 Chocolatey

Chocolatey : The package manager for Windows

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

choco upgrade chocolatey

安装Minikube

在powershell里面执行

choco install minikube

运行minikube

minikube start --vm-driver hyperv --hyperv-virtual-switch="minikube-vs"

在WSL里面安装kubectl

sudo apt-get update && sudo apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo touch /etc/apt/sources.list.d/kubernetes.list 
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl

配置kubectl

ln -s /mnt/c/User/<username>/.minikube
cp -r /mnt/c/Users/<username>/.kube .
certificate-authority: C:\Users\<username>\.minikube\ca.crt
client-certificate: C:\Users\<username>\.minikube\client.crt 
client-key: C:\Users\<username>\.minikube\client.key  

替换成/home/<username>/.minikube/xxx (这里是个列子,不要删去每行前面的空格)

certificate-authority: /home/<username>/.minikube/ca.crt
client-certificate:  /home/<username>/.minikube/client.crt 
client-key:  /home/<username>/.minikube/client.key  
elluffn@CN-00011373:~$ kubectl get node
NAME       STATUS    ROLES     AGE       VERSION
minikube   Ready     master    21h       v1.10.0

kubectl get po --all-namespaces
kube-system   etcd-minikube                               1/1       Running            0          3m
kube-system   kube-addon-manager-minikube                 1/1       Running            7          21h
kube-system   kube-apiserver-minikube                     1/1       Running            0          3m
kube-system   kube-controller-manager-minikube            1/1       Running            0          3m
kube-system   kube-dns-86f4d74b45-n2f5m                   3/3       Running            27         21h
kube-system   kube-proxy-99kpm                            1/1       Running            0          2m
kube-system   kube-scheduler-minikube                     1/1       Running            8          21h
kube-system   kubernetes-dashboard-5498ccf677-zrffj       1/1       Running            18         21h
kube-system   storage-provisioner                         1/1       Running            18         21h
kube-system   tiller-deploy-df4fdf55d-6c8jb               1/1       Running            7          21h

安装helm

$ curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh
$ chmod 700 get_helm.sh
$ ./get_helm.sh
helm init

Mount 本地目录到Minikube

minikube.exe mount .\git\:/media
Mounting .\git\ into /media on the minikube VM
This daemon process needs to stay alive for the mount to still be accessible...
ufs starting

这个进程窗口不能关闭。

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\tools\cmder> minikube.exe ssh
                         _             _
            _         _ ( )           ( )
  ___ ___  (_)  ___  (_)| |/')  _   _ | |_      __
/' _ ` _ `\| |/' _ `\| || , <  ( ) ( )| '_`\  /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )(  ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)

$ ls /media/
test demo 
$

后面再补一篇WSL with Docker的文章。

Reference

上一篇下一篇

猜你喜欢

热点阅读