templates/k8s: accept an https:// url when joining a node

The documentation and the k3s template pass the control plane as a
URL ("https://<ADDRESS>:6443"), but the k8s template put the url
param into apiServerEndpoint unchanged, and kubeadm expects a bare
host:port there, so the documented command did not work.

Strip the https:// prefix in the template, so both forms work, and
make the template comment and the BATS test use the URL form.

Fixes #5552

Signed-off-by: Sarthak <sarthakshreshtha345@gmail.com>
This commit is contained in:
Sarthak committed 2026-10-03 14:43:57 +05:30
1 parent c6fce45036
commit 7420bb01eb
2 files changed
+6 -3

No files matched your search

+1 -1
View File
@@ -46,7 +46,7 @@ local_setup() {
# kubeadm join ADDRESS --token TOKEN --discovery-token-ca-cert-hash DISCOVERY_TOKEN_CA_CERT_HASH
read -ra words <<< "$join_command"
assert_equal "${words[1]} ${words[3]} ${words[5]}" "join --token --discovery-token-ca-cert-hash"
params=".param.url=\"${words[2]}\"|.param.token=\"${words[4]}\"|.param.discoveryTokenCaCertHash=\"${words[6]}\""
params=".param.url=\"https://${words[2]}\"|.param.token=\"${words[4]}\"|.param.discoveryTokenCaCertHash=\"${words[6]}\""
elif [[ $i -eq 0 && "${TEMPLATE}" == "k3s" ]]; then
url=$(printf "https://lima-%s.internal:6443\n" "${NAME}-0")
token=$(limactl shell "${NAME}-0" sudo cat /var/lib/rancher/k3s/server/node-token)
+5 -2
View File
@@ -18,7 +18,7 @@
# (The parameters for the start command printed here)
#
# $ limactl start --name k8s-1 --network lima:user-v2 template:k8s \
# --param url="<ADDRESS_FROM_ABOVE>" --param token="<TOKEN_FROM_ABOVE>" \
# --param url="https://<ADDRESS_FROM_ABOVE>" --param token="<TOKEN_FROM_ABOVE>" \
# --param discoveryTokenCaCertHash="<DISCOVERY_TOKEN_CA_CERT_HASH_FROM_ABOVE>"
minimumLimaVersion: 2.0.0
@@ -139,6 +139,7 @@ provision:
EOF
kubeadm init --config /etc/kubeadm-config.yaml
{{else}}
API_SERVER_ENDPOINT=$(echo "{{.Param.url}}" | sed -e "s|https://||")
cat <<EOF >/etc/kubeadm-config.yaml
kind: JoinConfiguration
apiVersion: kubeadm.k8s.io/v1beta4
@@ -146,7 +147,7 @@ provision:
criSocket: unix:///run/containerd/containerd.sock
discovery:
bootstrapToken:
apiServerEndpoint: "{{.Param.url}}"
apiServerEndpoint: "${API_SERVER_ENDPOINT}"
token: "{{.Param.token}}"
caCertHashes:
- "{{.Param.discoveryTokenCaCertHash}}"
@@ -261,6 +262,8 @@ param:
version: "stable"
# The flannel version is either "latest" or "v0.xx.y"
flannelVersion: "v0.28.9"
# The control plane to join, as printed by `kubeadm token create --print-join-command`:
# url ("https://<ADDRESS>:6443"), token ("..."), discoveryTokenCaCertHash ("sha256:...")
url: ""
token: ""
discoveryTokenCaCertHash: ""