Kubernetes minikube 启动失败,错误:来自 127.0.0.1 的无效用户 docker

Kubernetes minikube 启动失败,错误:来自 127.0.0.1 的无效用户 docker

我的服务器是 Fedora 27,强制使用 SELinux。我正在设置 Kubernetes。我的设置很早就失败了,因为我甚至无法创建集群。以下是我收到的错误:

% minikube start --vm-driver kvm2 --logtostderr --v=10 
I0214 12:44:01.346196   10856 notify.go:109] Checking for updates...
I0214 12:44:01.768416   10856 start.go:96] Viper configuration:
Aliases:
map[string]string{}
Override:
map[string]interface {}{"v":"10"}
PFlags:
.........
Env:
map[string]string{}
Key/Value Store:
map[string]interface {}{}
Config:
..............
Defaults:
map[string]interface {}{"wantreporterror":false, "wantreporterrorprompt":true, "showdriverdeprecationnotification":true, "alsologtostderr":"false", "log_dir":"", "wantupdatenotification":true, "reminderwaitperiodinhours":24, "wantkubectldownloadmsg":true, "wantnonedriverwarning":true, "v":"0"}
Starting local Kubernetes v1.9.0 cluster...
Starting VM...
I0214 12:44:01.769248   10856 cluster.go:74] Skipping create...Using existing machine configuration
........
Found binary path at /usr/bin/docker-machine-driver-kvm2
Launching plugin server for driver kvm2
Plugin server listening at address 127.0.0.1:44533
() Calling .GetVersion
Using API Version  1
() Calling .SetConfigRaw
() Calling .GetMachineName
(minikube) Calling .GetState
I0214 12:44:01.916793   10856 cluster.go:83] Machine state:  Running
(minikube) Calling .DriverName
Waiting for SSH to be available...
Getting to WaitForSSH function...
(minikube) Calling .GetSSHHostname
(minikube) Calling .GetSSHPort
(minikube) Calling .GetSSHKeyPath
(minikube) Calling .GetSSHKeyPath
(minikube) Calling .GetSSHUsername
Using SSH client type: native
&{{{<nil> 0 [] [] []} docker [0x834be0] 0x834b90  [] 0s}  42660 <nil> <nil>}
About to run SSH command:
exit 0
Error dialing TCP: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
Error dialing TCP: ssh: handshake failed: ssh: unable to authenticate, attempted methods [publickey none], no supported methods remain

这里我需要输入来获取提示。当列出包含 minikube 的正在运行的进程时,我发现了这一点:

188:qemu     10734     1  9 12:43 ?        00:00:37 /usr/bin/qemu-system-x86_64 -machine accel=kvm -name guest=minikube,debug-threads=on -S -object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-4-minikube/master-key.aes -machine pc-i440fx-2.10,accel=kvm,usb=off,dump-guest-core=off -m 1954 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid fef86dfc-66d5-4033-87a2-106f6b470737 -display none -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-4-minikube/monitor.sock,server,nowait -mon` chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot menu=off,strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device lsi,id=scsi0,bus=pci.0,addr=0x4 -drive file=/home/gabx/.minikube/machines/minikube/boot2docker.iso,format=raw,if=none,id=drive-scsi0-0-2,readonly=on -device scsi-cd,bus=scsi0.0,scsi-id=2,drive=drive-scsi0-0-2,id=scsi0-0-2,bootindex=1 -drive file=/home/gabx/.minikube/machines/minikube/minikube.rawdisk,format=raw,if=none,id=drive-virtio-disk0,aio=threads -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=2 -netdev tap,fd=25,id=hostnet0,vhost=on,vhostfd=27 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=a4:d6:75:fd:a0:af,bus=pci.0,addr=0x2 -netdev tap,fd=28,id=hostnet1,vhost=on,vhostfd=29 -device virtio-net-pci,netdev=hostnet1,id=net1,mac=a4:d6:75:fd:a0:af,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 -object rng-random,id=objrng0,filename=/dev/random -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0x7 -msg timestamp=on

因此 qemu 用户已经启动了一个进程,但我不知道这是否是应该的方式。

一些调试帮助:

$ journalctl -u sshd.service
Invalid user docker from 127.0.0.1 port 34998

$ journalctl -u libvirtd.service
Starting Virtualization daemon...
Feb 14 12:29:12 dahlia systemd[1]: Started Virtualization daemon.
Feb 14 12:29:13 dahlia dnsmasq[16256]: read /etc/hosts - 3 addresses
Feb 14 12:29:13 dahlia dnsmasq[16256]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Feb 14 12:29:13 dahlia dnsmasq-dhcp[16256]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Feb 14 12:29:13 dahlia dnsmasq[9727]: started, version 2.78 cachesize 150
Feb 14 12:29:13 dahlia dnsmasq[9727]: compile time options: IPv6 GNU-getopt DBus no-i18n IDN2 DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth DNSSEC loop-detect inotify
Feb 14 12:29:13 dahlia dnsmasq[9727]: warning: no upstream servers configured
Feb 14 12:29:13 dahlia dnsmasq-dhcp[9727]: DHCP, IP range 192.168.39.2 -- 192.168.39.254, lease time 1h
Feb 14 12:29:13 dahlia dnsmasq-dhcp[9727]: DHCP, sockets bound exclusively to interface virbr0
Feb 14 12:29:13 dahlia dnsmasq[9727]: read /etc/hosts - 3 addresses
Feb 14 12:29:13 dahlia dnsmasq[9727]: read /var/lib/libvirt/dnsmasq/minikube-net.addnhosts - 0 addresses
Feb 14 12:29:13 dahlia dnsmasq-dhcp[9727]: read /var/lib/libvirt/dnsmasq/minikube-net.hostsfile
Feb 14 12:31:48 dahlia libvirtd[9650]: 2018-02-14 12:31:48.661+0000: 9650: info : libvirt version: 3.7.0, package: 3.fc27 (Fedora Project, 2017-12-04-17:14:09, buildhw-06.phx2.fedoraproj
Feb 14 12:31:48 dahlia libvirtd[9650]: 2018-02-14 12:31:48.661+0000: 9650: info : hostname: dahlia.thetradinghall.com
Feb 14 12:31:48 dahlia libvirtd[9650]: 2018-02-14 12:31:48.661+0000: 9650: error : virNetSocketReadWire:1808 : End of file while reading data: Input/output error

每次启动 minikube 时都会打印最后一行。

笔记

  1. sshd 在自定义端口上运行,用户登录时无需密码,但需要密钥,sshd 配置有以下行:

    允许用户 用户1 用户2

  2. Iptables 处于活动状态,其中包括:

    链转发(策略丢弃)

  3. 两个 dnsmasq 进程正在运行,一个由 root 拥有,另一个由 nobody 拥有

    154:nobody 1681 1 0 Feb13 ? 00:00:01 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/minikube-net.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper

  4. 没有码头工人我的机器上的用户或组

  5. 运行 kubectl 打印错误:

    % kubectl version

    Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.1", GitCommit:"3a1c9449a956b6026f075fa3134ff92f7d55f812", GitTreeState:"archive", BuildDate:"2018-01-15T15:56:33Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
    The connection to the server localhost:8080 was refused - did you specify the right host or port?

    % kubectl cluster-info

    Kubernetes master is running at http://localhost:8080 To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. The connection to the server localhost:8080 was refused - did you specify the right host or port

感谢您提供任何帮助和提示,关于 minikube 命令应该如何运行以及为什么这个 docker 用户无法连接?这可能是我遇到问题的根源吗?为什么会出现此消息连接到服务器 localhost:8080 被拒绝运行 kubectl 时?

答案1

rm -rf ~/.minikube

然后再试一次。

我已经放弃了 fedora 27 上的 kvm2 并且重新使用 VirtualBox 来使用 vm-driver。

关于你的其他问题-

  • qemu 是一个虚拟机应用程序。它负责为 minikube 运行 kubernetes 部分,并支持 kvm2 vm-driver。
  • 您的机器上不需要有 docker 用户。docker 用户存在于 qemu 机器上。
  • minikube ssh 的缩写是

    ssh -i ~/.minikube/machines/minikube/id_rsa docker@

此故障本质上意味着 qemu 虚拟机内的 ssh 密钥与您机器上该虚拟机的密钥不同。换句话说,一切都已解决,您应该重新开始。

相关内容