mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Merge pull request #75224 from neolit123/certs-print-key-on-phase
kubeadm: print key inside the upload-certs phase of init
This commit is contained in:
commit
50bf223a05
@ -379,6 +379,11 @@ func (d *initData) SetCertificateKey(key string) {
|
|||||||
d.certificateKey = key
|
d.certificateKey = key
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SkipCertificateKeyPrint returns the skipCertificateKeyPrint flag.
|
||||||
|
func (d *initData) SkipCertificateKeyPrint() bool {
|
||||||
|
return d.skipCertificateKeyPrint
|
||||||
|
}
|
||||||
|
|
||||||
// Cfg returns initConfiguration.
|
// Cfg returns initConfiguration.
|
||||||
func (d *initData) Cfg() *kubeadmapi.InitConfiguration {
|
func (d *initData) Cfg() *kubeadmapi.InitConfiguration {
|
||||||
return d.cfg
|
return d.cfg
|
||||||
|
@ -30,6 +30,7 @@ type InitData interface {
|
|||||||
UploadCerts() bool
|
UploadCerts() bool
|
||||||
CertificateKey() string
|
CertificateKey() string
|
||||||
SetCertificateKey(key string)
|
SetCertificateKey(key string)
|
||||||
|
SkipCertificateKeyPrint() bool
|
||||||
Cfg() *kubeadmapi.InitConfiguration
|
Cfg() *kubeadmapi.InitConfiguration
|
||||||
DryRun() bool
|
DryRun() bool
|
||||||
SkipTokenPrint() bool
|
SkipTokenPrint() bool
|
||||||
|
@ -33,6 +33,7 @@ var _ InitData = &testInitData{}
|
|||||||
func (t *testInitData) UploadCerts() bool { return false }
|
func (t *testInitData) UploadCerts() bool { return false }
|
||||||
func (t *testInitData) CertificateKey() string { return "" }
|
func (t *testInitData) CertificateKey() string { return "" }
|
||||||
func (t *testInitData) SetCertificateKey(key string) {}
|
func (t *testInitData) SetCertificateKey(key string) {}
|
||||||
|
func (t *testInitData) SkipCertificateKeyPrint() bool { return false }
|
||||||
func (t *testInitData) Cfg() *kubeadmapi.InitConfiguration { return nil }
|
func (t *testInitData) Cfg() *kubeadmapi.InitConfiguration { return nil }
|
||||||
func (t *testInitData) DryRun() bool { return false }
|
func (t *testInitData) DryRun() bool { return false }
|
||||||
func (t *testInitData) SkipTokenPrint() bool { return false }
|
func (t *testInitData) SkipTokenPrint() bool { return false }
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"k8s.io/klog"
|
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
|
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
|
||||||
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
||||||
@ -40,6 +39,7 @@ func NewUploadCertsPhase() workflow.Phase {
|
|||||||
options.CfgPath,
|
options.CfgPath,
|
||||||
options.UploadCerts,
|
options.UploadCerts,
|
||||||
options.CertificateKey,
|
options.CertificateKey,
|
||||||
|
options.SkipCertificateKeyPrint,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ func runUploadCerts(c workflow.RunData) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !data.UploadCerts() {
|
if !data.UploadCerts() {
|
||||||
klog.V(1).Infoln("[upload-certs] Skipping certs upload")
|
fmt.Printf("[upload-certs] Skipping phase. Please see --%s\n", options.UploadCerts)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
client, err := data.Client()
|
client, err := data.Client()
|
||||||
@ -70,5 +70,8 @@ func runUploadCerts(c workflow.RunData) error {
|
|||||||
if err := copycerts.UploadCerts(client, data.Cfg(), data.CertificateKey()); err != nil {
|
if err := copycerts.UploadCerts(client, data.Cfg(), data.CertificateKey()); err != nil {
|
||||||
return errors.Wrap(err, "error uploading certs")
|
return errors.Wrap(err, "error uploading certs")
|
||||||
}
|
}
|
||||||
|
if !data.SkipCertificateKeyPrint() {
|
||||||
|
fmt.Printf("[upload-certs] Using certificate key:\n%s\n", data.CertificateKey())
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ func CreateCertificateKey() (string, error) {
|
|||||||
|
|
||||||
//UploadCerts save certs needs to join a new control-plane on kubeadm-certs sercret.
|
//UploadCerts save certs needs to join a new control-plane on kubeadm-certs sercret.
|
||||||
func UploadCerts(client clientset.Interface, cfg *kubeadmapi.InitConfiguration, key string) error {
|
func UploadCerts(client clientset.Interface, cfg *kubeadmapi.InitConfiguration, key string) error {
|
||||||
fmt.Printf("[upload-certs] storing the certificates in ConfigMap %q in the %q Namespace\n", kubeadmconstants.KubeadmCertsSecret, metav1.NamespaceSystem)
|
fmt.Printf("[upload-certs] Storing the certificates in ConfigMap %q in the %q Namespace\n", kubeadmconstants.KubeadmCertsSecret, metav1.NamespaceSystem)
|
||||||
decodedKey, err := hex.DecodeString(key)
|
decodedKey, err := hex.DecodeString(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user