workaround for kube-vip and k8s v1.29+
parent
6731cdee84
commit
bcdfc03020
|
@ -951,7 +951,15 @@ func (k *Bootstrapper) UpdateNode(cfg config.ClusterConfig, n config.Node, r cru
|
||||||
}
|
}
|
||||||
// deploy kube-vip for ha cluster
|
// deploy kube-vip for ha cluster
|
||||||
if config.HA(cfg) {
|
if config.HA(cfg) {
|
||||||
kubevipCfg, err := kubevip.Configure(cfg)
|
// workaround for kube-vip
|
||||||
|
// only applicable for k8s v1.29+ during primary control-plane node's kubeadm init (ie, first boot)
|
||||||
|
// TODO (prezha): remove when fixed upstream - ref: https://github.com/kube-vip/kube-vip/issues/684#issuecomment-1864855405
|
||||||
|
kv, err := semver.ParseTolerant(cfg.KubernetesConfig.KubernetesVersion)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrapf(err, "parsing kubernetes version %q", cfg.KubernetesConfig.KubernetesVersion)
|
||||||
|
}
|
||||||
|
workaround := kv.GTE(semver.Version{Major: 1, Minor: 29}) && config.IsPrimaryControlPlane(n) && len(config.ControlPlanes(cfg)) == 1
|
||||||
|
kubevipCfg, err := kubevip.Configure(cfg, workaround)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("couldn't generate kube-vip config, this might cause issues (will continue): %v", err)
|
klog.Errorf("couldn't generate kube-vip config, this might cause issues (will continue): %v", err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -91,21 +91,26 @@ spec:
|
||||||
hostNetwork: true
|
hostNetwork: true
|
||||||
volumes:
|
volumes:
|
||||||
- hostPath:
|
- hostPath:
|
||||||
path: /etc/kubernetes/admin.conf
|
path: "{{ .AdminConf }}"
|
||||||
name: kubeconfig
|
name: kubeconfig
|
||||||
status: {}
|
status: {}
|
||||||
`))
|
`))
|
||||||
|
|
||||||
// Configure takes last client ip address in cluster nodes network subnet as vip address and generates kube-vip.yaml file.
|
// Configure takes last client ip address in cluster nodes network subnet as vip address and generates kube-vip.yaml file.
|
||||||
func Configure(cc config.ClusterConfig) ([]byte, error) {
|
func Configure(cc config.ClusterConfig, workaround bool) ([]byte, error) {
|
||||||
klog.Info("generating kube-vip config ...")
|
klog.Info("generating kube-vip config ...")
|
||||||
|
|
||||||
params := struct {
|
params := struct {
|
||||||
VIP string
|
VIP string
|
||||||
Port int
|
Port int
|
||||||
|
AdminConf string
|
||||||
}{
|
}{
|
||||||
VIP: cc.KubernetesConfig.APIServerHAVIP,
|
VIP: cc.KubernetesConfig.APIServerHAVIP,
|
||||||
Port: cc.APIServerPort,
|
Port: cc.APIServerPort,
|
||||||
|
AdminConf: "/etc/kubernetes/admin.conf",
|
||||||
|
}
|
||||||
|
if workaround {
|
||||||
|
params.AdminConf = "/etc/kubernetes/super-admin.conf"
|
||||||
}
|
}
|
||||||
|
|
||||||
b := bytes.Buffer{}
|
b := bytes.Buffer{}
|
||||||
|
|
Loading…
Reference in New Issue