Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(main): sync cert for cert cmd #3891

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion pkg/runtime/kubernetes/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (k *KubeadmRuntime) UpdateCertSANs(certSans []string) error {
k.initCert,
k.saveNewKubeadmConfig,
k.uploadConfigFromKubeadm,
k.syncCert,
k.deleteAPIServer,
k.showKubeadmCert,
}
Expand Down Expand Up @@ -136,7 +137,28 @@ func (k *KubeadmRuntime) InitCertsAndKubeConfigs() error {
}

func (k *KubeadmRuntime) initCert() error {
return k.runPipelines("init cert", k.GenerateCert, k.SendNewCertAndKeyToMasters)
return k.runPipelines("init cert", k.GenerateCert, func() error {
return k.sendNewCertAndKey([]string{k.getMaster0IPAndPort()})
})
}

func (k *KubeadmRuntime) syncCert() error {
return k.runPipelines("sync all masters cert", func() error {
for _, master := range k.getMasterIPList()[1:] {
logger.Debug("start to generate cert for master %s", master)
err := k.execCert(master)
if err != nil {
return fmt.Errorf("failed to create cert for master %s: %v", master, err)
}

err = k.copyMasterKubeConfig(master)
if err != nil {
return err
}
logger.Info("succeeded generate cert %s as master", master)
}
return nil
})
}

func (k *KubeadmRuntime) showKubeadmCert() error {
Expand Down
Loading