运行环境:Windows 10家庭中文版 版本号:1909
一、下载并安装docker desktop for windows
下载:https://www.docker.com/products/docker-desktop
安装要求:
安装WSL2:
以管理员身份运行powshell
设置docker mirrors:
{
"registry-mirrors": [
"https://registry.docker-cn.com",
"https://docker.mirrors.ustc.edu.cn"
],
"insecure-registries": [],
"debug": false,
"experimental": false,
"features": {
"buildkit": true
}
}
二、安装k8s
https://github.com.cnpmjs.org/AliyunContainerService/k8s-for-docker-desktop
下载zip包,按照页面说明进行安装
执行命令:
(参考:https://blog.csdn.net/weixin_41362657/article/details/110649744?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-2.control&dist_request_id=1331645.7931.16183640785829817&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-2.control)
安装完成后,需要在docker里启动k8s
三、安装helm
参考:https://blog.csdn.net/zhwyj1019/article/details/97665192
下载地址:https://mirrors.huaweicloud.com/helm/v3.5.3/
四、安装kubectl
下载,拷贝到目录
https://storage.googleapis.com/kubernetes-release/release/v1.9.0/bin/windows/amd64/kubectl.exe
五、安装daprCLI
参考:https://docs.dapr.io/getting-started/install-dapr-cli/
以管理员身份运行powershell,
运行 iwr -useb https://raw.githubusercontent.com/dapr/cli/master/install/install.ps1 | iex
提示如下错误
需要配置host文件
C:WindowsSystem32driversetcHOSTS
增加如下内容:
# GitHub Start
52.74.223.119 github.com
192.30.253.119 gist.github.com
54.169.195.247 api.github.com
185.199.111.153 assets-cdn.github.com
151.101.76.133 raw.githubusercontent.com
151.101.108.133 user-images.githubusercontent.com
151.101.76.133 gist.githubusercontent.com
151.101.76.133 cloud.githubusercontent.com
151.101.76.133 camo.githubusercontent.com
151.101.76.133 avatars0.githubusercontent.com
151.101.76.133 avatars1.githubusercontent.com
151.101.76.133 avatars2.githubusercontent.com
151.101.76.133 avatars3.githubusercontent.com
151.101.76.133 avatars4.githubusercontent.com
151.101.76.133 avatars5.githubusercontent.com
151.101.76.133 avatars6.githubusercontent.com
151.101.76.133 avatars7.githubusercontent.com
151.101.76.133 avatars8.githubusercontent.com
# GitHub End
命令窗口运行dapr
六、安装dapr运行时
参考:https://www.cnblogs.com/thrillcattle/p/14191058.html
helm repo add dapr https://dapr.github.io/helm-charts/
helm repo update
kubectl create namespace dapr-system
helm install dapr dapr/dapr --version 1.1 --namespace dapr-system
七、安装demo
参考:https://github.com/sd797994/Oxygen-Dapr.EshopSample
- 安装ingress-controller
https://kubernetes.github.io/ingress-nginx/deploy/#using-helm
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install ingress-nginx ingress-nginx/ingress-nginx
这时会提示错误:Error: failed to download "ingress-nginx/ingress-nginx" (hint: running `helm repo update` may help)
正确的安装方式:
https://blog.csdn.net/qq_28540443/article/details/103524156?utm_medium=distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromMachineLearnPai2~default-5.control&dist_request_id=1331303.9633.16182952752392803&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromMachineLearnPai2~default-5.control
添加源仓库:
helm repo remove stable && helm repo add stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
helm repo update
解压nginx-ingress-0.9.5.tgz到当前文件夹
修改 ginx-ingress emplates目录下的两个文件 controller-deployment.yaml 和 default-backend-deployment.yaml,将extensions/v1beta1修改为apps/v1
出现报错信息:
Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Deployment.spec): missing required field "selector" in io.k8s.api.apps.v1.DeploymentSpec
解决方案:
由于k8s1.16版本升级,需要Deployment.spec中加selector,所以愉快地加上就行了。
修改 ginx-ingress emplates目录下的两个文件 controller-deployment.yaml 和 default-backend-deployment.yaml,添加spec.selector代码块与metadata.labels对应
helm uninstall nginx-ingress nginx-ingress -n kube-system
helm install nginx-ingress nginx-ingress -n kube-system
替换前:
替换后:
查看是否安装成功:
kubectl --namespace kube-system get services -o wide -w nginx-ingress-controller
修改端口为30882:
kubectl --namespace kube-system edit svc nginx-ingress-controller
打开配置文件后搜索NodePort,http的端口号修改为30882,
保存即可。
- 安装服务
在目录中git clone https://github.com/sd797994/Oxygen-Dapr.EshopSample.git
cd Oxygen-Dapr.EshopSample
cd Deploy
RunBasic.bat #下载基础设施,含项目使用的数据库、dapr用于状态和事件管理的中间件及网关和链路追踪组件
cd Release
BuildImages.bat #构建服务镜像,由于是第一次运行,需要拉取基础镜像以及npm install包,可能会较慢
Deploy.bat #运行
目前安装环境已完成,但是还是没有能把demo跑起来,继续努力。