Skip to content

Use config file to join nodes to the cluster#616

Closed
aojea wants to merge 7 commits intokubernetes-sigs:masterfrom
aojea:kubeadmjoin
Closed

Use config file to join nodes to the cluster#616
aojea wants to merge 7 commits intokubernetes-sigs:masterfrom
aojea:kubeadmjoin

Conversation

@aojea
Copy link
Copy Markdown
Contributor

@aojea aojea commented Jun 14, 2019

This avoids having to write configuration files on runtime, however, seems that the control plane nodes can't use it

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 14, 2019
@k8s-ci-robot k8s-ci-robot requested review from amwat and neolit123 June 14, 2019 16:28
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 14, 2019
@aojea
Copy link
Copy Markdown
Contributor Author

aojea commented Jun 14, 2019

/assign @neolit123
/assign @BenTheElder

Copy link
Copy Markdown
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

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

thanks for the PR @aojea
aren't we already passing the main template with the --- separate different kubeadm config types to joining nodes?

it should also work for control-plane nodes, fine.

kubeletExtraArgs:
fail-swap-on: "false"
{{ if .APIAdvertiseAddress -}}
node-ip: "{{ .APIAdvertiseAddress }}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could you please explain why we need node-ip here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ipv6 needs it, otherwise Kubelet picks the ipv4

Copy link
Copy Markdown
Member

@neolit123 neolit123 Jun 14, 2019

Choose a reason for hiding this comment

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

understood.
would the kubelet long term always default to an ipv4 from the default interface...or would it be able to somehow pick a ipv6?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

IIRC the logic implemented in Kubernetes always defaults to the IPv4 address ... don´t think that´s a behavior that can change soon ... will add it to my backlog, it can be something interesting to implement though

