kubesphere / kubekey

Install Kubernetes/K3s only, both Kubernetes/K3s and KubeSphere, and related cloud-native add-ons, it supports all-in-one, multi-node, and HA 🔥 ⎈ 🐳
https://kubesphere.io
Apache License 2.0
2.38k stars 554 forks source link

panic: runtime error: index out of range [0] with length 0 with ipv6 calico config file #2452

Open haodengeke opened 2 weeks ago

haodengeke commented 2 weeks ago

What is version of KubeKey has the issue?

v3.1.7

What is your os environment?

Ubuntu22.04

KubeKey config file

cat config.yaml
apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Cluster
metadata:
  name: sample
spec:
  hosts:
    - {name: ubuntu, address: "127.0.0.1", internalAddress: "127.0.0.1", privateKeyPath: "~/.ssh/id_ed25519"}
  roleGroups:
    etcd:
    - ubuntu
    control-plane:
    - ubuntu
    worker:
    - ubuntu
  controlPlaneEndpoint:
    ## Internal loadbalancer for apiservers
    # internalLoadbalancer: haproxy

    domain: ::1
    address: ""
    port: 6443
  kubernetes:
    version: v1.28.6
    clusterName: cluster.local
    autoRenewCerts: true
    containerManager: containerd
    # apiserverArgs:
    # - service-node-port-range=1-65535
  etcd:
    type: kubekey
  network:
    plugin: calico
    kubePodsCIDR: "fd00:10:244::/48"
    kubeServiceCIDR: "fd00:10:245::/112"
    ## multus support. https://github.com/k8snetworkplumbingwg/multus-cni
    multusCNI:
      enabled: true
  addons: []

A clear and concise description of what happend.

I want to deploy a standalone cluster of k8s and with calico's ipv6, but I found index out of range [0] with length 0 error. May i ask does kubekey support ipv6? or is my configuration wrong? I would be delighted to receive a response,thx

Relevant log output

11:18:37 CST [InstallKubeBinariesModule] Enable kubelet service
11:18:37 CST success: [ubuntu]
11:18:37 CST [InstallKubeBinariesModule] Generate kubelet env
11:18:37 CST success: [ubuntu]
11:18:37 CST [InitKubernetesModule] Generate kubeadm config
panic: runtime error: index out of range [0] with length 0

goroutine 633 [running]:
github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/util.networkRange(0xc00063f890)
    github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/util/ip.go:125 +0x14e
github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/util.GetAvailableIP({0xc00051bc50?, 0x11?})
    github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/util/ip.go:79 +0x4a
github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/util.ParseIp({0xc00051bc50?, 0x11?})
    github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/util/ip.go:40 +0xfd
github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2.(*ClusterSpec).GenerateCertSANs(0xc0002c3800)
    github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2/cluster_types.go:157 +0x2b8
github.com/kubesphere/kubekey/v3/cmd/kk/pkg/kubernetes.(*GenerateKubeadmConfig).Execute(0xc000a686e0, {0x2890ed0, 0xc0002e6a80})
    github.com/kubesphere/kubekey/v3/cmd/kk/pkg/kubernetes/tasks.go:294 +0x14bb
github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task.(*RemoteTask).ExecuteWithRetry(0xc000afea80, {0x2890ed0, 0xc0002e6a80})
    github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task/remote_task.go:216 +0x119
github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task.(*RemoteTask).Run(0xc000afea80, {0x2890ed0, 0xc0002e6a80}, {0x2897cb0, 0xc00071c9f0}, 0x9a3e06?, 0xc000534780?)
    github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task/remote_task.go:152 +0x1c5
created by github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task.(*RemoteTask).RunWithTimeout
    github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task/remote_task.go:109 +0x16d

Additional information

No response