kubernetes 无法在Mac M1上使用Docker启动minikube

xzv2uavs  于 2022-11-21  发布在  Kubernetes
关注(0)|答案(4)|浏览(482)

我 试图 在 Mac M1 ( macOs Monterey V12.0.1 ) 上 启动 minikube , 在 安装 了 带有 自制 软件 的 minikube ( brew install minikube ) 后 , 但 在 运行 minikube start 后 出现 错误 。
日志 中 的 错误 如下 :

💢  initialization failed, will try again: wait: /bin/bash -c "sudo env PATH="/var/lib/minikube/binaries/v1.22.3:$PATH" kubeadm init --config /var/tmp/minikube/kubeadm.yaml  --ignore-preflight-errors=DirAvailable--etc-kubernetes-manifests,DirAvailable--var-lib-minikube,DirAvailable--var-lib-minikube-etcd,FileAvailable--etc-kubernetes-manifests-kube-scheduler.yaml,FileAvailable--etc-kubernetes-manifests-kube-apiserver.yaml,FileAvailable--etc-kubernetes-manifests-kube-controller-manager.yaml,FileAvailable--etc-kubernetes-manifests-etcd.yaml,Port-10250,Swap,Mem,SystemVerification,FileContent--proc-sys-net-bridge-bridge-nf-call-iptables": Process exited with status 1
stdout:
[init] Using Kubernetes version: v1.22.3
[preflight] Running pre-flight checks

stderr:
    [WARNING Swap]: running with swap on is not supported. Please disable swap
    [WARNING Service-Kubelet]: kubelet service is not enabled, please run 'systemctl enable kubelet.service'
error execution phase preflight: [preflight] Some fatal errors occurred:
    [ERROR KubeletVersion]: couldn't get kubelet version: cannot execute 'kubelet --version': exit status 255
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

💣  Error starting cluster: wait: /bin/bash -c "sudo env PATH="/var/lib/minikube/binaries/v1.22.3:$PATH" kubeadm init --config /var/tmp/minikube/kubeadm.yaml  --ignore-preflight-errors=DirAvailable--etc-kubernetes-manifests,DirAvailable--var-lib-minikube,DirAvailable--var-lib-minikube-etcd,FileAvailable--etc-kubernetes-manifests-kube-scheduler.yaml,FileAvailable--etc-kubernetes-manifests-kube-apiserver.yaml,FileAvailable--etc-kubernetes-manifests-kube-controller-manager.yaml,FileAvailable--etc-kubernetes-manifests-etcd.yaml,Port-10250,Swap,Mem,SystemVerification,FileContent--proc-sys-net-bridge-bridge-nf-call-iptables": Process exited with status 1
stdout:
[init] Using Kubernetes version: v1.22.3
[preflight] Running pre-flight checks

stderr:
    [WARNING Swap]: running with swap on is not supported. Please disable swap
    [WARNING Service-Kubelet]: kubelet service is not enabled, please run 'systemctl enable kubelet.service'
error execution phase preflight: [preflight] Some fatal errors occurred:
    [ERROR KubeletVersion]: couldn't get kubelet version: cannot execute 'kubelet --version': exit status 255
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

╭───────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                           │
│    😿  If the above advice does not help, please let us know:                             │
│    👉  https://github.com/kubernetes/minikube/issues/new/choose                           │
│                                                                                           │
│    Please run `minikube logs --file=logs.txt` and attach logs.txt to the GitHub issue.    │
│                                                                                           │
╰───────────────────────────────────────────────────────────────────────────────────────────╯

❌  Exiting due to GUEST_START: wait: /bin/bash -c "sudo env PATH="/var/lib/minikube/binaries/v1.22.3:$PATH" kubeadm init --config /var/tmp/minikube/kubeadm.yaml  --ignore-preflight-errors=DirAvailable--etc-kubernetes-manifests,DirAvailable--var-lib-minikube,DirAvailable--var-lib-minikube-etcd,FileAvailable--etc-kubernetes-manifests-kube-scheduler.yaml,FileAvailable--etc-kubernetes-manifests-kube-apiserver.yaml,FileAvailable--etc-kubernetes-manifests-kube-controller-manager.yaml,FileAvailable--etc-kubernetes-manifests-etcd.yaml,Port-10250,Swap,Mem,SystemVerification,FileContent--proc-sys-net-bridge-bridge-nf-call-iptables": Process exited with status 1
stdout:
[init] Using Kubernetes version: v1.22.3
[preflight] Running pre-flight checks