// assume the latest API version, then fallback if the k8s version is too low
templateSource := ConfigTemplateBetaV2
if ver.LessThan(version.MustParseSemantic("v1.12.0")) {
templateSource = ConfigTemplateAlphaV2
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

did we drop the kind 1.11 tests already?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, they aren't running, also 1.15 is close to be ready... No strong feelings but we should move on sooner or later :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

SGTM

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We only did because one of the tests is broken and officially Kubernetes CI won't support it. We should make best effort to support feasible versions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I dropped the 1.11 in a separate commit, let me remove that commit and figure out the code for the v1alpha2 config files

// JoinConfigTemplate is the kubadm join config template
const JoinConfigTemplate = `# config generated by kind
# no-op entry that exists solely so it can be patched
apiVersion: kubeadm.k8s.io/{{ .KubedamAPI }}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IMO, the correct way is separate constants - JoinConfigTemplate<version>.
the API is v1betav2, but still not final.

but also we already have JoinConfiguration as part of the other config templates, which is there for the sake of being patchable from kustomize. isn't it already used when nodes are joining?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Joins are done with the command line, i took one option but I'm missing lot of context, appreciate any feedback and advice

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i think we can pass the same kubeadm.cfg to both init and join (with the multi-yaml doc; --- separated). i was under the impression we are already doing that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I abandoned that idea because I thought that will break the kubeadm join and it could simplify the join file creation since it needs fewer parameters, any way you're the expert here

}

if err = writeKubeadmJoinConfiguration(node, joinAddress); err != nil {
return errors.Wrapf(err, "failed to generate kubeadm join configuration")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

...the kubeadm JoinConfiguration

// get installed kubernetes version from the node image
kubeVersion, err := node.KubeVersion()
if err != nil {
return errors.Wrap(err, "failed to get kubernetes version from node")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

kubernetes -> Kubernetes

@aojea
Copy link
Copy Markdown
Contributor Author

aojea commented Jun 14, 2019

seems join configuration for v1.12 needs a different template, it fails with

16:38:43.002425 435 interface.go:244] Interface \"eth0\" has 1 addresses :[172.17.0.3/16].\nI0614 16:38:43.002581 435 interface.go:211] Checking addr 172.17.0.3/16.\nI0614 16:38:43.003448 435 interface.go:218] IP found 172.17.0.3\nI0614 16:38:43.003517 435 interface.go:250] Found valid IPv4 address 172.17.0.3 for interface \"eth0\".\nI0614 16:38:43.003609 435 interface.go:395] Found active IP 172.17.0.3 \n[tlsBootstrapToken: Invalid value: \"\": the bootstrap token is invalid, discovery: Invalid value: \"\": discoveryToken or discoveryFile must be set]"

@neolit123
Copy link
Copy Markdown
Member

neolit123 commented Jun 14, 2019

it needs a token:

apiVersion: kubeadm.k8s.io/v1alpha3
kind: JoinConfiguration
token: "{{ .Token }}"
apiServerEndpoint: ........
discoveryTokenUnsafeSkipCAVerification: true

apiVersion: kubeadm.k8s.io/v1beta1
kind: JoinConfiguration
discovery:
  bootstrapToken:
    apiServerEndpoint: ........
    token: "{{ .Token }}"
    unsafeSkipCAVerification: true

apiVersion: kubeadm.k8s.io/v1beta2
kind: JoinConfiguration
discovery:
  bootstrapToken:
    apiServerEndpoint: ........
    token: "{{ .Token }}"
    unsafeSkipCAVerification: true

// increase verbosity for debugging
"--v=6",
"--cri-socket=/run/containerd/containerd.sock",
"--config=/kind/kubeadm-join.conf",
Copy link
Copy Markdown
Member

@neolit123 neolit123 Jun 14, 2019

Choose a reason for hiding this comment

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

"--ignore-preflight-errors=all",
// increase verbosity for debugging
"--v=6",
"--cri-socket=/run/containerd/containerd.sock",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no need to pass if present in config.

node-ip: "{{ .NodeAddress }}"
discovery:
bootstrapToken:
apiServerEndpoint: "{{ .JoinAddress }}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

for v1alpha3 it's different:
https://github.com/kubernetes/kubernetes/blob/release-1.12/cmd/kubeadm/app/apis/kubeadm/v1alpha3/types.go#L299-L302

(thus the recommendation to have separate constants)

for v1beta* this seems OK.

// TODO(bentheelder): limit the set of acceptable errors
"--ignore-preflight-errors=all",
// increase verbosity for debugging
// increase verbosity for debug
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

seems I cleaned more than necessary 😓

Copy link
Copy Markdown
Member

@BenTheElder BenTheElder left a comment

Choose a reason for hiding this comment

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

Please do not unnecessarily break v1.11.X support.
Also:

  • there should be a single config template per version
  • the config file should be generated per node but with the same mechanism
  • this should correctly handle each node's Kubernetes version

@BenTheElder BenTheElder dismissed their stale review June 19, 2019 07:26

resolved

@BenTheElder
Copy link
Copy Markdown
Member

I want to take another pass when I'm a little more awake but this looks right now and like a great improvement, thank you!

@BenTheElder BenTheElder changed the title WIP Use config file to join nodes to the cluster Use config file to join nodes to the cluster Jun 19, 2019
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 19, 2019
@BenTheElder
Copy link
Copy Markdown
Member

failing to join workers locally with 1.11, investigating...
/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 Jun 19, 2019
@BenTheElder
Copy link
Copy Markdown
Member

v1.11 doesn't have kubernetes/kubernetes@9109e62 🙃
will fix in a follow-up
/hold cancel

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jun 19, 2019
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aojea, BenTheElder

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 19, 2019
return err
}
if len(workers) > 0 {
kubeadmClusterConfig.ControlPlane = false
Copy link
Copy Markdown
Member

@BenTheElder BenTheElder Jun 19, 2019

Choose a reason for hiding this comment

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

this can cause all config templates to be controlplane=false

that's because while the function calls will get a pass by value of this struct, they copy from the same shared instance of the struct and we assign to it here

I'm fixing this in the patch to fix v1.11

@BenTheElder
Copy link
Copy Markdown
Member

/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 Jun 19, 2019
@BenTheElder
Copy link
Copy Markdown
Member

since this hadn't merged by the time I filed the follow up, I'm just including these commits in #632 😅

@BenTheElder
Copy link
Copy Markdown
Member

included in #632

thank you!!

@BenTheElder BenTheElder mentioned this pull request Jun 19, 2019
@aojea aojea deleted the kubeadmjoin branch August 9, 2020 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", 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.

4 participants