1. minikube start

创建或启动一个本地 Kubernetes 集群。

[!TIP|style:flat] 注意事项: 高版本的 minikube 在启动时,拒绝使用 root 用户启动,因此需要其他用户来执行 minikube start

1.1. 帮助

$ minikube start --help
Starts a local Kubernetes cluster

Options:
      --addons=[]: 启用插件。执行 `minikube addons list` 查看可用插件名称列表
      --apiserver-ips=[]: 一组在为 kubernetes 生成的证书中使用的 apiserver IP
地址。如果您希望将此 apiserver 设置为可从机器外部访问,则可以使用这组 apiserver IP 地址
      --apiserver-name='minikubeCA': The authoritative apiserver hostname for apiserver certificates and connectivity.
This can be used if you want to make the apiserver available from outside the machine
      --apiserver-names=[]: 一组在为 kubernetes 生成的证书中使用的 apiserver 名称。如果您希望将此
apiserver 设置为可从机器外部访问,则可以使用这组 apiserver 名称
      --apiserver-port=8443: apiserver 侦听端口
      --auto-update-drivers=true: 如果设置了,将自动更新驱动到最新版本。默认为 true。

--base-image='gcr.io/k8s-minikube/kicbase:v0.0.28@sha256:4780f1897569d2bf77aafb3d133a08d42b4fe61127f06fcfc90c2c5d902d893c':
The base image to use for docker/podman drivers. Intended for local development.
      --cache-images=true: If true, cache docker images for the current bootstrapper and load them into the machine.
Always false with --driver=none.
      --cert-expiration=26280h0m0s: Duration until minikube certificate expiration, defaults to three years (26280h).
      --cni='': CNI plug-in to use. Valid options: auto, bridge, calico, cilium, flannel, kindnet, or path to a CNI manifest (default: auto)
      --container-runtime='docker': The container runtime to be used (docker, cri-o, containerd).
      --cpus='2': Number of CPUs allocated to Kubernetes. Use "max" to use the maximum number of CPUs.
      --cri-socket='': The cri socket path to be used.
      --delete-on-failure=false: If set, delete the current cluster if start fails and try again. Defaults to false.
      --disable-driver-mounts=false: 停用由管理程序提供的文件系统装载
      --disk-size='20000mb': 分配给 minikube 虚拟机的磁盘大小(格式:<数字>[<单位>],其中单位 =
b、k、m 或 g)。
      --dns-domain='cluster.local': The cluster dns domain name used in the Kubernetes cluster
      --dns-proxy=false: 为 NAT DNS 请求启用代理(仅限 virtualbox 驱动程序)
      --docker-env=[]: 传递给 Docker 守护进程的环境变量。(格式:键值对)
      --docker-opt=[]: 指定要传递给 Docker 守护进程的任意标志。(格式:key=value)
      --download-only=false: 如果为 true,仅会下载和缓存文件以备后用 -
不会安装或启动任何项。
      --driver='': Driver is one of: virtualbox, vmwarefusion, kvm2, vmware, none, docker, podman, ssh (defaults to
auto-detect)
      --dry-run=false: dry-run mode. Validates configuration, but does not mutate system state
      --embed-certs=false: if true, will embed the certs in kubeconfig.
      --enable-default-cni=false: DEPRECATED: Replaced by --cni=bridge
      --extra-config=: A set of key=value pairs that describe configuration that may be passed to different components.
        The key should be '.' separated, and the first part before the dot is the component to apply the configuration to.
        Valid components are: kubelet, kubeadm, apiserver, controller-manager, etcd, proxy, scheduler
        Valid kubeadm parameters: ignore-preflight-errors, dry-run, kubeconfig, kubeconfig-dir, node-name, cri-socket,
experimental-upload-certs, certificate-key, rootfs, skip-phases, pod-network-cidr
      --extra-disks=0: Number of extra disks created and attached to the minikube VM (currently only implemented for
hyperkit and kvm2 drivers)
      --feature-gates='': 一组用于描述 alpha 版功能/实验性功能的功能限制的键值对。
      --force=false: 强制 minikube 执行可能有风险的操作
      --force-systemd=false: If set, force the container runtime to use systemd as cgroup manager. Defaults to false.
      --host-dns-resolver=true: 为 NAT DNS 请求启用主机解析器(仅限 virtualbox 驱动程序)
      --host-only-cidr='192.168.59.1/24': 需要用于 minikube 虚拟机的 CIDR(仅限 virtualbox 驱动程序)
      --host-only-nic-type='virtio': 网卡类型仅用于主机网络。Am79C970A, Am79C973, 82540EM, 82543GC, 82545EM
