-
Notifications
You must be signed in to change notification settings - Fork 430
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
Add SecurityProfile.EncryptionAtHost parameter to enable host-based VM encryption #1012
Add SecurityProfile.EncryptionAtHost parameter to enable host-based VM encryption #1012
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
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. I understand the commands that are listed here. |
Welcome @dkorzuno! |
Hi @dkorzuno. Thanks for your PR. I'm waiting for a kubernetes-sigs 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. |
Followed the CLA instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement. |
} | ||
|
||
return &compute.SecurityProfile{ | ||
EncryptionAtHost: to.BoolPtr(*vmSpec.SecurityProfile.EncryptionAtHost), |
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.
this isn't supported on all VM sizes, it requires a check against the capability (see accelerated networking for an example).
we should probably fail fast with error + no requeue in the reconciler if it's not possible to provision that for the user.
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.
I added the capability check.
cloud/services/scalesets/vmss.go
Outdated
} | ||
|
||
return &compute.SecurityProfile{ | ||
EncryptionAtHost: to.BoolPtr(*scaleSpec.SecurityProfile.EncryptionAtHost), |
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.
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.
Added the capability check to the function.
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.
I'm a little bummed we can't reject this in the webhook rather than in reconciliation.
Actually, I think returning an error on this is going to cause an endless reconcile loop. We will never get to a terminal state unless the user changes the VM SKU or disables EncryptionAtHost
.
@alexeldeib wdyt?
/ok-to-test |
Agreed 🙁
IMO, we need a way to bubble terminal vs non-terminal errors to the top. When you write one big reconcile loop, it's super easy -- log the error and either return if non-terminal or don't return the error if it's terminal. We could use a good way to bubble that up from inside the reconcilers (I smell custom error types). for this PR, probably fine to let it loop sadly. |
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.
With #1014 logged, I'm good with merging this.
lgtm
I'm going to leave it open for a bit to allow others to review. Thank you for the PR!
}, | ||
}, nil) | ||
s.GetBootstrapData(context.TODO()).Return("fake-bootstrap-data", nil) | ||
m.CreateOrUpdate(context.TODO(), "my-rg", "my-vmss", gomockinternal.DiffEq(compute.VirtualMachineScaleSet{ |
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.
instead of checking the entire struct here since we only care about testing the encryption at host functionality is enabled it would make sense to do the same thing you did in the virtualmachines test https://github.com/kubernetes-sigs/cluster-api-provider-azure/pull/1012/files#diff-f2a0391546f379219695118e52694fe6a8c5739619cb672941617a78d0c63336R770
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.
Updated the test... maybe not in the best possible way, though. I had to modify the test case interface a bit to pass through the *WithT
pointer. Happy to change it if needed.
A random thought - at least for
This way an error in one VM specification won't affect others. On next Something along the lines
|
Yeah arguably it's not a good reason, at the time it seemed easier to be consistent everywhere. I think VM and vnet (and scale set but that one is still not refactored) are probably the only ones that are exceptions to the rule? I'd be open to switching those to not be arrays. It's not an API change shouldn't be breaking for users. |
Im might be missing something, Is there something stopping us to do this in webhook? There were multiple comments about this. Is this a request or just a rant for that this is technologically not possible? #wannalearn |
@mjudeikis, it's the start of a rant. Since the webhooks don't have an authenticated context and we don't make any service calls within the webhook (we don't call out to Azure), we are unable to check to see if the resource sku supports Great question! |
Is there anything else I can do in the context of this PR? |
@dkorzuno to me the only actionable item for this PR is to persist the value in the controller (ie. if nil, set it to false) so that it doesn't get changed later on existing clusters if we change the default to "true if supported". @alexeldeib @devigned does that sound reasonable to you? |
@CecileRobertMichon let me clarify it as I got confused a bit. func getSecurityProfile(vmssSpec azure.ScaleSetSpec, sku resourceskus.SKU) (*compute.SecurityProfile, error) {
if vmssSpec.SecurityProfile == nil {
return &compute.SecurityProfile{
EncryptionAtHost: to.BoolPtr(false),
}, nil
}
if !sku.HasCapability(resourceskus.EncryptionAtHost) {
return nil, errors.Errorf("encryption at host is not supported for VM type %s", vmssSpec.Size)
}
return &compute.SecurityProfile{
EncryptionAtHost: to.BoolPtr(*vmssSpec.SecurityProfile.EncryptionAtHost),
}, nil
} Or (which I'm leaning towards to) if If it's the latter, what would be the best approach there - add |
I'm sure Cecile will comment too, but personally I think leave the field as an optional pointer, but default it to false in the webhook?
so basically this, but in the webhook for now should be okay I think? in the future, we would want to be able to dynamically detect whether a size supports it without forcing the user to tell us. to do that would still require what you describe, and yes it would require some kind of setter on the scope to write back into the CRD object. |
Done. |
E2E is failing with
🤨 Is EncryptionAtHost a gated feature? Also strange that it's for returning an error message when the value is |
Confirmed docs mention you have to send an email to get it activated on your sub https://docs.microsoft.com/en-us/azure/virtual-machines/linux/disks-enable-host-based-encryption-cli#prerequisites so we can't do the defaulting otherwise that will break all users that haven't enabled it 😞 @dkorzuno let's revert the defaulting, sorry for making you do that extra work for nothing... |
/retest |
@dkorzuno: The
Use
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. |
/retest |
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.
/lgtm
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CecileRobertMichon 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 |
What type of PR is this?
/kind feature
/kind api-change
What this PR does / why we need it:
The PR adds a parameter which enables encryption at host for virtual machines.
Which issue(s) this PR fixes
This PR addresses the second part of #982 started by @mjudeikis
Special notes for your reviewer:
I added what seemed reasonable to me, but I'm not entirely sure that I haven't missed anything. Especially I have some doubts about the conversion part. Will be happy to make whatever changes required.
Also, I added a couple of the unit test, in somewhat "copy-pasty" manner. While they seem to follow the suit and do cover the change, maybe I should clean those up a bit to exclude extra checks?
Release note: