k0sproject / k0s

k0s - The Zero Friction Kubernetes
https://docs.k0sproject.io
Other
3.48k stars 353 forks source link

Get error "Error: error detecting local IP: lookup localhost: Try again" on initialization of the cluster via k0sctl #2151

Closed fanningert closed 2 years ago

fanningert commented 2 years ago

Before creating an issue, make sure you've checked the following:

Platform

Linux 5.19.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 05 Sep 2022 18:09:09 +0000 x86_64 GNU/Linux
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"
LOGO=archlinux-logo

Version

1.24.4+k0s.0

Sysinfo

`k0s sysinfo` Machine ID: "25446bb7edce2de7c527663f4f600126356f9923264579b92bc0d2f747a6101c" (from machine) (pass) Total memory: 31.1 GiB (pass) Disk space available for /var/lib/k0s: 867.1 GiB (pass) Operating system: Linux (pass) Linux kernel release: 5.19.7-arch1-1 (pass) Max. file descriptors per process: current: 1024 / max: 524288 (warning: < 65536) Executable in path: modprobe: /usr/bin/modprobe (pass) /proc file system: mounted (0x9fa0) (pass) Control Groups: version 2 (pass) cgroup controller "cpu": available (pass) cgroup controller "cpuacct": available (via cpu in version 2) (pass) cgroup controller "cpuset": available (pass) cgroup controller "memory": available (pass) cgroup controller "devices": available (assumed) (pass) cgroup controller "freezer": available (assumed) (pass) cgroup controller "pids": available (pass) cgroup controller "hugetlb": available (pass) cgroup controller "blkio": available (via io in version 2) (pass) CONFIG_CGROUPS: Control Group support: built-in (pass) CONFIG_CGROUP_FREEZER: Freezer cgroup subsystem: built-in (pass) CONFIG_CGROUP_PIDS: PIDs cgroup subsystem: built-in (pass) CONFIG_CGROUP_DEVICE: Device controller for cgroups: built-in (pass) CONFIG_CPUSETS: Cpuset support: built-in (pass) CONFIG_CGROUP_CPUACCT: Simple CPU accounting cgroup subsystem: built-in (pass) CONFIG_MEMCG: Memory Resource Controller for Control Groups: built-in (pass) CONFIG_CGROUP_HUGETLB: HugeTLB Resource Controller for Control Groups: built-in (pass) CONFIG_CGROUP_SCHED: Group CPU scheduler: built-in (pass) CONFIG_FAIR_GROUP_SCHED: Group scheduling for SCHED_OTHER: built-in (pass) CONFIG_CFS_BANDWIDTH: CPU bandwidth provisioning for FAIR_GROUP_SCHED: built-in (pass) CONFIG_BLK_CGROUP: Block IO controller: built-in (pass) CONFIG_NAMESPACES: Namespaces support: built-in (pass) CONFIG_UTS_NS: UTS namespace: built-in (pass) CONFIG_IPC_NS: IPC namespace: built-in (pass) CONFIG_PID_NS: PID namespace: built-in (pass) CONFIG_NET_NS: Network namespace: built-in (pass) CONFIG_NET: Networking support: built-in (pass) CONFIG_INET: TCP/IP networking: built-in (pass) CONFIG_IPV6: The IPv6 protocol: built-in (pass) CONFIG_NETFILTER: Network packet filtering framework (Netfilter): built-in (pass) CONFIG_NETFILTER_ADVANCED: Advanced netfilter configuration: built-in (pass) CONFIG_NETFILTER_XTABLES: Netfilter Xtables support: module (pass) CONFIG_NETFILTER_XT_TARGET_REDIRECT: REDIRECT target support: module (pass) CONFIG_NETFILTER_XT_MATCH_COMMENT: "comment" match support: module (pass) CONFIG_NETFILTER_XT_MARK: nfmark target and match support: module (pass) CONFIG_NETFILTER_XT_SET: set target and match support: module (pass) CONFIG_NETFILTER_XT_TARGET_MASQUERADE: MASQUERADE target support: module (pass) CONFIG_NETFILTER_XT_NAT: "SNAT and DNAT" targets support: module (pass) CONFIG_NETFILTER_XT_MATCH_ADDRTYPE: "addrtype" address type match support: module (pass) CONFIG_NETFILTER_XT_MATCH_CONNTRACK: "conntrack" connection tracking match support: module (pass) CONFIG_NETFILTER_XT_MATCH_MULTIPORT: "multiport" Multiple port match support: module (pass) CONFIG_NETFILTER_XT_MATCH_RECENT: "recent" match support: module (pass) CONFIG_NETFILTER_XT_MATCH_STATISTIC: "statistic" match support: module (pass) CONFIG_NETFILTER_NETLINK: module (pass) CONFIG_NF_CONNTRACK: Netfilter connection tracking support: module (pass) CONFIG_NF_NAT: module (pass) CONFIG_IP_SET: IP set support: module (pass) CONFIG_IP_SET_HASH_IP: hash:ip set support: module (pass) CONFIG_IP_SET_HASH_NET: hash:net set support: module (pass) CONFIG_IP_VS: IP virtual server support: module (pass) CONFIG_IP_VS_NFCT: Netfilter connection tracking: built-in (pass) CONFIG_NF_CONNTRACK_IPV4: IPv4 connetion tracking support (required for NAT): unknown (warning) CONFIG_NF_REJECT_IPV4: IPv4 packet rejection: module (pass) CONFIG_NF_NAT_IPV4: IPv4 NAT: unknown (warning) CONFIG_IP_NF_IPTABLES: IP tables support: module (pass) CONFIG_IP_NF_FILTER: Packet filtering: module (pass) CONFIG_IP_NF_TARGET_REJECT: REJECT target support: module (pass) CONFIG_IP_NF_NAT: iptables NAT support: module (pass) CONFIG_IP_NF_MANGLE: Packet mangling: module (pass) CONFIG_NF_DEFRAG_IPV4: module (pass) CONFIG_NF_CONNTRACK_IPV6: IPv6 connetion tracking support (required for NAT): unknown (warning) CONFIG_NF_NAT_IPV6: IPv6 NAT: unknown (warning) CONFIG_IP6_NF_IPTABLES: IP6 tables support: module (pass) CONFIG_IP6_NF_FILTER: Packet filtering: module (pass) CONFIG_IP6_NF_MANGLE: Packet mangling: module (pass) CONFIG_IP6_NF_NAT: ip6tables NAT support: module (pass) CONFIG_NF_DEFRAG_IPV6: module (pass) CONFIG_BRIDGE: 802.1d Ethernet Bridging: module (pass) CONFIG_LLC: module (pass) CONFIG_STP: module (pass) CONFIG_EXT4_FS: The Extended 4 (ext4) filesystem: module (pass) CONFIG_PROC_FS: /proc file system support: built-in (pass)

