mac单机环境(国内环境,minikube)k8s搭建(一)

总体目标

纯新手记录本身搭建过程.git

  1. mac单机搭建k8s 测试环境
  2. k8s使用demo
  3. spring boot 在k8s 使用
  4. istio 微服务

mac 搭建k8s

install docker

官方教程
基本是下载,点点点okgithub

install brew

brew mac 包管理(相似于yum,apt)
命令行执行spring

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

官网 自带中文docker

(可跳过) brew update 过慢

brew 本质上也是git pull ,因此当源是一些国外源,因为某些不可描述的缘由,因此会很慢,甚至可能访问不了.
因此咱们要换成git的源.原理是 brew update --verbose 观察卡到哪里,cd到那个目录,替换(git remote set-url origin )ruby

# 替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

# 替换homebrew-cask.git:
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

# 替换homebrew-bottles:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

install minikube

minikube 和 docker desktop

mac单机安装k8s,目前分两种方案.1、docker desktop上Kubernetes集群.2、minikube.
本人选择minikube.
1、docker desktop,自动从k8s拉去镜像,解决办法是本身拉去镜像,而后docker tag 修改为k8s的镜像.因此docker desktop每次升级,必须手动拉去镜像,就该tag.比较麻烦.
2、docker desktop 安装的集群须要本身配置插件,minikube自带一些插件,后期可控.
3、minikube能够跨操做系统安装,相对来讲泛用.curl

安装

mac 虚拟化微服务

sysctl -a | grep -E --color 'machdep.cpu.features|VMX'

底层采用 hyperkit 虚拟机(也能够用其余 好比 VirtualBox、VMware Fusion)测试

brew install hyperkit

正式installgoogle

brew cask install minikube
# 命令查看
minikube help

启动

# minikube config 用户配置一些环境
# minikube config --help 查看帮助
# minikube config view 查看全部配置
# minikube config get/set k v 获取配置/设置配置
minikube config set dashboard true
# 指定驱动 若是用 其余修改
minikube config set vm-driver hyperkit

minikube start --logtostderr --v=3 --registry-mirror=https://registry.docker-cn.com --registry-mirror=https://8eoqixdq.mirror.aliyuncs.com --registry-mirror=https://dockerhub.azk8s.cn  --insecure-registry=local.registry:5000 --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers   --vm-driver="hyperkit"   --memory=4096
# v=3 配置日历(可选)
# registry-mirror 镜像加速地址 (必须不然会很慢)
# https://registry.docker-cn.com
# https://8eoqixdq.mirror.aliyuncs.com
# https://dockerhub.azk8s.cn
# insecure-registry 本地镜像仓储(可选)
# image-repository(必须带,重点,重点)
# registry.cn-hangzhou.aliyuncs.com/google_containers

minikube status
# 查询状态
minikube start/stop/delete
# k8s 集群启动 中止 删除
相关文章
相关标签/搜索