PyratLabs / ansible-role-k3s

Ansible role for installing k3s as either a standalone server or HA cluster.
BSD 3-Clause "New" or "Revised" License
640 stars 135 forks source link

advertise-address ist hostname, no IP as it should be #128

Closed tuxpeople closed 3 years ago

tuxpeople commented 3 years ago

Hi, not sure if it is a bug. most probably, it's me :-)

Environment: 3 VM (foo1..3.lab) with Ubuntu 20.04.2 LTS. Using the Hostnames in the inventory.

Vars used:

k3s_build_cluster: true
k3s_etcd_datastore: true
k3s_control_node: true
k3s_install_hard_links: true
k3s_release_version: "v1.21.1+k3s1"
k3s_become_for_all: true
k3s_server:
  tls-san: '192.168.8.8,k3s-prod.192.168.8.8.nip.io'
  disable:
    - local-storage
  advertise-address: "{{ ansible_host }}"
  bind-address: 0.0.0.0
k3s_agent:
  node-label:
    - "region=sky"
  node-ip: "{{ ansible_host }}"
  node-external-ip: "{{ ansible_host }}"

I ending up here:

RUNNING HANDLER [xanmanning.k3s : restart k3s] ****************************************************************************************************************************
fatal: [foo1.lab]: FAILED! => changed=false
  failed_when_result: true
  msg: |-
    Unable to restart service k3s: Job for k3s.service failed because the control process exited with error code.
    See "systemctl status k3s.service" and "journalctl -xe" for details.

So I did ran the start command manually, including --debug for more information:

sudo /usr/local/bin/k3s server --debug --config /etc/rancher/k3s/config.yaml

Output:

[...]
{"level":"info","ts":"2021-06-17T12:52:20.611+0200","caller":"raft/raft.go:765","msg":"c114fe843b0ccad4 became leader at term 67"}
{"level":"info","ts":"2021-06-17T12:52:20.611+0200","caller":"raft/node.go:325","msg":"raft.node: c114fe843b0ccad4 elected leader c114fe843b0ccad4 at term 67"}
{"level":"info","ts":"2021-06-17T12:52:20.611+0200","caller":"etcdserver/server.go:2039","msg":"published local member to cluster through raft","local-member-id":"c114fe843b0ccad4","local-member-attributes":"{Name:foo1-c035c8b9 ClientURLs:[https://192.168.8.163:2379]}","request-path":"/0/members/c114fe843b0ccad4/attributes","cluster-id":"4583e26907b1dfab","publish-timeout":"15s"}
{"level":"info","ts":"2021-06-17T12:52:20.612+0200","caller":"embed/serve.go:191","msg":"serving client traffic securely","address":"127.0.0.1:2379"}
{"level":"info","ts":"2021-06-17T12:52:20.613+0200","caller":"embed/serve.go:191","msg":"serving client traffic securely","address":"192.168.8.163:2379"}
INFO[2021-06-17T12:52:20.619798049+02:00] etcd data store connection OK
INFO[2021-06-17T12:52:20.620396823+02:00] Saving current etcd snapshot set to k3s-etcd-snapshots ConfigMap
Error: invalid argument "foo1.lab" for "--advertise-address" flag: failed to parse IP: "foo1.lab"
FATA[2021-06-17T12:52:20.621278106+02:00] apiserver exited: invalid argument "foo1.lab" for "--advertise-address" flag: failed to parse IP: "foo1.lab"

Which is exactly what the role wrote to the config:

ubuntu@foo1:~$ grep advertise /etc/rancher/k3s/config.yaml
advertise-address: foo1.lab

If I change this manually to the IP, the error disappears:

ubuntu@foo1:~$ grep advertise /etc/rancher/k3s/config.yaml
advertise-address: 192.168.8.163

According to the docs, this must be an IP.

My Question is: Am I doing something wrong? Or could this be a bug?

tuxpeople commented 3 years ago

Ok. It's me. I'm closing this issue now and then start face palming :D