What happened?

On creation of the cluster, I get the error Error: error detecting local IP: lookup localhost: Try again. I already disabled the network-resolved stub. So in the /etc/resolv.conf is the correct nameserver.

nameserver 192.168.1.1
search .

Steps to reproduce

  1. Create a k0sctl.yaml
    apiVersion: k0sctl.k0sproject.io/v1beta1
    kind: Cluster
    metadata:
    name: home-k0s-cluster
    spec:
    hosts:
    - ssh:
      address: 192.168.1.190
      user: root
      port: 22
      keyPath: ~/.ssh/id_rsa
    role: controller+worker
    - ssh:
      address: 192.168.1.191
      user: root
      port: 22
      keyPath: ~/.ssh/id_rsa
    role: controller+worker
    k0s:
    version: 1.24.4+k0s.0
    dynamicConfig: false
  2. Run k0sctl apply --config k0sctl.yaml

Expected behavior

No response

Actual behavior

No response

Screenshots and logs

k0sctl log

k0sctl v0.13.2 Copyright 2021, k0sctl authors.
Anonymized telemetry of usage will be sent to the authors.
By continuing to use k0sctl you agree to these terms:
https://k0sproject.io/licenses/eula
WARN An old cache directory still exists at /home/xxxxxx/.k0sctl/cache, k0sctl now uses /home/xxxxxx/.cache/k0sctl 
INFO ==> Running phase: Connect to hosts 
INFO [ssh] 192.168.1.190:22: connected            
INFO [ssh] 192.168.1.191:22: connected            
INFO ==> Running phase: Detect host operating systems 
INFO [ssh] 192.168.1.190:22: is running Arch Linux 
INFO [ssh] 192.168.1.191:22: is running Arch Linux 
INFO ==> Running phase: Acquire exclusive host lock 
INFO ==> Running phase: Prepare hosts    
INFO ==> Running phase: Gather host facts 
INFO [ssh] 192.168.1.190:22: using cluster01 as hostname 
INFO [ssh] 192.168.1.190:22: discovered eno1 as private interface 
INFO [ssh] 192.168.1.191:22: using cluster02 as hostname 
INFO [ssh] 192.168.1.191:22: discovered eno1 as private interface 
INFO ==> Running phase: Validate hosts   
INFO ==> Running phase: Gather k0s facts 
INFO ==> Running phase: Validate facts   
INFO ==> Running phase: Configure k0s    
INFO [ssh] 192.168.1.191:22: validating configuration 
INFO [ssh] 192.168.1.190:22: validating configuration 
INFO [ssh] 192.168.1.191:22: configuration was changed 
INFO [ssh] 192.168.1.190:22: configuration was changed 
INFO ==> Running phase: Initialize the k0s cluster 
INFO [ssh] 192.168.1.190:22: installing k0s controller 
INFO [ssh] 192.168.1.190:22: waiting for the k0s service to start 
INFO * Running clean-up for phase: Initialize the k0s cluster 
ERRO apply failed - log file saved to /home/xxxxxx/.cache/k0sctl/k0sctl.log 
FATA not running 

Logs from the first server journalctl -f -u k0scontroller.service

Sep 10 21:46:16 cluster01 systemd[1]: Started k0s - Zero Friction Kubernetes.
Sep 10 21:46:16 cluster01 k0s[739]: time="2022-09-10 21:46:16" level=info msg="using api address: 192.168.1.190"
Sep 10 21:46:16 cluster01 k0s[739]: time="2022-09-10 21:46:16" level=info msg="using listen port: 6443"
Sep 10 21:46:16 cluster01 k0s[739]: time="2022-09-10 21:46:16" level=info msg="using sans: [192.168.1.190 fe80::8aae:ddff:fe09:558c 192.168.1.191 127.0.0.1]"
Sep 10 21:46:16 cluster01 k0s[739]: time="2022-09-10 21:46:16" level=info msg="DNS address: 10.96.0.10"
Sep 10 21:46:16 cluster01 k0s[739]: time="2022-09-10 21:46:16" level=info msg="using storage backend etcd"
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] generate received request
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] received CSR
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] generating key: rsa-2048
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] encoded CSR
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] signed certificate with serial number 10788042844541733629335556867900524330636297071
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] generate received request
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] received CSR
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] generate received request
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] received CSR
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] generating key: rsa-2048
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] generate received request
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] received CSR
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] generating key: rsa-2048
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] generating key: rsa-2048
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] generate received request
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] generate received request
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] received CSR
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] generating key: rsa-2048
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] generate received request
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] received CSR
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] generating key: rsa-2048
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] received CSR
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] generating key: rsa-2048
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] encoded CSR
Sep 10 21:46:16 cluster01 k0s[739]: 2022/09/10 21:46:16 [INFO] signed certificate with serial number 72922180210829093437401942735740181549xxxxxxxxxx
Sep 10 21:46:17 cluster01 k0s[739]: 2022/09/10 21:46:17 [INFO] encoded CSR
Sep 10 21:46:17 cluster01 k0s[739]: 2022/09/10 21:46:17 [INFO] signed certificate with serial number 12941938567193212506627756741225754022xxxxxxxxxx
Sep 10 21:46:17 cluster01 k0s[739]: 2022/09/10 21:46:17 [INFO] generate received request
Sep 10 21:46:17 cluster01 k0s[739]: 2022/09/10 21:46:17 [INFO] received CSR
Sep 10 21:46:17 cluster01 k0s[739]: 2022/09/10 21:46:17 [INFO] generating key: rsa-2048
Sep 10 21:46:17 cluster01 k0s[739]: 2022/09/10 21:46:17 [INFO] encoded CSR
Sep 10 21:46:17 cluster01 k0s[739]: 2022/09/10 21:46:17 [INFO] signed certificate with serial number 30192918713628505809015897773823810020xxxxxxxxxx
Sep 10 21:46:17 cluster01 k0s[739]: 2022/09/10 21:46:17 [INFO] encoded CSR
Sep 10 21:46:17 cluster01 k0s[739]: 2022/09/10 21:46:17 [INFO] signed certificate with serial number 19611435771853783433309307797423691100xxxxxxxxxx
Sep 10 21:46:17 cluster01 k0s[739]: 2022/09/10 21:46:17 [INFO] encoded CSR
Sep 10 21:46:17 cluster01 k0s[739]: 2022/09/10 21:46:17 [INFO] signed certificate with serial number 22676471919981251697503246490712127172xxxxxxxxxx
Sep 10 21:46:17 cluster01 k0s[739]: 2022/09/10 21:46:17 [INFO] encoded CSR
Sep 10 21:46:17 cluster01 k0s[739]: 2022/09/10 21:46:17 [INFO] signed certificate with serial number 45775992925326842631857692208207364058xxxxxxxxxx
Sep 10 21:46:17 cluster01 k0s[739]: 2022/09/10 21:46:17 [INFO] encoded CSR
Sep 10 21:46:17 cluster01 k0s[739]: 2022/09/10 21:46:17 [INFO] signed certificate with serial number 19214466264699992494588158198677986526xxxxxxxxxx
Sep 10 21:46:21 cluster01 k0s[739]: Error: error detecting local IP: lookup localhost: Try again
Sep 10 21:46:21 cluster01 systemd[1]: k0scontroller.service: Main process exited, code=exited, status=1/FAILURE
Sep 10 21:46:21 cluster01 systemd[1]: k0scontroller.service: Failed with result 'exit-code'.
Sep 10 21:46:21 cluster01 systemd[1]: k0scontroller.service: Consumed 4.156s CPU time.

Additional context

No response

fanningert commented 2 years ago

Looks like is a problem of systemd-networkd when polkit is not installed. Then the /etc/hosts is not filled with the hostname.

https://github.com/systemd/systemd/issues/13501

Reference to similar issue: 1873

Analyse: networkctl status

State: routable                         
  Online state: online                           
       Address: 192.168.1.190 on eno1
                fe80::8aae:ddff:fe09:558c on eno1
       Gateway: 192.168.1.1 on eno1
           DNS: 192.168.1.1

Sep 11 07:56:03 cluster01 systemd[1]: Started Network Configuration.
Sep 11 07:56:04 cluster01 systemd-networkd[236]: eth0: Interface name change detected, renamed to eno1.
Sep 11 07:56:04 cluster01 systemd-networkd[236]: eno1: Configuring with /etc/systemd/network/20-wired-eno1.network.
Sep 11 07:56:04 cluster01 systemd-networkd[236]: eno1: Link UP
Sep 11 07:56:08 cluster01 systemd-networkd[236]: eno1: Gained carrier
Sep 11 07:56:09 cluster01 systemd-networkd[236]: eno1: Gained IPv6LL
Sep 11 07:56:12 cluster01 systemd-networkd[236]: eno1: DHCPv4 address 192.168.1.190/24, gateway 192.168.1.1 acquired from 192.168.1.1
Sep 11 07:56:12 cluster01 systemd-networkd[236]: Could not set hostname: Access denied
Sep 11 07:58:12 cluster01 systemd[1]: Starting Wait for Network to be Configured...
Sep 11 07:58:12 cluster01 systemd[1]: Finished Wait for Network to be Configured.

After installation polkit the error with " Could not set hostname: Access denied" is gone.

I also edit manuell the /etc/hosts.

Know it is working.