@@ -31,13 +31,20 @@ import (
31
31
"k8s.io/kubernetes/cmd/kubeadm/app/phases/copycerts"
32
32
kubeconfigphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubeconfig"
33
33
kubeconfigutil "k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig"
34
+ "k8s.io/kubernetes/pkg/util/normalizer"
34
35
)
35
36
37
+ var controlPlanePrepareExample = normalizer .Examples (`
38
+ # Prepares the machine for serving a control plane
39
+ kubeadm join phase control-plane-prepare all
40
+ ` )
41
+
36
42
// NewControlPlanePreparePhase creates a kubeadm workflow phase that implements the preparation of the node to serve a control plane
37
43
func NewControlPlanePreparePhase () workflow.Phase {
38
44
return workflow.Phase {
39
- Name : "control-plane-prepare" ,
40
- Short : "Prepares the machine for serving a control plane." ,
45
+ Name : "control-plane-prepare" ,
46
+ Short : "Prepares the machine for serving a control plane." ,
47
+ Example : controlPlanePrepareExample ,
41
48
Phases : []workflow.Phase {
42
49
{
43
50
Name : "all [api-server-endpoint]" ,
@@ -48,33 +55,75 @@ func NewControlPlanePreparePhase() workflow.Phase {
48
55
newControlPlanePrepareDownloadCertsSubphase (),
49
56
newControlPlanePrepareCertsSubphase (),
50
57
newControlPlanePrepareKubeconfigSubphase (),
51
- newControlPlanePrepareManifestsSubphases (),
58
+ newControlPlanePrepareControlPlaneSubphase (),
52
59
},
53
60
}
54
61
}
55
62
56
63
func getControlPlanePreparePhaseFlags (name string ) []string {
57
- flags := []string {
58
- options . APIServerAdvertiseAddress ,
59
- options . APIServerBindPort ,
60
- options . CfgPath ,
61
- options .ControlPlane ,
62
- options .NodeName ,
63
- }
64
- if name != "manifests" {
65
- flags = append ( flags ,
64
+ var flags []string
65
+ switch name {
66
+ case "all" :
67
+ flags = [] string {
68
+ options .APIServerAdvertiseAddress ,
69
+ options .APIServerBindPort ,
70
+ options . CfgPath ,
71
+ options . ControlPlane ,
72
+ options . NodeName ,
66
73
options .FileDiscovery ,
67
74
options .TokenDiscovery ,
68
75
options .TokenDiscoveryCAHash ,
69
76
options .TokenDiscoverySkipCAHash ,
70
77
options .TLSBootstrapToken ,
71
78
options .TokenStr ,
72
- )
73
- }
74
- if name == "all" || name == "download-certs" {
75
- flags = append (flags ,
76
79
options .CertificateKey ,
77
- )
80
+ }
81
+ case "download-certs" :
82
+ flags = []string {
83
+ options .CfgPath ,
84
+ options .ControlPlane ,
85
+ options .FileDiscovery ,
86
+ options .TokenDiscovery ,
87
+ options .TokenDiscoveryCAHash ,
88
+ options .TokenDiscoverySkipCAHash ,
89
+ options .TLSBootstrapToken ,
90
+ options .TokenStr ,
91
+ options .CertificateKey ,
92
+ }
93
+ case "certs" :
94
+ flags = []string {
95
+ options .APIServerAdvertiseAddress ,
96
+ options .CfgPath ,
97
+ options .ControlPlane ,
98
+ options .NodeName ,
99
+ options .FileDiscovery ,
100
+ options .TokenDiscovery ,
101
+ options .TokenDiscoveryCAHash ,
102
+ options .TokenDiscoverySkipCAHash ,
103
+ options .TLSBootstrapToken ,
104
+ options .TokenStr ,
105
+ }
106
+ case "kubeconfig" :
107
+ flags = []string {
108
+ options .CfgPath ,
109
+ options .ControlPlane ,
110
+ options .FileDiscovery ,
111
+ options .TokenDiscovery ,
112
+ options .TokenDiscoveryCAHash ,
113
+ options .TokenDiscoverySkipCAHash ,
114
+ options .TLSBootstrapToken ,
115
+ options .TokenStr ,
116
+ options .CertificateKey ,
117
+ }
118
+ case "control-plane" :
119
+ flags = []string {
120
+ options .APIServerAdvertiseAddress ,
121
+ options .APIServerBindPort ,
122
+ options .CfgPath ,
123
+ options .ControlPlane ,
124
+ }
125
+ default :
126
+ flags = []string {}
78
127
}
79
128
return flags
80
129
}
@@ -106,16 +155,16 @@ func newControlPlanePrepareKubeconfigSubphase() workflow.Phase {
106
155
}
107
156
}
108
157
109
- func newControlPlanePrepareManifestsSubphases () workflow.Phase {
158
+ func newControlPlanePrepareControlPlaneSubphase () workflow.Phase {
110
159
return workflow.Phase {
111
160
Name : "control-plane" ,
112
161
Short : "Generates the manifests for the new control plane components" ,
113
- Run : runControlPlanePrepareManifestsSubphase , //NB. eventually in future we would like to break down this in sub phases for each component
114
- InheritFlags : getControlPlanePreparePhaseFlags ("manifests " ),
162
+ Run : runControlPlanePrepareControlPlaneSubphase , //NB. eventually in future we would like to break down this in sub phases for each component
163
+ InheritFlags : getControlPlanePreparePhaseFlags ("control-plane " ),
115
164
}
116
165
}
117
166
118
- func runControlPlanePrepareManifestsSubphase (c workflow.RunData ) error {
167
+ func runControlPlanePrepareControlPlaneSubphase (c workflow.RunData ) error {
119
168
data , ok := c .(JoinData )
120
169
if ! ok {
121
170
return errors .New ("control-plane-prepare phase invoked with an invalid data struct" )
0 commit comments