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

Allow user to use arbitraty userdata #651

Closed
wants to merge 3 commits into from

Conversation

enxebre
Copy link
Member

@enxebre enxebre commented Mar 13, 2019

What this PR does / why we need it:

This PR removes tight coupling between machine resource and kubeadm while keeping the current behaviour pristine.
This allows flexibility for the API consumers to support broader use cases by injecting arbitrary userdata into a secret optionally referenced by the spec.
While being a fairly scoped change this would favour adoption of the project extremely.

Related:
kubernetes-sigs/cluster-api-provider-azure#135
kubernetes-sigs/cluster-api#721 and https://docs.google.com/document/d/1pzXtwYWRsOzq5Ftu03O5FcFAlQE26nD3bjYBPenbhjg/edit#heading=h.etxqa0k5waej

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:


@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 13, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: enxebre
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: ingvagabund

If they are not already assigned, you can assign the PR to them by writing /assign @ingvagabund in a comment when ready.

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 the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 13, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @enxebre. Thanks for your PR.

I'm waiting for a kubernetes-sigs or kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 13, 2019
@enxebre
Copy link
Member Author

enxebre commented Mar 13, 2019

@chuckha
Copy link
Contributor

chuckha commented Mar 13, 2019

where is the branch on your fork to check this out? I can't seem to locate a branch named allow-user-userdata

edit: 🤦‍♂️

@@ -90,3 +93,21 @@ func funcMap(funcs map[string]interface{}) template.FuncMap {

return funcMap
}

func GetUserDataFromSecret(machine *actuators.MachineScope) (string, error) {

Choose a reason for hiding this comment

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

Is it possible to create a unit test case for this function?

Copy link
Contributor

@chuckha chuckha left a comment

Choose a reason for hiding this comment

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

Before I get too far into code reviewing let me make sure I understand what this is doing:

This allows someone to add their own script to be run at node-boot time. It's not in addition to the default installation, but entirely replaces it.

Can you outline what your use case is so I can better understand where you're coming from?

@@ -90,3 +93,21 @@ func funcMap(funcs map[string]interface{}) template.FuncMap {

return funcMap
}

func GetUserDataFromSecret(machine *actuators.MachineScope) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A couple of suggestions and questions:

  • flip around the nil check and return early if the UserDataSecret is nil
  • the userData var is unnecessary, directly encode and return at line 105 and remove the else statement
  • why is it an error if the secret doesn't contain the userData key? My expectation would be to log an error and return nothing
  • please add godoc and a test to this function

@@ -158,15 +158,73 @@ func (s *Service) createInstance(machine *actuators.MachineScope, bootstrapToken
}

// apply values based on the role of the machine
Copy link
Contributor

Choose a reason for hiding this comment

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

is this comment still valid?

func GetUserDataFromSecret(machine *actuators.MachineScope) (string, error) {
if machine.MachineConfig.UserDataSecret != nil {
userData := []byte{}
userDataSecret, err := machine.CoreClient.Secrets(machine.Namespace()).Get(machine.MachineConfig.UserDataSecret.Name, metav1.GetOptions{})
Copy link
Contributor

@ashish-amarnath ashish-amarnath Mar 13, 2019

Choose a reason for hiding this comment

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

How will this secret be created?
If the secret doesn't exist, the machine reconciliation will not make progress until the secret is created. Correct?

Copy link
Member Author

@enxebre enxebre Mar 13, 2019

Choose a reason for hiding this comment

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

@enxebre
Copy link
Member Author

enxebre commented Mar 13, 2019

Before I get too far into code reviewing let me make sure I understand what this is doing:

This allows someone to add their own script to be run at node-boot time. It's not in addition to the default installation, but entirely replaces it.

Can you outline what your use case is so I can better understand where you're coming from?

Hey @chuckha for our use case in OpenShift we have a clearer separation between machine (hardware) and software/kubelet. The software/kubelet is managed orthogonally by a different component.
We pre-populate a secret with an ignition config containing the kubelet configuration (among other things) which then is fetched via the userdata API field https://github.com/openshift/cluster-api-provider-aws/blob/master/pkg/actuators/machine/actuator.go#L203-L214.
Then the kubelet and software upgrades/lifecycle management is oblivious to this API. Please let me know if more context is needed

@ncdc
Copy link
Contributor

ncdc commented Mar 13, 2019

As discussed in today's Cluster API meeting, we'd like to see a document outlining requirements and use cases. Going to mark this on hold for now. Thanks!

/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 Mar 13, 2019
@enxebre enxebre changed the title Allow user userdata Allow user to use arbitraty userdata Mar 13, 2019
@enxebre
Copy link
Member Author

enxebre commented Mar 13, 2019

As discussed in today's Cluster API meeting, we'd like to see a document outlining requirements and use cases. Going to mark this on hold for now. Thanks!

Unfortunately attending the meeting is not always feasible being in CET. @ncdc I can't see any action item in the meeting notes https://docs.google.com/document/d/1Ys-DOR5UsgbMEeciuG0HOgDQc8kZsaWIWJeKJ1-UfbY/edit#heading=h.h3b651pv3rlt I'm happy to get some doc in place otherwise.

This relates to kubernetes-sigs/cluster-api#721
The case this PR is adding is allowing the user to put arbitrary userdata in machines

@ncdc
Copy link
Contributor

ncdc commented Mar 13, 2019

@enxebre understood about the time zone issue. The relevant section in the meeting notes is Ignition support - node bootstrap commonalities between all providers?, specifically the part about doing a design doc.

@ncdc
Copy link
Contributor

ncdc commented Mar 13, 2019

We would like to go through the design process to come up with something that works well for everyone, and would like adequate time to review/comment/revise etc.

@k8s-ci-robot
Copy link
Contributor

@enxebre: PR needs rebase.

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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 27, 2019
@ncdc
Copy link
Contributor

ncdc commented Jun 24, 2019

As part of the Cluster API v1alpha2 milestone that we just started working on, we're separating bootstrapping from infrastructure provisioning, and you'll be able to bring your own user data. As such, I'm going to close this in favor of that effort.

/close

@k8s-ci-robot
Copy link
Contributor

@ncdc: Closed this PR.

In response to this:

As part of the Cluster API v1alpha2 milestone that we just started working on, we're separating bootstrapping from infrastructure provisioning, and you'll be able to bring your own user data. As such, I'm going to close this in favor of that effort.

/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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.

6 participants