mirror of https://github.com/k3s-io/k3s
Merge pull request #75224 from neolit123/certs-print-key-on-phase
kubeadm: print key inside the upload-certs phase of initpull/564/head
commit
50bf223a05
|
@ -379,6 +379,11 @@ func (d *initData) SetCertificateKey(key string) {
|
|||
d.certificateKey = key
|
||||
}
|
||||
|
||||
// SkipCertificateKeyPrint returns the skipCertificateKeyPrint flag.
|
||||
func (d *initData) SkipCertificateKeyPrint() bool {
|
||||
return d.skipCertificateKeyPrint
|
||||
}
|
||||
|
||||
// Cfg returns initConfiguration.
|
||||
func (d *initData) Cfg() *kubeadmapi.InitConfiguration {
|
||||
return d.cfg
|
||||
|
|
|
@ -30,6 +30,7 @@ type InitData interface {
|
|||
UploadCerts() bool
|
||||
CertificateKey() string
|
||||
SetCertificateKey(key string)
|
||||
SkipCertificateKeyPrint() bool
|
||||
Cfg() *kubeadmapi.InitConfiguration
|
||||
DryRun() bool
|
||||
SkipTokenPrint() bool
|
||||
|
|
|
@ -33,6 +33,7 @@ var _ InitData = &testInitData{}
|
|||
func (t *testInitData) UploadCerts() bool { return false }
|
||||
func (t *testInitData) CertificateKey() string { return "" }
|
||||
func (t *testInitData) SetCertificateKey(key string) {}
|
||||
func (t *testInitData) SkipCertificateKeyPrint() bool { return false }
|
||||
func (t *testInitData) Cfg() *kubeadmapi.InitConfiguration { return nil }
|
||||
func (t *testInitData) DryRun() bool { return false }
|
||||
func (t *testInitData) SkipTokenPrint() bool { return false }
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"k8s.io/klog"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
|
||||
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
||||
|
@ -40,6 +39,7 @@ func NewUploadCertsPhase() workflow.Phase {
|
|||
options.CfgPath,
|
||||
options.UploadCerts,
|
||||
options.CertificateKey,
|
||||
options.SkipCertificateKeyPrint,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func runUploadCerts(c workflow.RunData) error {
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
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 {
|
||||
return errors.Wrap(err, "error uploading certs")
|
||||
}
|
||||
if !data.SkipCertificateKeyPrint() {
|
||||
fmt.Printf("[upload-certs] Using certificate key:\n%s\n", data.CertificateKey())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ func CreateCertificateKey() (string, error) {
|
|||
|
||||
//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 {
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue