-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
kubeadm: mark-control-plane phase #70625
Conversation
@RA489: Reiterating the mentions to trigger a notification: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/release-note-none |
/priority important-soon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RA489 thank you a lot for finding time to work on this!
added some comments mostly about renames and camelCase, but this is a good start.
will get back to this when we merge the previous phase - kubeconfig.
cmd/kubeadm/app/cmd/init.go
Outdated
@@ -169,6 +168,8 @@ func NewCmdInit(out io.Writer) *cobra.Command { | |||
initRunner.AppendPhase(phases.NewControlPlanePhase()) | |||
initRunner.AppendPhase(phases.NewEtcdPhase()) | |||
initRunner.AppendPhase(phases.NewWaitControlPlanePhase()) | |||
initRunner.AppendPhase(phases.NewmarkcontrolplanePhase()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NewmarkcontrolplanePhase -> NewMarkControlPlanePhase
@@ -25,68 +25,65 @@ import ( | |||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options" | |||
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util" | |||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants" | |||
markmasterphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/markmaster" | |||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow" | |||
markcontrolplanephase "k8s.io/kubernetes/cmd/kubeadm/app/phases/markmaster" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should rename the file to markcontrolplane
to avoid the aliasing.
kubeadm alpha phase mark-master | ||
|
||
markcontrolplaneExample = normalizer.Examples(` | ||
# Run master markcontrolplane checks using a config file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applies control-plane label and taint to the current node, functionally equivalent to what is executed by kubeadm init.
|
||
markcontrolplaneExample = normalizer.Examples(` | ||
# Run master markcontrolplane checks using a config file. | ||
kubeadm init phase mark-controlplane --config config.yml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mark-control-plane
|
||
# Applies master label and taint to a specific node | ||
kubeadm alpha phase mark-master --node-name myNode | ||
kubeadm init phase mark-controlplane --node-name myNode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mark-control-plane
}, | ||
fmt.Println("[markcontrolplane] running markcontrolplane checks") | ||
var cfgPath string | ||
kubeConfigFile := kubeadmconstants.GetAdminKubeConfigPath() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please align the indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we define the kubeconfig dir that also respects dry run:
https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/cmd/init.go#L366
you can also expose KubeConfigDir() for the data object in this file too.
this line would end up something like:
kubeConfigFile := filepath.Join(data.KubeConfig() , kubeadmconstants.AdminKubeConfigFileName)
err = markmasterphase.MarkMaster(client, internalcfg.NodeRegistration.Name, internalcfg.NodeRegistration.Taints) | ||
kubeadmutil.CheckErr(err) | ||
}, | ||
fmt.Println("[markcontrolplane] running markcontrolplane checks") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[markcontrolplane] running markcontrolplane checks
->
[mark-control-plane] Running checks
fmt.Println("[markcontrolplane] running markcontrolplane checks") | ||
var cfgPath string | ||
kubeConfigFile := kubeadmconstants.GetAdminKubeConfigPath() | ||
kubeConfigFile = cmdutil.FindExistingKubeConfig(kubeConfigFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self: seems to me like we are not doing this in other places, where we should be doing it.
possibly best to move it in init.go
options.AddKubeConfigFlag(cmd.Flags(), &kubeConfigFile) | ||
cmd.Flags().StringVar(&cfgPath, "config", cfgPath, "Path to kubeadm config file. WARNING: Usage of a configuration file is experimental") | ||
cmd.Flags().StringVar(&cfg.NodeRegistration.Name, "node-name", cfg.NodeRegistration.Name, `The node name to which label and taints should apply`) | ||
if err := markmasterphase.MarkMaster(client, internalcfg.NodeRegistration.Name, internalcfg.NodeRegistration.Taints); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it's ok to rename the MarkMaster function to MarkControlPlane as part of this refector.
basically master->controlPlane
everywhere.
return cmd | ||
} | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add new line at end of file.
/assign @fabriziopandini |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RA489 thanks a lot for the update!
after this pass we are going to be close to LGTM
// NewMarkControlPlanePhase creates a kubeadm workflow phase that implements mark-controlplane checks. | ||
func NewMarkControlPlanePhase() workflow.Phase { | ||
return workflow.Phase{ | ||
Name: "markcontrolplane", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's name it like so for consistency with other phases:
mark-control-plane
func NewMarkControlPlanePhase() workflow.Phase { | ||
return workflow.Phase{ | ||
Name: "markcontrolplane", | ||
Short: "Run master markcontrolplane checks", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark a node as a control-plane
return workflow.Phase{ | ||
Name: "markcontrolplane", | ||
Short: "Run master markcontrolplane checks", | ||
Long: "Run master markcontrolplane checks, applies master label.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove Long:
here given Short fits on one line.
|
||
fmt.Println("[mark-control-plane] Running checks") | ||
var cfgPath string | ||
kubeConfigFile := filepath.Join(data.KubeConfig() , kubeadmconstants.AdminKubeConfigFileName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small whitespace problem.
./hack/update-gofmt.sh
might help with these.
return errors.New("mark-control-plane phase invoked with an invalid data struct") | ||
} | ||
|
||
fmt.Println("[mark-control-plane] Running checks") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's just remove this line.
// MarkMaster taints the master and sets the master label | ||
func MarkMaster(client clientset.Interface, masterName string, taints []v1.Taint) error { | ||
// MarkControlPlane taints the master and sets the master label | ||
func MarkControlPlane(client clientset.Interface, masterName string, taints []v1.Taint) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
masterName -> controlPlaneName
|
||
fmt.Printf("[markmaster] Marking the node %s as master by adding the label \"%s=''\"\n", masterName, constants.LabelNodeRoleMaster) | ||
fmt.Printf("[mark-control-plane] Marking the node %s as master by adding the label \"%s=''\"\n", masterName, constants.LabelNodeRoleMaster) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking the node %s as control-plane by adding the label
|
||
if taints != nil && len(taints) > 0 { | ||
taintStrs := []string{} | ||
for _, taint := range taints { | ||
taintStrs = append(taintStrs, taint.ToString()) | ||
} | ||
fmt.Printf("[markmaster] Marking the node %s as master by adding the taints %v\n", masterName, taintStrs) | ||
fmt.Printf("[mark-control-plane] Marking the node %s as master by adding the taints %v\n", masterName, taintStrs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking the node %s as a control-plane by adding the taints
/ok-to-test @RA489 as a helper, please make sure you have run these: and also include the ./docs changes after running: thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RA489 thanks for this PR! Well done!
Please fix test, address few small nits and then ping me again after removing WIP
|
||
var cfgPath string | ||
kubeConfigFile := filepath.Join(data.KubeConfig(), kubeadmconstants.AdminKubeConfigFileName) | ||
kubeConfigFile = cmdutil.FindExistingKubeConfig(kubeConfigFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to FindExistingKubeConfig
should be removed and instead we should use data.Kubeconfig
@neolit123 the call of FindExistingKubeConfig
should be removed by all phases, because it can make kubeadm use unexpected kubeconfig files while instead we need admin.conf.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ started a thread on slack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok we had a discussion about this - @RA489 please remove the FindExistingKubeConfig call and use:
kubeConfigFile := data.KubeConfigPath()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@neolit123 ok
if err != nil { | ||
return err | ||
} | ||
internalcfg, err := configutil.ConfigFileAndDefaultsToInternalConfig(cfgPath, data.Cfg()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to ConfigFileAndDefaultsToInternalConfig
is not necessary (it is already called by initData
). Please remove
You can pass data.Cfg()
directly to MarkControlPlane
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and | |||
limitations under the License. | |||
*/ | |||
|
|||
package markmaster | |||
package markcontrolplane |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please kindly rename also file and folder
@RA489 I guess build is failing because hack/update-bazel.sh should be run after renaming files |
the previous phase just merged and init has a small conflict. |
# Applies control-plane label and taint to the current node, functionally equivalent to what is executed by kubeadm init. | ||
kubeadm init phase mark-control-plane --config config.yml | ||
|
||
# Applies master label and taint to a specific node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it correct to change "master label" with "control-plane label"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RA489 Can you fix this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atoato88 ok
@RA489 it seems another rebase is necessary to fix bazel-build errors... |
we need to merge this today, ideally. |
@RA489 |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: RA489 If they are not already assigned, you can assign the PR to them by writing The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/close |
@neolit123: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@RA489: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
What type of PR is this?
This PR implement mark-control-plane phase in the kubeadm init workflow.
/kind feature
What this PR does / why we need it:
Ref kubernetes/kubeadm#1163
/sig cluster-lifecycle
@kubernetes/sig-cluster-lifecycle-pr-reviews
Release note:
NONE