stderr:
    [WARNING Swap]: running with swap on is not supported. Please disable swap
    [WARNING Service-Kubelet]: kubelet service is not enabled, please run 'systemctl enable kubelet.service'
error execution phase preflight: [preflight] Some fatal errors occurred:
    [ERROR KubeletVersion]: couldn't get kubelet version: cannot execute 'kubelet --version': exit status 255
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

╭───────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                           │
│    😿  If the above advice does not help, please let us know:                             │
│    👉  https://github.com/kubernetes/minikube/issues/new/choose                           │
│                                                                                           │
│    Please run `minikube logs --file=logs.txt` and attach logs.txt to the GitHub issue.    │
│                                                                                           │
╰───────────────────────────────────────────────────────────────────────────────────────────╯

中 的 每 一 个
我 试 过 通过 运行 sysctl enable kubelet.service 来 启用 kubelet.service , 但 没有 任何 改变 。 我 还 安装 了 kubeclt 版本 1.22

ffdz8vbo

ffdz8vbo1#

我 能够 找到 我 的 问题 的 解决 方案 , 虽然 , 我 不 太 确定 主要 问题 是 什么 , 它 似乎 与 用户 主 目录 下 .minikube 文件 夹 中 的 旧 配置 有关 。
为了 修复 它 , 首先 我 必须 在 Docker 桌面 中 启用 Kubernetes , 然后 我 必须 停止 并 删除 minikube 集群 , 最 后 删除 目录 。 然后 再次 运行 命令 是 成功 的 。
要 修复 :

$ minikube stop
$ minikube delete
$ rm -rf ~/.minikube/
$ minikube start

😄  minikube v1.24.0 on Darwin 12.0.1 (arm64)
✨  Automatically selected the docker driver
👍  Starting control plane node minikube in cluster minikube
🚜  Pulling base image ...
🔥  Creating docker container (CPUs=2, Memory=1988MB) ...
    > kubectl.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubelet.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubeadm.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubeadm: 40.50 MiB / 40.50 MiB [-------------] 100.00% 29.75 MiB p/s 1.6s
    > kubectl: 41.44 MiB / 41.44 MiB [-------------] 100.00% 21.39 MiB p/s 2.1s
    > kubelet: 107.26 MiB / 107.26 MiB [-----------] 100.00% 27.70 MiB p/s 4.1s

    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

中 的 每 一 个

wmtdaxz3

wmtdaxz32#

首先,Mac机器默认启用交换。您必须禁用交换,然后重试启动minikube
在MacBook中禁用交换的步骤:

*1.禁用SIP:

  • 先关闭MacBook电源,
  • 按住Command()和R键,然后启动MacBook。(对于基于M1芯片的MacBook,按住电源按钮,直到看到“正在加载启动选项”)
  • 从实用程序菜单中选择“终端”,然后运行csrutil disable,屏幕应显示SIP已禁用的消息。x1c 0d1x
  • 从菜单中,按restart重新启动MacBook。
    *2.禁用交换
  • 打开macbook终端
  • 检查系统管理内存的当前模式,在终端中键入sysctl -a vm.compressor_mode
  • 默认模式是4,表示压缩内存并使用交换。要禁用交换,我们应该将模式从4更改为2,表示仅压缩内存。
  • modify vm.compressor_mode,键入sudo nvram boot-args="vm_compressor=2"。在重新启动之前不会更改模式。-reboot

再次,任何人运行计算机没有交换文件应密切监视内存使用,以避免内核恐慌!

*3. Minikube启动:

$ minikube stop
$ minikube delete
$ rm -rf ~/.minikube/
$ minikube start
b5buobof

b5buobof3#

对于遇到此问题的任何人:
1.确保使用minikube的arm64二进制文件
1.运行minikube delete --all --purge
1.尝试再次启动minikube

a11xaf1n

a11xaf1n4#

这对我在mac m1上起作用了-
$ minikube delete --all
$ rm -rf ~/.minikube
$ minikube start --force-systemd=true
参考-https://minikube.sigs.k8s.io/docs/faq/#docker-driver-how-can-i-set-minikubes-cgroup-manager

相关问题