-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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 WaitForAllControlPlaneComponents to Beta #129620
base: master
Are you sure you want to change the base?
kubeadm: graduate WaitForAllControlPlaneComponents to Beta #129620
Conversation
/triage accepted |
/hold for review |
i believe we do have users that use the scheduler --config option and have no flags in the scheduler manifest. for those users this new logic will use the default address/port. as far as i can tell there is no way to set the --secrure-port and --bind-address as fields in the KubeSchedulerConfiguration? |
there are some really messy circular dependencies going on. will try to debug more tomorrow or later this week.. |
1a1451a
to
3a74d70
Compare
3a74d70
to
d70fa87
Compare
reworked the logic to something much cleaner. |
d70fa87
to
de6fa77
Compare
latest e2e test runs are green. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hashim21223445, neolit123 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 |
de6fa77
to
41a4b59
Compare
- Set the feature gate to Beta and enabled by default. - Make sure that the source of truth for which address/port to use for a component health check comes from the respective component static Pod manifest. That is done to comply with any user --patches that are applied on top of the ClusterConfiguration.
41a4b59
to
8dfaec6
Compare
/cc @HirazawaUi |
|
||
// getControlPlaneComponents reads the static Pods of control plane components | ||
// and returns a slice of 'controlPlaneComponent'. | ||
func getControlPlaneComponents(podMap map[string]*v1.Pod, addressAPIServer string) ([]controlPlaneComponent, 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.
It seems that some duplicate code can be omitted.
func getControlPlaneComponents(podMap map[string]*v1.Pod, addressAPIServer string) ([]controlPlaneComponent, error) {
var (
// By default kubeadm deploys the kube-controller-manager and kube-scheduler
// with --bind-address=127.0.0.1. This should match get{Scheduler|ControllerManager}Command().
addressKCM = "127.0.0.1"
addressScheduler = "127.0.0.1"
portAPIServer = fmt.Sprintf("%d", constants.KubeAPIServerPort)
portKCM = fmt.Sprintf("%d", constants.KubeControllerManagerPort)
portScheduler = fmt.Sprintf("%d", constants.KubeSchedulerPort)
errs []error
result []controlPlaneComponent
)
type componentConfig struct {
name string
podKey string
args []string
defaultAddr string
defaultPort string
endpoint string
}
components := []componentConfig{
{
name: "kube-apiserver",
podKey: constants.KubeAPIServer,
args: []string{argAdvertiseAddress, argPort},
defaultAddr: addressAPIServer,
defaultPort: portAPIServer,
endpoint: endpointLivez,
},
{
name: "kube-controller-manager",
podKey: constants.KubeControllerManager,
args: []string{argBindAddress, argPort},
defaultAddr: addressKCM,
defaultPort: portKCM,
endpoint: endpointHealthz,
},
{
name: "kube-scheduler",
podKey: constants.KubeScheduler,
args: []string{argBindAddress, argPort},
defaultAddr: addressScheduler,
defaultPort: portScheduler,
endpoint: endpointLivez,
},
}
for _, component := range components {
address, port := component.defaultAddr, component.defaultPort
values, err := getControlPlaneComponentAddressAndPort(
podMap[component.podKey],
component.podKey,
component.args,
)
if err != nil {
errs = append(errs, err)
}
if len(values[0]) != 0 {
address = values[0]
}
if len(values[1]) != 0 {
port = values[1]
}
result = append(result, controlPlaneComponent{
name: component.name,
url: fmt.Sprintf("https://%s/%s", net.JoinHostPort(address, port), component.endpoint),
})
}
if len(errs) > 0 {
return nil, utilerrors.NewAggregate(errs)
}
return result, 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 like this, i will update to use it like that.
if err := waiter.WaitForControlPlaneComponents(&initCfg.ClusterConfiguration, | ||
pods, err := staticpodutil.ReadMultipleStaticPodsFromDisk(data.ManifestDir(), | ||
constants.ControlPlaneComponents...) | ||
if 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.
Would it be better if we make kubeadm join
provide the same error output as kubeadm init
here? And make handleError
a utility function.
ref:
kubernetes/cmd/kubeadm/app/cmd/phases/init/waitcontrolplane.go
Lines 102 to 113 in 0caa36c
handleError := func(err error) error { | |
context := struct { | |
Error string | |
Socket string | |
}{ | |
Error: fmt.Sprintf("%v", err), | |
Socket: data.Cfg().NodeRegistration.CRISocket, | |
} | |
kubeletFailTempl.Execute(data.OutputWriter(), context) | |
return errors.New("could not initialize a Kubernetes cluster") | |
} |
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 that's not a bad idea, but probably should be done in a separate PR after this one merges. you can log an issue in k/kubedam so that we don't forget. thanks
What type of PR is this?
/kind feature
What this PR does / why we need it:
of the ClusterConfiguration.
Which issue(s) this PR fixes:
xref
Special notes for your reviewer:
first commit fixes circular dependency problems. check the commit message.Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: