-
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: graduate control plane join phase #73452
kubeadm: graduate control plane join phase #73452
Conversation
Hi @RA489. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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 |
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.
Thanks @RA489
/ok-to-test
/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.
@neolit123 rebased PTAL |
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, i've added some comments.
this is progressing good.
func NewControlPlaneJoinPhase() workflow.Phase { | ||
return workflow.Phase{ | ||
Name: "control-plane-join", | ||
Short: "Prepares the machine to join a control plane.", |
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.
Joins a machine as a control plane instance
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.
done
} | ||
|
||
// NewControlPlaneJoinPhase creates a kubeadm workflow phase that implements marking the new node as master and update the cluster status | ||
// with information about current 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.
change to:
NewControlPlaneJoinPhase creates a kubeadm workflow phase that implements joining a machine as a control plane instance
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.
done
Phases: []workflow.Phase{ | ||
{ | ||
Name: "all", | ||
Short: "Generates all static Pod manifest files", |
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.
Joins a machine as a control plane instance
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.
done
}, | ||
newControlPlaneJoinSubphase(kubeadmconstants.KubeAPIServer), | ||
newControlPlaneJoinSubphase(kubeadmconstants.KubeControllerManager), | ||
newControlPlaneJoinSubphase(kubeadmconstants.KubeScheduler), |
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.
@fabriziopandini are you OK with this ordering of sub-phases or should we create a "control-plane" subphase that holds these 3?
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 creation of static manifest should not be part of control-plane-join
, because already implemented in the control-plane-prepare
phase (as documented in kubernetes/kubeadm#1204).
That means that the three sub phases above can go away toghether with the related code ( runControlPlaneJoinComponentSubphase
method, controlPlanePhaseProperties
struct, getPhaseDescription
method)
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.
@fabriziopandini removed the three subphases and its related codes
} | ||
} | ||
|
||
func newMarkControlPlaneSubphases() workflow.Phase { |
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.
newMarkControlPlaneSubphase
without the s
at the end?
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.
done
return workflow.Phase{ | ||
Name: "mark-control-plane", | ||
Short: "Mark a node as a control-plane", | ||
Run: runMarkControlPlanePhaseLocal, |
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.
try removing Local
from the function name.
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.
done
return nil | ||
} | ||
|
||
func runMarkControlPlanePhaseLocal(c workflow.RunData) 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.
try removing Local
from the name here.
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.
done
return workflow.Phase{ | ||
Name: controlPlanePhaseProperties[component].name, | ||
Short: controlPlanePhaseProperties[component].short, | ||
Run: runControlPlaneJoinSubphase(component), |
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.
rename this to runControlPlaneJoinComponentSubphase
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.
removed because it is already implemented in control-plane-prepare phase
return nil | ||
} | ||
|
||
func runControlPlaneJoinSubphase(component string) func(c workflow.RunData) 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.
rename this to runControlPlaneJoinComponentSubphase
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.
removed because it is already implemented in control-plane-prepare phase
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.
Thanks @RA489 !
This is a huge step in the right direction, but we need to figure a couple of details here.
cmd/kubeadm/app/cmd/join.go
Outdated
|
||
return nil | ||
// KubeConfigPath returns the path to the kubeconfig file to use for connecting to Kubernetes | ||
func (j *joinData) KubeConfigPath() string { |
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.
Why do we need this one? Where is it used?
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.
it is used in the function showControlPlaneJoinCommand in updated PR
cmd/kubeadm/app/cmd/join.go
Outdated
return nil | ||
// KubeConfigPath returns the path to the kubeconfig file to use for connecting to Kubernetes | ||
func (j *joinData) KubeConfigPath() string { | ||
j.kubeconfigPath = filepath.Join(kubeadmconstants.KubernetesDir, 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.
If we are going to keep this func, let's at least not reinvent kubeadmconstants.GetAdminKubeConfigPath()
. Also, I bet, that this needs to be conditioned and executed only if j.kubeconfigPath
is empty.
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.
done
} | ||
|
||
// Skip if this is not a control plane | ||
if data.Cfg().ControlPlane == 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.
Now this concerns me kind of indirectly. If I am not mistaken, data.Cfg().ControlPlane
is going to be different from nil
only if --experimental-control-plane
is specified at the command line or it's filled in the config file. Hence, if the is no config file, the UX is going to be a bit odd, because we cannot execute the control-plane-join phase without the above flag at the command line.
The mandatory command line without config file would look something like this:
kubeadm join --experimental-control-plane phase control-plane-join ...
I believe, that we need to fix this.
@fabriziopandini @neolit123 WDYT?
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, this is the case, but as @fabriziopandini pointed out this is already taken care by the control plane prepare phase (and needs the flag if no config file is provided).
return errors.New("control-plane-join phase invoked with an invalid data struct") | ||
} | ||
|
||
kubeConfigFile := filepath.Join(kubeadmconstants.KubernetesDir, 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.
Actually, it's even more complicated than that. The user may supply kubeconfig file in data.Cfg().Discovery.File.KubeConfigPath
or via the --discovery-file
command line switch. In that case we need to take those into account too.
@neolit123 @fabriziopandini WDYT?
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!
The overall approach looks fine, but some changes are required before moving on with this effort:
- creating manifest is out of the scope of this PR/this phases
- all the code currently in Run should find a new home after refactor
If something is not clear, let me know!
cmd/kubeadm/app/cmd/join.go
Outdated
return nil | ||
// KubeConfigPath returns the path to the kubeconfig file to use for connecting to Kubernetes | ||
func (j *joinData) KubeConfigPath() string { | ||
j.kubeconfigPath = filepath.Join(kubeadmconstants.KubernetesDir, 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.
Might be I'm missing something, but I don't understand why we should manage joinData. kubeconfigPath
when this is always set to a constant value...
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.
it is called in showControlPlaneJoinCommand function
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.
might be i am missing something but i need it in showControlPlaneJoinCommand in updated PR
}, | ||
newControlPlaneJoinSubphase(kubeadmconstants.KubeAPIServer), | ||
newControlPlaneJoinSubphase(kubeadmconstants.KubeControllerManager), | ||
newControlPlaneJoinSubphase(kubeadmconstants.KubeScheduler), |
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 creation of static manifest should not be part of control-plane-join
, because already implemented in the control-plane-prepare
phase (as documented in kubernetes/kubeadm#1204).
That means that the three sub phases above can go away toghether with the related code ( runControlPlaneJoinComponentSubphase
method, controlPlanePhaseProperties
struct, getPhaseDescription
method)
@fabriziopandini updated the PR PTAL. |
/test pull-kubernetes-integration |
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 being so collaborative in addressing comments!
Few nits and one little misunderstanding to be addressed on the management of the final error, and then this is ready for lgtm
return errors.New("control-plane-join phase invoked with an invalid data struct") | ||
} | ||
|
||
kubeConfigFile := filepath.Join(kubeadmconstants.KubernetesDir, 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.
I was forgetting the addition of the --kubeconfig
flag, please change this into
kubeConfigFile := j.KubeConfigFile()
(the same apply to all the other subphases)
@fabriziopandini Thanks for reviewing! I will update your suggestions ASAP. |
/test pull-kubernetes-e2e-gce |
@fabriziopandini updated the PR as per your suggestion. Please let me know if anything missed incorporating. Thanks! |
/test pull-kubernetes-integration |
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
I'm trying to test your changes but when I execute kubeadm join
I got
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x13d2003]
goroutine 1 [running]:
k8s.io/kubernetes/cmd/kubeadm/app/cmd.NewCmdJoin.func1(0xc0001bef00, 0xc0000aaff0, 0x1, 0x5)
cmd/kubeadm/app/cmd/join.go:165 +0xc3
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).execute(0xc0001bef00, 0xc0000aafa0, 0x5, 0x5, 0xc0001bef00, 0xc0000aafa0)
vendor/github.com/spf13/cobra/command.go:760 +0x2cc
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc0003a0280, 0xc0000caa00, 0xc0003a1180, 0xc00012c0a0)
vendor/github.com/spf13/cobra/command.go:846 +0x2fd
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).Execute(0xc0003a0280, 0xc00000c010, 0x1904b00)
vendor/github.com/spf13/cobra/command.go:794 +0x2b
k8s.io/kubernetes/cmd/kubeadm/app.Run(0xc000084180, 0x960)
cmd/kubeadm/app/kubeadm.go:50 +0x202
main.main()
cmd/kubeadm/kubeadm.go:29 +0x33
Could you kindly check?
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 Looks great!
I have tested both join worker and join control-plane with phases, thank you to all the people who contributed to this effort!
/approve
@neolit123 @ereslibre @rosti could you kindly give final check + lgtm
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.
Thank you! Final nit to keep structs as small as possible with only the attributes they need, and almost ready for LGTM.
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.
Thanks @RA489 !
We are on the final stretch here.
@RA489 please address the latest comments and mark the conversations as resolved (there is a button under each one). if this PR can be merged this week, great, as this will give us more time for auditing. |
All the comments seems to be addressed! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fabriziopandini, RA489 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 |
What this PR does / why we need it:
Graduate control plane join phase
Which issue(s) this PR fixes:
Refs kubernetes/kubeadm#1204
Does this PR introduce a user-facing change?:
NONE
/kind feature