k0sproject / k0sproject/k0sctl

k0sctl apply: selects wrong IP address for ClusterConfig

Open
#716 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
582
Forks
113
Avg merge
2d 13h
Merged PRs (30d)
34

Description

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

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

### Platform

```shell
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: 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_

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the controller setup with primary address 192.168.1.254 and secondary address 192.168.1.240/32, then run `k0sctl apply --dry-run` and trace how the ClusterConfig API and peer addresses are selected. Done means the generated ClusterConfig uses the primary interface address 192.168.1.254 rather than the secondary address.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
devops, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.