kubernetes / kubeadm

Aggregator for issues filed against kubeadm
Apache License 2.0
3.76k stars 716 forks source link

'kubeadm join' fails if apiServerEndpoint use [IPv6]:port notation #3101

Closed doka380 closed 3 months ago

doka380 commented 3 months ago

What keywords did you search in kubeadm issues before filing this one?

apiServerEndpoint, IPv6

Is this a BUG REPORT or FEATURE REQUEST?

BUG REPORT

Versions

kubeadm version: 1.31.0

Environment:

What happened?

When joining cluster with custom YAML file, the following configuration (specifically - apiServerEndpoint) fails:

apiVersion: kubeadm.k8s.io/v1beta4
kind: JoinConfiguration
nodeRegistration:
  criSocket: "unix:///run/containerd/containerd.sock"
  kubeletExtraArgs:
  - name: node-ip
    value: "x.x.x.x,,2a01:xxxx:xxxx:xxxx:1715::1ea"
discovery:
  bootstrapToken:
    apiServerEndpoint: [2a01:xxxx:xxxx:xxxx:1715::19e]:6443
    token: "nyb6dc.s58lqvo1c02tje0w"
    caCertHashes:
    - "sha256:828b7916ec2e27717e1956d10ed2a4c3dca66516dc6e3a0ea919153657757aef"
    [ ... ]

with the message

I0822 10:43:21.602530   42333 joinconfiguration.go:83] loading configuration from "gen-join-kw1.yml"
could not interpret GroupVersionKind; unmarshal error: error converting YAML to JSON: yaml: line 9: did not find expected key

but if I change apiServerEndpoint parameter to fqdn:6443, it passes through this step. At the same time, the following CLI command (using the same syntax [IPv6]:port) do not produce error messages:

sudo kubeadm join [2a01:xxxx:xxxx:xxxx:1715::19e]:6443 --token nyb6dc.s58lqvo1c02tje0w \
        --discovery-token-ca-cert-hash sha256:828b7916ec2e27717e1956d10ed2a4c3dca66516dc6e3a0ea919153657757aef

and, using the same notation for controlPlaneEndpoint in ClusterConfiguration during kubeadm init :

apiVersion: kubeadm.k8s.io/v1beta4
kind: ClusterConfiguration
networking:
  podSubnet: fd53:ba5e:ba11::/48
  serviceSubnet: fd53:babe:c001::/112
controlPlaneEndpoint: "[2a01:xxxx:xxxx:xxxx:1715::19e]:6443"

passed successfully.

What you expected to happen?

I'm expecting that using notation [IPv6]:port should not produce errors, if this notation works in CLI and in other configurations of kubeadm.

How to reproduce it (as minimally and precisely as possible)?

Try to initialize single controller and join single worker in IPv6-based environment, using IP addresses instead of FQDNs.

Anything else we need to know?

I like Kubernetes :-)

neolit123 commented 3 months ago

could not interpret GroupVersionKind; unmarshal error: error converting YAML to JSON: yaml: line 9: did not find expected key

this is a problem from the sigs.k8s.io/yaml library which core k8s and kubeadm use.

i think it's a matter of quoting the value. please try: apiServerEndpoint: "[2a01:xxxx:xxxx:xxxx:1715::19e]:6443"

notice how the quoted one works on init: controlPlaneEndpoint: "[2a01:xxxx:xxxx:xxxx:1715::19e]:6443"

doka380 commented 3 months ago

Yup, thank you very much, it was about quoting. Thanks again :)