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
|
||||
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 {
|
||||
klog.Errorf("couldn't generate kube-vip config, this might cause issues (will continue): %v", err)
|
||||
} else {
|
||||
|
|
|
@ -91,21 +91,26 @@ spec:
|
|||
hostNetwork: true
|
||||
volumes:
|
||||
- hostPath:
|
||||
path: /etc/kubernetes/admin.conf
|
||||
path: "{{ .AdminConf }}"
|
||||
name: kubeconfig
|
||||
status: {}
|
||||
`))
|
||||
|
||||
// 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 ...")
|
||||
|
||||
params := struct {
|
||||
VIP string
|
||||
Port int
|
||||
VIP string
|
||||
Port int
|
||||
AdminConf string
|
||||
}{
|
||||
VIP: cc.KubernetesConfig.APIServerHAVIP,
|
||||
Port: cc.APIServerPort,
|
||||
VIP: cc.KubernetesConfig.APIServerHAVIP,
|
||||
Port: cc.APIServerPort,
|
||||
AdminConf: "/etc/kubernetes/admin.conf",
|
||||
}
|
||||
if workaround {
|
||||
params.AdminConf = "/etc/kubernetes/super-admin.conf"
|
||||
}
|
||||
|
||||
b := bytes.Buffer{}
|
||||
|
|
Loading…
Reference in New Issue