minikube在mac单机上部署kubernetes沙箱环境
说明eva系统,由前端eva-web,后端eva-api,数据库eva-mysql 三部分组成。本地minikube环境,有eva-web,eva-api(因为IP限制,只能访问本地eva-mysql)和eva-mysql这三个服务.沙箱k8s环境,只有eva-web,eva-api(直接访问阿里云rds)这两个服务.准备工作1.安装Docker for Machttps://docs.dock
说明
eva系统,由前端eva-web,后端eva-api,数据库eva-mysql 三部分组成。
本地minikube环境,有eva-web,eva-api(因为IP限制,只能访问本地eva-mysql)和eva-mysql这三个服务.
沙箱k8s环境,只有eva-web,eva-api(直接访问阿里云rds)这两个服务.
准备工作
1.安装Docker for Mac
https://docs.docker.com/docker-for-mac/install/#install-and-run-docker-for-mac
安装Docker_1.13.1.dmg 生成:/Applications/Docker.app
启动 /Applications/Docker.app
2.安装VirtualBox https://www.docker.com/products/docker-toolbox
下载DockerToolbox.pkg 并安装
启动/Applications/VirtualBox.app
3.安装minikube
https://github.com/kubernetes/minikube/releases
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.17.1/minikube-darwin-amd64
xattr -c minikube && chmod +x minikube && mv minikube /usr/local/bin/
4.安装minikube的xhyve driver (for mac)
https://github.com/zchee/docker-machine-driver-xhyve#install
$ brew install docker-machine-driver-xhyve
# docker-machine-driver-xhyve need root owner and uid
$ sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
$ sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
5.安装kubectl (pronounced ‘kube (like ‘tube’) control`)
wget https://storage.googleapis.com/kubernetes-release/release/v1.5.3/bin/darwin/amd64/kubectl
chmod +x ./kubectl
mv ./kubectl /usr/local/bin/kubectl
6.修改本地环境变量
如果是bash
vi ~/.bash_profile #最后添加3行 export DIR_DOCKERFILE=/var/www/Dockerfile export DIR_EVA_WEB=/var/www/eva export DIR_EVA_API=$GOPATH/src/eva-api #让新增环境变量在当前terminal内生效 source ~/.bash_profile
如果是zsh
vi ~/.zsh #最后添加3行 export DIR_DOCKERFILE=/var/www/Dockerfile export DIR_EVA_WEB=/var/www/eva export DIR_EVA_API=$GOPATH/src/eva-api #让新增环境变量在当前terminal内生效 source ~/.zsh
mac本地minikube环境测试
1.启动minikube
minikube start --vm-driver=xhyve
eval $(minikube docker-env)
2.重启相关服务
#重新制作eva-web的image,本地重启eva-web服务
cd $DIR_EVA_WEB/image/kubernetes/
./rebuild.sh
#重新制作eva-api的image,本地重启eva-api服务
cd $DIR_EVA_API/image/kubernetes/eva-api
./rebuild.sh
#重新制作eva-mysql的image,本地重启eva-mysql服务
cd $DIR_EVA_API/image/kubernetes/eva-mysql
./rebuild.sh
本地docker测试地址: http://192.168.99.100:31087
更多推荐
所有评论(0)