之一,或 virtio(仅限 VirtualBox 驱动程序)
      --hyperkit-vpnkit-sock='': 用于网络连接的 VPNKit 套接字的位置。如果为空,则停用 Hyperkit
VPNKitSock;如果为“auto”,则将 Docker 用于 Mac VPNKit 连接;否则使用指定的 VSock(仅限
hyperkit 驱动程序)
      --hyperkit-vsock-ports=[]: 应在主机上公开为套接字的访客 VSock 端口列表(仅限 hyperkit
驱动程序)
      --hyperv-external-adapter='': External Adapter on which external switch will be created if no external switch is
found. (hyperv driver only)
      --hyperv-use-external-switch=false: Whether to use external switch over Default Switch if virtual switch not
explicitly specified. (hyperv driver only)
      --hyperv-virtual-switch='': hyperv 虚拟交换机名称。默认为找到的第一个 hyperv
虚拟交换机。(仅限 hyperv 驱动程序)
      --image-mirror-country='':
需要使用的镜像镜像的国家/地区代码。留空以使用全球代码。对于中国大陆用户,请将其设置为
cn。
      --image-repository='': Alternative image repository to pull docker images from. This can be used when you have
limited access to gcr.io. Set it to "auto" to let minikube decide one for you. For Chinese mainland users, you may use
local gcr.io mirrors such as registry.cn-hangzhou.aliyuncs.com/google_containers
      --insecure-registry=[]: Insecure Docker registries to pass to the Docker daemon.  The default service CIDR range
will automatically be added.
      --install-addons=true: If set, install addons. Defaults to true.
      --interactive=true: 允许用户提示以获取更多信息

--iso-url=[https://storage.googleapis.com/minikube/iso/minikube-v1.24.0.iso,https://github.com/kubernetes/minikube/releases/download/v1.24.0/minikube-v1.24.0.iso,https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/iso/minikube-v1.24.0.iso]:
Locations to fetch the minikube ISO from.
      --keep-context=false: 这将保留现有 kubectl 上下文并创建 minikube 上下文。
      --kubernetes-version='': The Kubernetes version that the minikube VM will use (ex: v1.2.3, 'stable' for v1.22.3,
'latest' for v1.22.4-rc.0). Defaults to 'stable'.
      --kvm-gpu=false: 在 minikube 中启用实验性 NVIDIA GPU 支持
      --kvm-hidden=false: 向 minikube 中的访客隐藏管理程序签名(仅限 kvm2 驱动程序)
      --kvm-network='default': The KVM default network name. (kvm2 driver only)
      --kvm-numa-count=1: Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver
only)
      --kvm-qemu-uri='qemu:///system': KVM QEMU 连接 URI。(仅限 kvm2 驱动程序)
      --listen-address='': IP Address to use to expose ports (docker and podman driver only)
      --memory='': Amount of RAM to allocate to Kubernetes (format: <number>[<unit>], where unit = b, k, m or g). Use
"max" to use the maximum amount of memory.
      --mount=false: This will start the mount daemon and automatically mount files into minikube.
      --mount-string='/root:/minikube-host': The argument to pass the minikube mount command on start.
      --namespace='default': The named space to activate after start
      --nat-nic-type='virtio': NIC Type used for nat network. One of Am79C970A, Am79C973, 82540EM, 82543GC, 82545EM, or
virtio (virtualbox driver only)
      --native-ssh=true: Use native Golang SSH client (default true). Set to 'false' to use the command line 'ssh'
command when accessing the docker machine. Useful for the machine drivers when they will not start with 'Waiting for
SSH'.
      --network='': network to run minikube with. Now it is used by docker/podman and KVM drivers. If left empty,
