Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

✨ Initialize JoinConfiguration if missing #234

Conversation

fabriziopandini
Copy link
Contributor

@fabriziopandini fabriziopandini commented Sep 17, 2019

What this PR does / why we need it:

  • If join configuration is missing, we are going to generate a default one.

Which issue(s) this PR fixes:
Fixes #213

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 17, 2019
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 17, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 17, 2019
@fabriziopandini fabriziopandini force-pushed the initialize-configobjects-if-missing branch from b41e9c2 to 6d6589b Compare September 17, 2019 16:04
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 17, 2019
@accepting
Copy link
Contributor

@fabriziopandini In our use cases, we use a template to generate bootstrap configs for all control plane machines. Hence, these configs all contains initconfiguration, clusterconfiguration and joinconfiguration. If adding the requirements in your PR, it will make the work of setting kubeadmconfig objects more manual.

@fabriziopandini
Copy link
Contributor Author

@accepting here a thread explaining why it was decided to make this change

@fabriziopandini fabriziopandini force-pushed the initialize-configobjects-if-missing branch from 6d6589b to d7fdceb Compare September 23, 2019 07:38
@chuckha
Copy link
Contributor

chuckha commented Sep 24, 2019

I'm really torn on this PR

I'm leaning towards not being restrictive to allow more use cases, but I'm concerned about how people are using this. I don't think I have enough information about what is more common, using duplicated configs across all machines or being specific about which machine will be the initial control plane and which will be a secondary control plane. I'll talk to some people this week and see if I can get some consensus on this.

Any additional thoughts are welcome.

Please see the associated issue for more details. The TL;DR is: Should we allow users to supply all configs to every machine and let the controller figure it out? or should we be prescriptive to prevent accidental user errors and nice error messages.

@fabriziopandini
Copy link
Contributor Author

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 24, 2019
@chuckha
Copy link
Contributor

chuckha commented Sep 24, 2019

For this PR can we have just the initializing a join configuration if one doesn't exist and leave the other checks out for now? That way our behavior doesn't change and we can close #213.

@SataQiu
Copy link
Contributor

SataQiu commented Sep 25, 2019

/retitle ✨ Initialize config objects if missing

@k8s-ci-robot k8s-ci-robot changed the title ✨ initialize config objects if missing ✨ Initialize config objects if missing Sep 25, 2019
Copy link
Contributor

@detiber detiber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit around adding an event when we cannot process an additional control plane Init, otherwise lgtm


//In case of join, ClusterConfiguration and InitConfiguration should not be defined by users
if config.Spec.ClusterConfiguration != nil || config.Spec.InitConfiguration != nil {
return ctrl.Result{}, errors.New("Control plane already exists for the cluster, KubeadmConfig objects with ClusterConfiguration or InitConfiguration can not be processed at this stage")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to also emit an event here as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we return an error here, it means the KubeadmConfig will be reconciled again using backoff. We probably don't want to return an error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked @fabriziopandini to not make these changes as they are controversial and reduce this PR to fix the original issue of #213

@fabriziopandini fabriziopandini force-pushed the initialize-configobjects-if-missing branch from d7fdceb to 4de256f Compare September 30, 2019 21:04
@fabriziopandini
Copy link
Contributor Author

@chuckha
Reduced the scope to

  • If join configuration is missing, we are going to generate a default one.

@fabriziopandini fabriziopandini changed the title ✨ Initialize config objects if missing ✨ Initialize JoinConfiguration if missing Sep 30, 2019
log.Info("Creating default JoinConfiguration")
config.Spec.JoinConfiguration = &kubeadmv1beta1.JoinConfiguration{}
if util.IsControlPlaneMachine(machine) {
config.Spec.JoinConfiguration.ControlPlane = &kubeadmv1beta1.JoinControlPlane{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be dependent on if it is a ControlPlane instance or a Worker Node instance?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you missed line 270's if check

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears I did :(

@chuckha
Copy link
Contributor

chuckha commented Oct 1, 2019

/hold cancel

looks good to me. assigning to @detiber in case I've misunderstood his comment

/assign @detiber

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 1, 2019
@detiber
Copy link
Contributor

detiber commented Oct 1, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 1, 2019
@k8s-ci-robot k8s-ci-robot merged commit 54a04d8 into kubernetes-retired:master Oct 1, 2019
@fabriziopandini fabriziopandini deleted the initialize-configobjects-if-missing branch October 10, 2019 07:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should not error if worker node does not have JoinConfiguration
7 participants