Skip to content

Commit a3ed9f0

Browse files
join-phases-texts
1 parent e1b79ab commit a3ed9f0

File tree

7 files changed

+45
-33
lines changed

7 files changed

+45
-33
lines changed

cmd/kubeadm/app/cmd/join.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func NewCmdJoin(out io.Writer, joinOptions *joinOptions) *cobra.Command {
157157
joinRunner := workflow.NewRunner()
158158

159159
cmd := &cobra.Command{
160-
Use: "join",
160+
Use: "join [api-server-endpoint]",
161161
Short: "Run this on any machine you wish to join an existing cluster",
162162
Long: joinLongDescription,
163163
Run: func(cmd *cobra.Command, args []string) {
@@ -336,7 +336,7 @@ func newJoinData(cmd *cobra.Command, args []string, opt *joinOptions, out io.Wri
336336
opt.externalcfg.Discovery.BootstrapToken = nil
337337
} else {
338338
if len(opt.cfgPath) == 0 && len(args) > 1 {
339-
klog.Warningf("[join] WARNING: More than one API server endpoint supplied on command line %v. Using the first one.", args)
339+
klog.Warningf("[preflight] WARNING: More than one API server endpoint supplied on command line %v. Using the first one.", args)
340340
}
341341
opt.externalcfg.Discovery.BootstrapToken.APIServerEndpoint = args[0]
342342
}
@@ -352,7 +352,7 @@ func newJoinData(cmd *cobra.Command, args []string, opt *joinOptions, out io.Wri
352352
var tlsBootstrapCfg *clientcmdapi.Config
353353
if _, err := os.Stat(adminKubeConfigPath); err == nil && opt.controlPlane {
354354
// use the admin.conf as tlsBootstrapCfg, that is the kubeconfig file used for reading the kubeadm-config during discovery
355-
klog.V(1).Infof("[join] found %s. Use it for skipping discovery", adminKubeConfigPath)
355+
klog.V(1).Infof("[preflight] found %s. Use it for skipping discovery", adminKubeConfigPath)
356356
tlsBootstrapCfg, err = clientcmd.LoadFromFile(adminKubeConfigPath)
357357
if err != nil {
358358
return nil, errors.Wrapf(err, "Error loading %s", adminKubeConfigPath)
@@ -371,19 +371,19 @@ func newJoinData(cmd *cobra.Command, args []string, opt *joinOptions, out io.Wri
371371
// Either use the config file if specified, or convert public kubeadm API to the internal JoinConfiguration
372372
// and validates JoinConfiguration
373373
if opt.externalcfg.NodeRegistration.Name == "" {
374-
klog.V(1).Infoln("[join] found NodeName empty; using OS hostname as NodeName")
374+
klog.V(1).Infoln("[preflight] found NodeName empty; using OS hostname as NodeName")
375375
}
376376

377377
if opt.externalcfg.ControlPlane != nil && opt.externalcfg.ControlPlane.LocalAPIEndpoint.AdvertiseAddress == "" {
378-
klog.V(1).Infoln("[join] found advertiseAddress empty; using default interface's IP address as advertiseAddress")
378+
klog.V(1).Infoln("[preflight] found advertiseAddress empty; using default interface's IP address as advertiseAddress")
379379
}
380380

381381
// in case the command doesn't have flags for discovery, makes the join cfg validation pass checks on discovery
382382
if cmd.Flags().Lookup(options.FileDiscovery) == nil {
383383
if _, err := os.Stat(adminKubeConfigPath); os.IsNotExist(err) {
384384
return nil, errors.Errorf("File %s does not exists. Please use 'kubeadm join phase control-plane-prepare' subcommands to generate it.", adminKubeConfigPath)
385385
}
386-
klog.V(1).Infof("[join] found discovery flags missing for this command. using FileDiscovery: %s", adminKubeConfigPath)
386+
klog.V(1).Infof("[preflight] found discovery flags missing for this command. using FileDiscovery: %s", adminKubeConfigPath)
387387
opt.externalcfg.Discovery.File = &kubeadmapiv1beta1.FileDiscovery{KubeConfigPath: adminKubeConfigPath}
388388
opt.externalcfg.Discovery.BootstrapToken = nil //NB. this could be removed when we get better control on args (e.g. phases without discovery should have NoArgs )
389389
}
@@ -431,7 +431,7 @@ func (j *joinData) TLSBootstrapCfg() (*clientcmdapi.Config, error) {
431431
if j.tlsBootstrapCfg != nil {
432432
return j.tlsBootstrapCfg, nil
433433
}
434-
klog.V(1).Infoln("[join] Discovering cluster-info")
434+
klog.V(1).Infoln("[preflight] Discovering cluster-info")
435435
tlsBootstrapCfg, err := discovery.For(j.cfg)
436436
j.tlsBootstrapCfg = tlsBootstrapCfg
437437
return tlsBootstrapCfg, err
@@ -445,7 +445,7 @@ func (j *joinData) InitCfg() (*kubeadmapi.InitConfiguration, error) {
445445
if _, err := j.TLSBootstrapCfg(); err != nil {
446446
return nil, err
447447
}
448-
klog.V(1).Infoln("[join] Fetching init configuration")
448+
klog.V(1).Infoln("[preflight] Fetching init configuration")
449449
initCfg, err := fetchInitConfigurationFromJoinConfiguration(j.cfg, j.tlsBootstrapCfg)
450450
j.initCfg = initCfg
451451
return initCfg, err
@@ -459,7 +459,7 @@ func (j *joinData) ClientSet() (*clientset.Clientset, error) {
459459
path := kubeadmconstants.GetAdminKubeConfigPath()
460460
client, err := kubeconfigutil.ClientSetFromFile(path)
461461
if err != nil {
462-
return nil, errors.Wrap(err, "[join] couldn't create Kubernetes client")
462+
return nil, errors.Wrap(err, "[preflight] couldn't create Kubernetes client")
463463
}
464464
j.clientSet = client
465465
return client, nil
@@ -478,7 +478,7 @@ func (j *joinData) OutputWriter() io.Writer {
478478
// fetchInitConfigurationFromJoinConfiguration retrieves the init configuration from a join configuration, performing the discovery
479479
func fetchInitConfigurationFromJoinConfiguration(cfg *kubeadmapi.JoinConfiguration, tlsBootstrapCfg *clientcmdapi.Config) (*kubeadmapi.InitConfiguration, error) {
480480
// Retrieves the kubeadm configuration
481-
klog.V(1).Infoln("[join] Retrieving KubeConfig objects")
481+
klog.V(1).Infoln("[preflight] Retrieving KubeConfig objects")
482482
initConfiguration, err := fetchInitConfiguration(tlsBootstrapCfg)
483483
if err != nil {
484484
return nil, err
@@ -509,7 +509,7 @@ func fetchInitConfiguration(tlsBootstrapCfg *clientcmdapi.Config) (*kubeadmapi.I
509509
}
510510

511511
// Fetches the init configuration
512-
initConfiguration, err := configutil.FetchInitConfigurationFromCluster(tlsClient, os.Stdout, "join", true)
512+
initConfiguration, err := configutil.FetchInitConfigurationFromCluster(tlsClient, os.Stdout, "preflight", true)
513513
if err != nil {
514514
return nil, errors.Wrap(err, "unable to fetch the kubeadm-config ConfigMap")
515515
}

cmd/kubeadm/app/cmd/phases/join/controlplanejoin.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func NewControlPlaneJoinPhase() workflow.Phase {
6262
RunAllSiblings: true,
6363
},
6464
newEtcdLocalSubphase(),
65-
newUploadConfigSubphase(),
65+
newUpdateStatusSubphase(),
6666
newMarkControlPlaneSubphase(),
6767
},
6868
}
@@ -71,17 +71,21 @@ func NewControlPlaneJoinPhase() workflow.Phase {
7171
func newEtcdLocalSubphase() workflow.Phase {
7272
return workflow.Phase{
7373
Name: "etcd",
74-
Short: "Generates the static Pod manifest file for a local etcd member",
74+
Short: "Add a new local etcd member",
7575
Run: runEtcdPhase,
7676
InheritFlags: getControlPlaneJoinPhaseFlags(),
7777
}
7878
}
7979

80-
func newUploadConfigSubphase() workflow.Phase {
80+
func newUpdateStatusSubphase() workflow.Phase {
8181
return workflow.Phase{
82-
Name: "upload-config",
83-
Short: "Upload the currently used configuration to the cluster",
84-
Run: runUploadConfigPhase,
82+
Name: "update-status",
83+
Short: fmt.Sprintf(
84+
"Register the new control-plane node into the %s maintained in the %s ConfigMap",
85+
kubeadmconstants.ClusterStatusConfigMapKey,
86+
kubeadmconstants.KubeadmConfigConfigMap,
87+
),
88+
Run: runUpdateStatusPhase,
8589
InheritFlags: getControlPlaneJoinPhaseFlags(),
8690
}
8791
}
@@ -136,7 +140,7 @@ func runEtcdPhase(c workflow.RunData) error {
136140
return nil
137141
}
138142

139-
func runUploadConfigPhase(c workflow.RunData) error {
143+
func runUpdateStatusPhase(c workflow.RunData) error {
140144
data, ok := c.(JoinData)
141145
if !ok {
142146
return errors.New("control-plane-join phase invoked with an invalid data struct")

cmd/kubeadm/app/cmd/phases/join/controlplaneprepare.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"k8s.io/klog"
2626
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
2727
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
28-
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
2928
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
3029
certsphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/certs"
3130
"k8s.io/kubernetes/cmd/kubeadm/app/phases/controlplane"
@@ -41,7 +40,7 @@ func NewControlPlanePreparePhase() workflow.Phase {
4140
Short: "Prepares the machine for serving a control plane.",
4241
Phases: []workflow.Phase{
4342
{
44-
Name: "all",
43+
Name: "all [api-server-endpoint]",
4544
Short: "Prepares the machine for serving a control plane.",
4645
InheritFlags: getControlPlanePreparePhaseFlags("all"),
4746
RunAllSiblings: true,
@@ -82,17 +81,16 @@ func getControlPlanePreparePhaseFlags(name string) []string {
8281

8382
func newControlPlanePrepareDownloadCertsSubphase() workflow.Phase {
8483
return workflow.Phase{
85-
Name: "download-certs",
86-
Short: fmt.Sprintf("Download certificates from %s", kubeadmconstants.KubeadmCertsSecret),
87-
Long: cmdutil.MacroCommandLongDescription,
84+
Name: "download-certs [api-server-endpoint]",
85+
Short: fmt.Sprintf("[EXPERIMENTAL] Downloads certificates shared among control-plane nodes from the %s Secret", kubeadmconstants.KubeadmCertsSecret),
8886
Run: runControlPlanePrepareDownloadCertsPhaseLocal,
8987
InheritFlags: getControlPlanePreparePhaseFlags("download-certs"),
9088
}
9189
}
9290

9391
func newControlPlanePrepareCertsSubphase() workflow.Phase {
9492
return workflow.Phase{
95-
Name: "certs",
93+
Name: "certs [api-server-endpoint]",
9694
Short: "Generates the certificates for the new control plane components",
9795
Run: runControlPlanePrepareCertsPhaseLocal, //NB. eventually in future we would like to break down this in sub phases for each cert or add the --csr option
9896
InheritFlags: getControlPlanePreparePhaseFlags("certs"),
@@ -101,7 +99,7 @@ func newControlPlanePrepareCertsSubphase() workflow.Phase {
10199

102100
func newControlPlanePrepareKubeconfigSubphase() workflow.Phase {
103101
return workflow.Phase{
104-
Name: "kubeconfig",
102+
Name: "kubeconfig [api-server-endpoint]",
105103
Short: "Generates the kubeconfig for the new control plane components",
106104
Run: runControlPlanePrepareKubeconfigPhaseLocal, //NB. eventually in future we would like to break down this in sub phases for each kubeconfig
107105
InheritFlags: getControlPlanePreparePhaseFlags("kubeconfig"),
@@ -110,7 +108,7 @@ func newControlPlanePrepareKubeconfigSubphase() workflow.Phase {
110108

111109
func newControlPlanePrepareManifestsSubphases() workflow.Phase {
112110
return workflow.Phase{
113-
Name: "manifests",
111+
Name: "control-plane",
114112
Short: "Generates the manifests for the new control plane components",
115113
Run: runControlPlanePrepareManifestsSubphase, //NB. eventually in future we would like to break down this in sub phases for each component
116114
InheritFlags: getControlPlanePreparePhaseFlags("manifests"),

cmd/kubeadm/app/cmd/phases/join/kubelet.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ var (
5656
// NewKubeletStartPhase creates a kubeadm workflow phase that start kubelet on a node.
5757
func NewKubeletStartPhase() workflow.Phase {
5858
return workflow.Phase{
59-
Name: "kubelet-start",
59+
Name: "kubelet-start [api-server-endpoint]",
6060
Short: "Writes kubelet settings, certificates and (re)starts the kubelet",
6161
Long: "Writes a file with KubeletConfiguration and an environment file with node specific kubelet settings, and then (re)starts kubelet.",
6262
Run: runKubeletStartJoinPhase,
@@ -102,7 +102,7 @@ func runKubeletStartJoinPhase(c workflow.RunData) error {
102102
bootstrapKubeConfigFile := kubeadmconstants.GetBootstrapKubeletKubeConfigPath()
103103

104104
// Write the bootstrap kubelet config file or the TLS-Boostrapped kubelet config file down to disk
105-
klog.V(1).Infoln("[join] writing bootstrap kubelet config file at", bootstrapKubeConfigFile)
105+
klog.V(1).Infoln("[kubelet-start] writing bootstrap kubelet config file at", bootstrapKubeConfigFile)
106106
if err := kubeconfigutil.WriteToDisk(bootstrapKubeConfigFile, tlsBootstrapCfg); err != nil {
107107
return errors.Wrap(err, "couldn't save bootstrap-kubelet.conf to disk")
108108
}

cmd/kubeadm/app/cmd/phases/join/preflight.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ var (
5454
// NewPreflightPhase creates a kubeadm workflow phase that implements preflight checks for a new node join
5555
func NewPreflightPhase() workflow.Phase {
5656
return workflow.Phase{
57-
Name: "preflight",
57+
Name: "preflight [api-server-endpoint]",
5858
Short: "Run join pre-flight checks",
5959
Long: "Run pre-flight checks for kubeadm join.",
6060
Example: preflightExample,

cmd/kubeadm/app/cmd/phases/workflow/runner.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ func (e *Runner) prepareForExecution() {
442442
// addPhaseRunner adds the phaseRunner for a given phase to the phaseRunners list
443443
func addPhaseRunner(e *Runner, parentRunner *phaseRunner, phase Phase) {
444444
// computes contextual information derived by the workflow managed by the Runner.
445-
generatedName := strings.ToLower(phase.Name)
446-
use := generatedName
445+
use := cleanName(phase.Name)
446+
generatedName := use
447447
selfPath := []string{generatedName}
448448

449449
if parentRunner != nil {
@@ -471,3 +471,13 @@ func addPhaseRunner(e *Runner, parentRunner *phaseRunner, phase Phase) {
471471
addPhaseRunner(e, currentRunner, childPhase)
472472
}
473473
}
474+
475+
// cleanName makes phase name suitable for the runner help, by lowercasing the name
476+
// and removing args descriptors, if any
477+
func cleanName(name string) string {
478+
ret := strings.ToLower(name)
479+
if pos := strings.Index(ret, " "); pos != -1 {
480+
ret = ret[:pos]
481+
}
482+
return ret
483+
}

cmd/kubeadm/app/cmd/phases/workflow/runner_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func TestHelp(t *testing.T) {
262262
var w = Runner{
263263
Phases: []Phase{
264264
phaseBuilder3("foo", false,
265-
phaseBuilder3("bar", false),
265+
phaseBuilder3("bar [arg]", false),
266266
phaseBuilder3("baz", true),
267267
),
268268
phaseBuilder3("qux", false),
@@ -272,7 +272,7 @@ func TestHelp(t *testing.T) {
272272
expected := "The \"myCommand\" command executes the following phases:\n" +
273273
"```\n" +
274274
"foo long description for foo ...\n" +
275-
" /bar long description for bar ...\n" +
275+
" /bar long description for bar [arg] ...\n" +
276276
"qux long description for qux ...\n" +
277277
"```"
278278

0 commit comments

Comments
 (0)