minikube will create a new network.
      --network-plugin='': Kubelet network plug-in to use (default: auto)
      --nfs-share=[]: 通过 NFS 装载与访客共享的本地文件夹(仅限 hyperkit 驱动程序)
      --nfs-shares-root='/nfsshares': NFS 共享的根目录位置,默认为 /nfsshares(仅限 hyperkit
驱动程序)
      --no-kubernetes=false: If set, minikube VM/container will start without starting or configuring Kubernetes. (only
works on new clusters)
      --no-vtx-check=false: 禁用在启动虚拟机之前检查硬件虚拟化的可用性(仅限 virtualbox
驱动程序)
  -n, --nodes=1: The number of nodes to spin up. Defaults to 1.
  -o, --output='text': Format to print stdout in. Options include: [text,json]
      --ports=[]: List of ports that should be exposed (docker and podman driver only)
      --preload=true: If set, download tarball of preloaded images if available to improve start time. Defaults to true.
      --registry-mirror=[]: 传递给 Docker 守护进程的注册表镜像
      --service-cluster-ip-range='10.96.0.0/12': 需要用于服务集群 IP 的 CIDR。
      --ssh-ip-address='': IP address (ssh driver only)
      --ssh-key='': SSH key (ssh driver only)
      --ssh-port=22: SSH port (ssh driver only)
      --ssh-user='root': SSH user (ssh driver only)
      --trace='': Send trace events. Options include: [gcp]
      --uuid='': 提供虚拟机 UUID 以恢复 MAC 地址(仅限 hyperkit 驱动程序)
      --vm=false: Filter to use only VM Drivers
      --vm-driver='': DEPRECATED, use `driver` instead.
      --wait=[apiserver,system_pods]: comma separated list of Kubernetes components to verify and wait for after
starting a cluster. defaults to "apiserver,system_pods", available options:
"apiserver,system_pods,default_sa,apps_running,node_ready,kubelet" . other acceptable values are 'all' or 'none', 'true'
and 'false'
      --wait-timeout=6m0s: max time to wait per Kubernetes or host to be healthy.

Usage:
  minikube start [flags] [options]

Use "minikube options" for a list of global command-line options (applies to all commands).

1.2. 参数说明

选项 默认值 描述
--addons=[] - 启用插件。执行 minikube addons list 查看可用插件名称列表
--apiserver-ips=[] - 一组在为 kubernetes 生成的证书中使用的 apiserver IP地址。如果您希望将此 apiserver 设置为可从机器外部访问,则可以使用这组 apiserver IP 地址
--apiserver-names=[] - 一组在为 kubernetes 生成的证书中使用的 apiserver 名称。如果您希望将此 apiserver 设置为可从机器外部访问,则可以使用这组 apiserver 名称
--apiserver-port=8443 8443 apiserver 侦听端口
--auto-update-drivers=true true 如果设置了,将自动更新驱动到最新版本。默认为 true。
--base-image='' - The base image to use for docker/podman drivers. Intended for local development.gcr.io/k8s-minikube/kicbase:v0.0.28
--cache-images=true - If true, cache docker images for the current bootstrapper and load them into the machine. Always false with --driver=none.
--cert-expiration=26280h0m0s 3 年 minikube 证书有效时长,默认是3年(26280h)
--cni='' auto 使用的 CNI 网络插件。有效值为: auto, bridge, calico, cilium, flannel, kindnet, 或者 CNI 清单路径 (default: auto)
--container-runtime='docker' docker 配置使用的容器运行时。有效可选项:docker, cri-o, containerd。
--cpus='2' - 配置分配给 Kubernetes 的 CPU 核数。使用 "max" 时会主机所有 CPU
--cri-socket='' - 配置需要使用的 cri socket 路径
--delete-on-failure=false false 在设置后,如果集群启动和重试失败后会删除当前的集群,默认是 false。
--disable-driver-mounts=false - 停用由管理程序提供的文件系统装载
--disk-size='20000mb' - 分配给 minikube 虚拟机的磁盘大小(格式:<数字>[<单位>],其中单位 = b、k、m 或 g)。
--dns-domain='cluster.local' cluster.local 设置 Kubernetes 集群的 DNS 域名后缀,默认是 cluster.local
--dns-proxy=false - 为 NAT DNS 请求启用代理(仅限 virtualbox 驱动程序)
--docker-env=[] - 传递给 Docker 守护进程的环境变量。(格式:键值对)
--docker-opt=[] - 指定要传递给 Docker 守护进程的任意标志。(格式:key=value)
--download-only=false - 如果为 true,仅会下载和缓存文件以备后用 -不会安装或启动任何项。
--driver='' auto-detect 设置驱动,可选列表: virtualbox, vmwarefusion, kvm2, vmware, none, docker, podman, ssh (defaults toauto-detect)
--dry-run=false - dry-run 模式,验证配置,但不改变系统状态
--embed-certs=false - 如果设置为 true, 会将证书嵌入到kubeconfig
--enable-default-cni=false - 启用: 使用 --cni=bridge 代替
--extra-config= - A set of key=value pairs that describe configuration that may be passed to different components. The key should be '.' separated, and the first part before the dot is the component to apply the configuration to. Valid components are: kubelet, kubeadm, apiserver, controller-manager, etcd, proxy, scheduler。Valid kubeadm parameters: ignore-preflight-errors, dry-run, kubeconfig, kubeconfig-dir, node-name, cri-socket,experimental-upload-certs, certificate-key, rootfs, skip-phases, pod-network-cidr
--extra-disks=0 - Number of extra disks created and attached to the minikube VM (currently only implemented for hyperkit and kvm2 drivers)
--feature-gates='' - 一组用于描述 alpha 版功能/实验性功能的功能限制的键值对。
--force=false - 强制 minikube 执行可能有风险的操作
--force-systemd=false false 如果设置,将强制使用 systemd 来管理 cgroup。默认是 false
--host-dns-resolver=true - 为 NAT DNS 请求启用主机解析器(仅限 virtualbox 驱动程序)
--host-only-cidr='192.168.59.1/24' - 需要用于 minikube 虚拟机的 CIDR(仅限 virtualbox 驱动程序)
--host-only-nic-type='virtio' - 网卡类型仅用于主机网络。Am79C970A, Am79C973, 82540EM, 82543GC, 82545EM 之一,或 virtio(仅限 VirtualBox 驱动程序)
--hyperkit-vpnkit-sock='' - 用于网络连接的 VPNKit 套接字的位置。如果为空,则停用 Hyperkit 。VPNKitSock;如果为“auto”,则将 Docker 用于 Mac VPNKit 连接;否则使用指定的 VSock(仅限 hyperkit 驱动程序)
--hyperkit-vsock-ports=[] - 应在主机上公开为套接字的访客 VSock 端口列表(仅限 hyperkit 驱动程序)
--hyperv-external-adapter='' - External Adapter on which external switch will be created if no external switch is found. (hyperv driver only)
--hyperv-use-external-switch=false - 如果没有明确指定虚拟交换机,是否使用外部交换机覆盖默认的交换机。(仅 hyperv 可用)
--hyperv-virtual-switch='' - hyperv 虚拟交换机名称。默认为找到的第一个 hyperv 虚拟交换机。(仅限 hyperv 驱动程序)
--image-mirror-country='' - 需要使用的镜像镜像的国家/地区代码。留空以使用全球代码。对于中国大陆用户,请将其设置为 cn。
--image-repository='' - 可从其中拉取 docker 镜像的替代镜像库。当您对 gcr.io 的访问权限有限时,可以使用此选项。设置为“auto”,让minikube为你决定一个。对于中国大陆用户,您可以使用本地 gcr.io 同步仓库,如 registry.cn-hangzhou.aliyuncs.com/google_containers
--insecure-registry=[] - 给 docker 配置不安全的 Docker 镜像仓库。默认的 service CIDR 地址段将会被自动添加进去。
--install-addons=true true 如果设置,会自动安装一些 addons 插件。默认为 true
--interactive=true - 允许用户提示以获取更多信息
--iso-url=[] - 配置 minikube ISO 镜像下载地址
--keep-context=false - 这将保留现有 kubectl 上下文并创建 minikube 上下文。
--kubernetes-version='' stable minikube VM 使用的 Kubernetes 的版本 (如: v1.2.3, 'stable' for v1.22.3,'latest' for v1.22.4-rc.0). 默认 'stable'.
--kvm-gpu=false - 在 minikube 中启用实验性 NVIDIA GPU 支持
--kvm-hidden=false - 向 minikube 中的访客隐藏管理程序签名(仅限 kvm2 驱动程序)
--kvm-network='default' - KVM 默认的网络名称(仅限 kvm2 驱动)
--kvm-numa-count=1 - 在minikube中模拟numa节点数,支持numa节点数范围为1-8 (仅限 kvm2 驱动)
--kvm-qemu-uri='qemu:///system' - KVM QEMU 连接 URI。(仅限 kvm2 驱动程序)
--listen-address='' - 监听的 IP 地址,用来暴露端口 (仅限 docker 和 podman 驱动)
--memory='' - 分配给 Kubernetes 的内存大小 (格式: [], where unit = b, k, m or g)。使用 "max" 时会主机所有内存。
--mount=false - 这将启动挂载守护进程,并自动将文件挂载到minikube中。
--mount-string='/root:/minikube-host' - The argument to pass the minikube mount command on start.
--namespace='default' - The named space to activate after start
--nat-nic-type='virtio' - 网络 NAT 转换使用的网卡 NCI 类型,可选 Am79C970A, Am79C973, 82540EM, 82543GC, 82545EM, or virtio (仅限 virtualbox 驱动)
--native-ssh=true true 使用原生的 Golang SSH 客户端(默认为 true)。设置为'false'来使用命令行'ssh'命令访问docker机器。Useful for the machine drivers when they will not start with 'Waiting for SSH'
--network='' - network to run minikube with. Now it is used by docker/podman and KVM drivers. If left empty, minikube will create a new network.
--network-plugin='' - kubelet 的网络插件 (default: auto)
--nfs-share=[] - 通过 NFS 装载与访客共享的本地文件夹(仅限 hyperkit 驱动程序)
--nfs-shares-root='/nfsshares' - NFS 共享的根目录位置,默认为 /nfsshares(仅限 hyperkit 驱动程序)
--no-kubernetes=false - If set, minikube VM/container will start without starting or configuring Kubernetes. (only works on new clusters)
--no-vtx-check=false - 禁用在启动虚拟机之前检查硬件虚拟化的可用性(仅限 virtualbox 驱动程序)
-n, --nodes=1 1 初始化 nodes 节点数量,默认 1
-o, --output='text' - stdout 输出内容的格式,可配置 [text,json]
--ports=[] - 列举出需要暴露的端口列表 (仅限 docker and podman 驱动)
--preload=true - If set, download tarball of preloaded images if available to improve start time. Defaults to true.
--registry-mirror=[] - 传递给 Docker 守护进程的注册表镜像
--service-cluster-ip-range='10.96.0.0/12' - 需要用于服务集群 IP 的 CIDR。
--ssh-ip-address='' - IP address (仅限 ssh 驱动使用)
--ssh-key='' - SSH key (仅限ssh 驱动使用)
--ssh-port=22 - SSH 端口 (仅限 ssh 驱动使用)
--ssh-user='root' - SSH user (仅限 ssh 驱动使用)
--trace='' - Send trace events. Options include: [gcp]
--uuid='' - 提供虚拟机 UUID 以恢复 MAC 地址(仅限 hyperkit 驱动程序)
--vm=false - Filter to use only VM Drivers
--vm-driver='' - 废弃,使用 driver 代替.
--wait=[apiserver,system_pods] - comma separated list of Kubernetes components to verify and wait for after starting a cluster. defaults to "apiserver,system_pods", available options: "apiserver,system_pods,default_sa,apps_running,node_ready,kubelet" . other acceptable values are 'all' or 'none', 'true' and 'false'
--wait-timeout=6m0s - max time to wait per Kubernetes or host to be healthy.

