在MacOS上安装minikube
Posted 云原生技术课堂
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在MacOS上安装minikube相关的知识,希望对你有一定的参考价值。
1. 检查环境
检查我们的macOS是不是支持虚拟化
sysctl -a | grep -E --color 'machdep.cpu.features|VMX'
machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C
如果看到结果中有VMX
,VT-x功能就是启用的
2. 安装minikube
2.1. 安装brew
官方的方法安装
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
修改源为aliyun的源 bash
# 替换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
# 应用生效
brew update
# 替换homebrew-bottles:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profilezsh
# 替换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
# 应用生效
brew update
# 替换homebrew-bottles:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc2.2. 安装kubectl
brew install kubectl
或者
brew install kubernetes-cli
2.3. 安装minikube
brew install minikube
3. 启动minkube
minikube start --image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers'
4. 部署应用
创建deployment
kubectl create deployment nginx --image=nginx
暴露端口
kubectl expose deployment nginx --type=LoadBalancer --port=80
service/nginx exposed查看服务
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 12m
nginx LoadBalancer 10.103.91.33 <pending> 80:31382/TCP 6s访问我们的服务
minikube service nginx
|-----------|-------|-------------|---------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|-------|-------------|---------------------------|
| default | nginx | | http://192.168.64.2:31382 |
|-----------|-------|-------------|---------------------------|
以上是关于在MacOS上安装minikube的主要内容,如果未能解决你的问题,请参考以下文章
markdown 在VirtualBox和本地Docker注册表上使用minikube在macOS上设置本地Kubernetes
markdown 在VirtualBox和本地Docker注册表上使用minikube在macOS上设置本地Kubernetes