Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

k0sctl apply: selects wrong IP address for ClusterConfig #716

Open
4 tasks done
nickb937 opened this issue May 16, 2024 · 1 comment
Open
4 tasks done

k0sctl apply: selects wrong IP address for ClusterConfig #716

nickb937 opened this issue May 16, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@nickb937
Copy link

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

  • You are running the latest released version of k0s
  • Make sure you've searched for existing issues, both open and closed
  • Make sure you've searched for PRs too, a fix might've been merged already
  • You're looking at docs for the released version, "main" branch docs are usually ahead of released versions.

Platform

aarch64 & x86_64 (arch linux)

Version

No response

Sysinfo

`k0s sysinfo`
➡️ Please replace this text with the output of `k0s sysinfo`. ⬅️

What happened?

I have a controller node defined with two IP addresses. The primary network adress is 192.168.1.254, the secondary address is 192.168.1.240/32:

# ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1492 qdisc mq state UP group default qlen 1000
    link/ether dc:a6:32:1c:a9:fc brd ff:ff:ff:ff:ff:ff
    altname end0
    inet 192.168.1.254/24 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 192.168.1.240/32 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::dea6:32ff:fe1c:a9fc/64 scope link proto kernel_ll 
       valid_lft forever preferred_lft forever

In k0sctl, I specify:

 - ssh:
      address: 192.168.1.254
      user: root
      port: 22
      keyPath: ~/.ssh/id_rsa
    role: controller+worker

The ClusterConfig is picking up the secondary IP address (192.168.1.240) as the API address but should be choosing the primary IP address 192.168.1.254.

# generated-by-k0sctl 2024-05-16T10:06:40+01:00
apiVersion: k0s.k0sproject.io/v1beta1
kind: ClusterConfig
metadata:
  name: home-cluster
spec:
  api:
    address: 192.168.1.240
    sans:
    - 192.168.1.240
    - 192.168.1.252
    - 192.168.1.254
    - 127.0.0.1
  storage:
    etcd:
      peerAddress: 192.168.1.240
    kine:
      dataSource: mysql://k0s:k0s@tcp(192.168.1.252)/k0s
    type: kine

Steps to reproduce

  1. Build a k0sctl.yaml with a controller node
  2. Add secondary IP to an interface ip addr add 192.168.1.240/32 dev eth0 onto the controller node
  3. k0sctl apply --dry-run and observe the ClusterConfig output

Expected behavior

ClusterConfig should have been defined with the primary interface address 192.168.1.254.

Actual behavior

ClusterConfig should have been defined with the primary interface address 192.168.1.240.

Screenshots and logs

No response

Additional context

No response

@nickb937 nickb937 added the bug Something isn't working label May 16, 2024
@twz123 twz123 transferred this issue from k0sproject/k0s May 16, 2024
@kke
Copy link
Contributor

kke commented May 23, 2024

Yes it intentionally picks a different address than the "public" address (ssh connection address) here

k0sctl/configurer/linux.go

Lines 264 to 266 in 5de84fb

if publicip != addr {
return addr, nil
}

For many cases this works when the primary address is the public one and the secondary is connected to an internal network.

You can use the privateAddress config option to configure the address manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants