Minikube安装-MacOS M1

Posted by Yuankun Li on 2022-11-02

Minikube 是什么

Minikube Git

Minikube是一个可以快速构建一个单节点本地运行Kubernetes环境的一个工具,它专注于让快速创建本地Kubernetes环境,用于学习和开发。
抛去多集群有关的特性,Minukube构建的单节点集群,足以使用户探索和发现Kubernate的绝大多数主要功能。

Minikube 安装

参考Minikube 官方Installation文档

Minikube支持安装在OSX, Windows, Linux.

本篇文章是按照安装MacOS来写的,其他操作系统请参考:

安装Minikube

通过Homebrew安装在本地mac上

最简单的安装方式Homebrew, 如果系统没有安装brew工具请参考之前的文章

1
2
3
4
brew install minikube

# 查看minikube
which minikube

通过Git安装

安装docker

目前看只有Docker Desktop for Mac (macOS)可以下载.

安装 kubectl(K8s的CLI工具)

1
2
3
4
brew install kubectl

# 查看版本
kubectl version --client

安装虚拟机管理器

安装hyperkit (适合x86_64机器)

1
2
3
4
5
6
7
8
9
10
brew install hyperkit

# To check your current version, run:
hyperkit -v

# If the version didn’t change after upgrading verify the correct HyperKit is in the path. run:
which hyperkit

#Run to make sure the version matches minikube
docker-machine-driver-hyperkit version

问题:Mac M1: hyperkit not supported

如果在Mac M1上brew install hyperkit, 报错

1
2
3
4
brew install hyperkit

hyperkit: The x86_64 architecture is required for this software.
Error: hyperkit: An unsatisfied requirement failed this build.

解决方法:

安装qemu (兼容MAC M1)

  • Mac M1: hyperkit not supported
    • HyperKit is Intel-only, so the alternative to QEMU will be the new Virtualization.framework driver
      • brew install qemu
      • minikube start --driver=qemu --memory=4Gb

运行Minikube

1
minikube start --driver=hyperkit

或者

1
2
# Mac M1
minikube start --driver=qemu

如果没有VPN,为了解决海外资源访问受限问题,可以使用阿里云提供的镜像地址。具体命令如下:

$ minikube start
–cpus=4
–memory=‘6000mb’
–image-mirror-country=‘cn’
–image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers
命令参数说明如下:

–cpus=4:表示为minikube分配的CPU核数;
–memory=‘6000mb’:表示为minikube虚拟机分配的内存数;
–image-mirror-country=‘cn’:将缺省利用"registry.cn-hangzhou.aliyuncs.com/google_containers"作为安装Kubernetes的容器镜像仓库;
–image-repository=“xx”:表示所使用的镜像仓库地址,这里为阿里云地址;

Minikube使用

Testing Minikube

  • minikube status: shows current status
  • kubectl get all: verifies kubectl client operation
  • minikube start: starts Minikube
  • minikube stop: stops Minikube
  • minikube ssh: logs in to the Minikube host
  • docker ps: shows all Docker processes on the Minikube host

Managing Minikube

The minikube command has different options

  • minikube dashboard: opens the K8s dashboard in the local browser
  • minikube delete: deletes a cluster
  • minikube ip: shows the currently used IP address
  • minikube start: starts a cluster
  • minikube stop: stops a cluster
  • minikube status: gives current status
  • minikube version: shows current version

参考文章



show git comment