1.3. 扩展说明

1.3.1. minikube 驱动支持 --driver

minikube 支持以下几种驱动:

--driver=''| auto-detect | 设置驱动,可选列表: virtualbox, vmwarefusion, kvm2, vmware, none, docker, podman, ssh (defaults toauto-detect)
  • virtualbox
  • vmwarefusion
  • kvm2: 使用 kvm2 虚拟化作为集群的运行的驱动,该驱动会自动创建一个虚拟机(可通过 virsh list 查看)作为 master 节点。也可以自动添加 node 节点
  • vmware
  • none : 可在在虚拟机中使用,直接使用宿主机的 docker 运行环境。
  • docker
  • podman
  • ssh
  • (defaults to auto-detect)

1.3.2. 指定镜像仓库 --image-repository=''

--image-repository='' 提供 minikube 安装和运行过程中的镜像下载的远程仓库服务。可从其中拉取 docker 镜像的替代 gcr.io 镜像库。

当您对 gcr.io 的访问权限有限时,可以使用此选项。

设置为“auto”,让 minikube 为你决定一个。

对于中国大陆用户,您可以使用本地 gcr.io 同步仓库,如 'registry.cn-hangzhou.aliyuncs.com/google_containers'

1.4. 示例

1.4.1. 启动一个默认的 minikube 集群

sudo minikube start
Copyright © 温玉 2021 | 浙ICP备2020032454号 all right reserved,powered by Gitbook该文件修订时间: 2022-06-09 23:55:09

results matching ""

    No results matching ""