Skip to content
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

remove k8s.io/kubernetes dependency from yurtctl join/reset #697

Merged

Conversation

rambohe-ch
Copy link
Member

@rambohe-ch rambohe-ch commented Dec 27, 2021

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line:
/kind bug
/kind documentation
/kind enhancement
/kind good-first-issue
/kind feature
/kind question
/kind design
/sig ai
/sig iot
/sig network
/sig storage
/sig storage

/kind enhancement

What this PR does / why we need it:

Remove k8s.io/kubernetes dependency from yurtctl join and yurtctl reset.

1. feature update points:
  • In order to reduce the complexity of yurtctl join command and integrate with sealer, join ControlPlane node feature is removed, so yurtctl join can only join cloud or edge worker node. and end user should use yurtctl init to install ControlPlane through sealer.
  • yurtctl reset can only reset worker node that joined by yurtctl join command. if end user use yurtctl reset to reset other kind of nodes, the result maybe unknown.
2. yurtctl join command
  • implementation update points:

    • dependency on kubeadm copied from k8s.io/kubernetes/cmd/kubeadm to github.com/openyurtio/openyurt/pkg/yurtctl/kubernetes. so KubeletConfiguration has been left.

    • command line parameter:

      • In order to reduce the complexity of input parameter, kubeadmapi.JoinConfiguration and kubeadmapi.InitConfiguration have been removed. only command line parameters are supported in yurtctl join.
      • add YurtJoinData interface.
      • apiServerAddress and token parameter for yurtctl join command
      • organizations parameter is added for adding customized Organizations info into yurthub client certificate.
      • node-labels parameter is added for adding customized labels for worker node.
  • prepare phase(pkg/yurtctl/cmd/join/phases/prepage.go):

    • kubelet service conf file(/etc/systemd/system/kubelet.service.d/10-kubeadm.conf) is the same of cloud and edge worker node, so merge EdgeKubeletUnitConfig and CloudKubeletUnitConfig into KubeletUnitConfig
    • add /etc/kubernetes/kubelet.conf file preparation.
    • add /etc/kubernetes/pki/ca.crt file preparation.
  • preflight phase(pkg/yurtctl/cmd/join/phases/preflight.go)

    • add /etc/kubernetes/kubelet.conf and /etc/kubernetes/pki/ca.crt file existing check
    • add pause and yurthub image pull check
  • joinNode phase(pkg/yurtctl/cmd/join/phases/joinnode.go)

    • merge joinCloudNode/joindEdgeNode into joinNode because the join routine is the same except the WorkingMode parameter of yurthub.
    • openyurt.io/is-edge-worker label is added as kubelet command line parameter, so after kubelet startup, only CRISocket annotation is need to patch to node.
    • because kubelet use HTTP to connect yurthub, so rotate-certificates=faluse is added to kubelet command line parameter.
    • use templates.SubsituteTemplate to populate yurthub yaml, so the format of fields in YurthubTemplate are modified. for example: from __workingMode__ to {{.workingMode}}
  • postCheck phase(pkg/yurtctl/cmd/join/phases/postcheck.go)

    • remove nodeLabel patch.
3. yurtctl reset command
  • add resetData interface
  • add preflight phase
  • separate cleanfile phase into cleanupnode and cleanyurtfile phases.

Which issue(s) this PR fixes:

Fixes #671

Special notes for your reviewer:

Does this PR introduce a user-facing change?


other Note

@openyurt-bot
Copy link
Collaborator

@rambohe-ch: GitHub didn't allow me to assign the following users: your_reviewer.

Note that only openyurtio members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line:
/kind bug
/kind documentation
/kind enhancement
/kind good-first-issue
/kind feature
/kind question
/kind design
/sig ai
/sig iot
/sig network
/sig storage
/sig storage

/kind enhancement

What this PR does / why we need it:

Remove k8s.io/kubernetes dependency from yurtctl join and yurtctl reset.

Which issue(s) this PR fixes:

Fixes #671

Special notes for your reviewer:

Does this PR introduce a user-facing change?


other Note

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.

@openyurt-bot openyurt-bot added the kind/enhancement kind/enhancement label Dec 27, 2021
@rambohe-ch
Copy link
Member Author

@openyurt-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rambohe-ch

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

@rambohe-ch
Copy link
Member Author

@neo502721

@rambohe-ch rambohe-ch force-pushed the refactor-yurtctl-join-reset branch 2 times, most recently from 13674d6 to 34fb4e6 Compare December 28, 2021 06:01
@adamzhoul
Copy link
Member

hi @rambohe-ch
I see this is a big and important update. we may take a while to fully understand.
can you have a simple description of what you did? so can help us understand more.
something like :

  1. copy k8s code to dir yurtctl/kubernetes
  2. merge joinCloudNode/joindEdgeNode into one( and I see you simplify the implantation can you have some introduction ?)
  3. ...

PS: can some change in node can be implantation in node-servant? to make the update to kubelet/yurthub keep same.

very thanks.

@rambohe-ch
Copy link
Member Author

hi @rambohe-ch I see this is a big and important update. we may take a while to fully understand. can you have a simple description of what you did? so can help us understand more. something like :

  1. copy k8s code to dir yurtctl/kubernetes
  2. merge joinCloudNode/joindEdgeNode into one( and I see you simplify the implantation can you have some introduction ?)
  3. ...

PS: can some change in node can be implantation in node-servant? to make the update to kubelet/yurthub keep same.

very thanks.

@adamzhoul Thanks for your suggestions. i

hi @rambohe-ch I see this is a big and important update. we may take a while to fully understand. can you have a simple description of what you did? so can help us understand more. something like :

  1. copy k8s code to dir yurtctl/kubernetes
  2. merge joinCloudNode/joindEdgeNode into one( and I see you simplify the implantation can you have some introduction ?)
  3. ...

PS: can some change in node can be implantation in node-servant? to make the update to kubelet/yurthub keep same.

very thanks.

@adamzhoul Thanks for your suggestions. i have updated the pull request messages.

}

if !r.ForceReset() {
fmt.Println("[reset] WARNING: Changes made to this host by 'kubeadm init' or 'kubeadm join' will be reverted.")
Copy link
Member

Choose a reason for hiding this comment

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

why fmt not klog?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@rambohe-ch rambohe-ch force-pushed the refactor-yurtctl-join-reset branch from 34fb4e6 to b0cd9dc Compare December 31, 2021 01:42
@adamzhoul
Copy link
Member

/lgtm

@openyurt-bot openyurt-bot added the lgtm lgtm label Dec 31, 2021
@openyurt-bot openyurt-bot merged commit bebc077 into openyurtio:master Dec 31, 2021
MrGirl pushed a commit to MrGirl/openyurt that referenced this pull request Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature request]Refactor yurtctl join to remove k8s.io/kubernetes dependency
3 participants