-
Notifications
You must be signed in to change notification settings - Fork 442
Allow user userdata #135
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 userdata #135
Conversation
Welcome @enxebre! |
@enxebre: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: enxebre If they are not already assigned, you can assign the PR to them by writing 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 |
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 Once the patch is verified, the new status will be reflected by the 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. |
@@ -138,7 +141,34 @@ func (s *Service) MachineExists(machine *actuators.MachineScope) (bool, error) { | |||
return vm != nil, nil | |||
} | |||
|
|||
func getUserDataFromSecret(machine *actuators.MachineScope) (string, error) { | |||
if machine.MachineConfig.UserDataSecret != 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.
You could reduce the indentation by returning early here.
} else { | ||
return "", fmt.Errorf("secret %q does not have field %q", machine.MachineConfig.UserDataSecret.Name, "userData") | ||
} | ||
encodedUserData := base64.StdEncoding.EncodeToString(userData) |
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.
nit: drop the temporary, return base64.StdEncoding.EncodeToString(userData), nil
.
func (s *Service) getVMStartupScript(machine *actuators.MachineScope, bootstrapToken string) (string, 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.
nit; drop the blank line.
|
||
userData, err := getUserDataFromSecret(machine) | ||
if err != nil { | ||
return "", errors.Errorf("failed getting userData from secret %v", err) |
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.
Not sure what the convention is here, but do we separate error message with a preceding :
?
On hold, echoing @ncdc's request for a design doc/justification (ref: kubernetes-sigs/cluster-api-provider-aws#651 (comment)) /hold |
@@ -41,6 +42,10 @@ type AzureMachineProviderSpec struct { | |||
OSDisk OSDisk `json:"osDisk"` | |||
SSHPublicKey string `json:"sshPublicKey"` | |||
SSHPrivateKey string `json:"sshPrivateKey"` | |||
// UserDataSecret contains a local reference to a secret that contains the | |||
// UserData to apply to the instance |
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.
// UserData to apply to the instance | |
// UserData to apply to the instance. |
scope, err := actuators.NewMachineScope(actuators.MachineScopeParams{Machine: machine, Cluster: cluster, Client: a.client}) | ||
coreClient, bootstrapErr := a.coreV1Client(cluster) | ||
if bootstrapErr != nil { | ||
return errors.Wrapf(bootstrapErr, "failed to retrieve corev1 client for cluster %q", cluster.Name) |
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.
return errors.Wrapf(bootstrapErr, "failed to retrieve corev1 client for cluster %q", cluster.Name) | |
return errors.Wrapf(bootstrapErr, "failed to retrieve corev1 client for cluster %s", cluster.Name) |
@@ -20,6 +20,7 @@ import ( | |||
"github.com/pkg/errors" | |||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | |||
"k8s.io/apimachinery/pkg/runtime" | |||
v1 "k8s.io/client-go/kubernetes/typed/core/v1" |
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.
v1 "k8s.io/client-go/kubernetes/typed/core/v1" | |
v1 "corev1 "k8s.io/api/core/v1" |
userData := []byte{} | ||
userDataSecret, err := machine.CoreClient.Secrets(machine.Namespace()).Get(machine.MachineConfig.UserDataSecret.Name, metav1.GetOptions{}) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to get userData secret %q", machine.MachineConfig.UserDataSecret.Name) |
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.
s/%q/%s
|
||
userData, err := getUserDataFromSecret(machine) | ||
if err != nil { | ||
return "", errors.Errorf("failed getting userData from secret %v", err) |
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.
return "", errors.Errorf("failed getting userData from secret %v", err) | |
return "", errors.Wrap(err, "failed getting userData from secret") |
@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. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle stale |
This ties in closely to bootstrap/infrastructure provider changes in the CAPI v1alpha2 proposals, feels like there will be some tight interplay there. Marking as frozen since this is important but the direction is a bit hazy at the moment. /lifecycle frozen |
Closing this (xref @ncdc's comment on the same PR for CAPA):
/close |
@justaugustus: Closed this PR. In response to this:
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. |
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-aws#651
kubernetes-sigs/cluster-api#721
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: