Open uablrek opened 3 weeks ago
I don't think k0s passes any --node-ip flags to kubelet at all. According to the CLI flag's description, it defaults to IPv4. That's what you're seeing in your cluster, I suppose.
--node-ip string IP address (or comma-separated dual-stack IP addresses) of the node. If unset, kubelet will use the node's default IPv4 address, if any, or its default IPv6 address if it has no IPv4 addresses. You can pass '::' to make it prefer the default IPv6 address rather than the default IPv4 address.
You could pass your own values via --kubelet-extra-args=--node-ip=...
in spec.hosts[*].installFlags
for the time being.
/cc @ncopa WDYT about this?
I don't think k0s passes any --node-ip flags to kubelet at all.
@twz123 You are right. I specified privateAddress:
. If I remove that, no "--node-ip" is passed to kubelet.
vm-002 ~ # ps www | grep kubelet
464 root 1267m S /var/lib/k0s/bin/kubelet --root-dir=/var/lib/k0s/kubelet --config=/var/lib/k0s/kubelet-config.yaml --kubeconfig=/var/lib/k0s/kubelet.conf --v=1 --cert-dir=/var/lib/k0s/kubelet/pki --containerd=/run/k0s/containerd.sock --runtime-cgroups=/system.slice/containerd.service
But for dual-stack it seems that you must specify "comma-separated dual-stack IP addresses" to get it right:
vm-002 ~ # k0s kubectl get node $(hostname) -o json | jq .status.addresses
[
{
"address": "192.168.1.2",
"type": "InternalIP"
},
{
"address": "vm-002",
"type": "Hostname"
}
]
(ipv6 is missing)
If it's connected to privateAddress
, then it's probably something in k0sctl, not in k0s itself ... Indeed, it is: https://github.com/k0sproject/k0sctl/blob/v0.18.1/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/host.go#L320-L327
Not sure what to do here, since the IPv6 is not part of the k0sctl config at all. /cc @kke How would k0s or k0sctl know which IP to use if it isn't specified? Sure, there could be some magic auto-detection, but less magic is usually preferable. Would it make sense to make privateAddress
a list and accept multiple IPs, or is that a bad idea? :thinking:
You could pass your own values via --kubelet-extra-args=--node-ip=... in spec.hosts[*].installFlags for the time being.
Yes, that works :smiley:
vm-002 ~ # k0s kubectl get node $(hostname) -o json | jq .status.addresses
[
{
"address": "192.168.1.2",
"type": "InternalIP"
},
{
"address": "fd00::c0a8:102",
"type": "InternalIP"
},
{
"address": "vm-002",
"type": "Hostname"
}
]
I removed privateAddress:
and instead specified:
installFlags:
- "--kubelet-extra-args=--node-ip=192.168.1.2,fd00::192.168.1.2"
If privateAddress:
is only used for passing an address to kubelet via --node-ip, it should take comma-separated dual-stack IP addresses, same as kubelet.
For a better user experience, k0sctl
may specify the first IPv4 and the first global IPv6 for "privateInterface:" as --node-ip if dual-stack is enabled.
This problem should be documented in any case.
I am happy with this work-around, and you may close this issue if you like, or keep it for reference.
Before creating an issue, make sure you've checked the following:
Platform
Version
vm-001 ~ # k0s version v1.30.2+k0s.0
Sysinfo
`k0s sysinfo`
What happened?
In dual-stack mode only the ipv4 address is specified in the "--node-ip" parameter to kubelet. This causes the node object to have only an ipv4 address.
Steps to reproduce
ps ... | grep kubelet
and check the "--node-ip" parameterk0s kubectl get node $(hostname) -o json | jq .status.addresses
. Only ipv4 is presentExpected behavior
Both ipv4 and ipv6 addresses should be specified in "--node-ip", example:
Then, when the worker joins, the node object will have both addresses:
Actual behavior
Only ipv4 is specified in "--node-ip", and the node object only gets an ipv4 address:
Screenshots and logs
No response
Additional context
I install with
k0sctl
.k0scat.yaml
```yaml apiVersion: k0sctl.k0sproject.io/v1beta1 kind: Cluster metadata: name: k0s-cluster spec: k0s: version: $__k0sver config: apiVersion: k0s.k0sproject.io/v1beta1 kind: Cluster metadata: name: k0s spec: api: k0sApiPort: 9443 port: 6443 installConfig: users: etcdUser: etcd kineUser: kube-apiserver konnectivityUser: konnectivity-server kubeAPIserverUser: kube-apiserver kubeSchedulerUser: kube-scheduler konnectivity: adminPort: 8133 agentPort: 8132 network: kubeProxy: disabled: false mode: iptables provider: calico calico: mode: "bird" envVars: IP_AUTODETECTION_METHOD: "interface=eth1" IP6_AUTODETECTION_METHOD: "interface=eth1" kuberouter: autoMTU: true mtu: 0 peerRouterASNs: "" peerRouterIPs: "" podCIDR: 10.244.0.0/16 serviceCIDR: 10.96.0.0/16 dualStack: enabled: true IPv6podCIDR: "$PREFIX:0af4:0:0/108" IPv6serviceCIDR: "$PREFIX:0a60:0:0/108" podSecurityPolicy: defaultPolicy: 00-k0s-privileged storage: type: etcd telemetry: enabled: false hosts: - ssh: address: 192.168.1.1 user: root port: 22 keyPath: /root/.ssh/id_dropbear_ssh role: controller+worker installFlags: - --disable-components=konnectivity-server noTaints: true os: alpine privateInterface: eth1 privateAddress: 192.168.1.1 k0sDownloadURL: file:///root/www/k0s-$__k0sver-amd64 - ssh: address: 192.168.1.2 user: root port: 22 keyPath: /root/.ssh/id_dropbear_ssh role: worker os: alpine privateInterface: eth1 privateAddress: 192.168.1.2 k0sDownloadURL: file:///root/www/k0s-$__k0sver-amd64 - ssh: address: 192.168.1.3 user: root port: 22 keyPath: /root/.ssh/id_dropbear_ssh role: worker os: alpine privateInterface: eth1 privateAddress: 192.168.1.3 k0sDownloadURL: file:///root/www/k0s-$__k0sver-amd64 - ssh: address: 192.168.1.4 user: root port: 22 keyPath: /root/.ssh/id_dropbear_ssh role: worker os: alpine privateInterface: eth1 privateAddress: 192.168.1.4 k0sDownloadURL: file:///root/www/k0s-$__k0sver-amd64 ```