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

Add support for Encryption Providers #1241

Merged
merged 4 commits into from
Apr 19, 2021

Conversation

moelsayed
Copy link
Contributor

What this PR does / why we need it:

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 #1225

Special notes for your reviewer:
While this adds support for custom configuration, they wouldn't be effective yet in enabling KMS deployment as that would require adding external volumes to the KubeAPI container. That will be implemented separately.
Does this PR introduce a user-facing change?:

Add support for Encryption Providers 

@kubermatic-bot kubermatic-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 5, 2021
@moelsayed moelsayed force-pushed the encryption_providers_1 branch 3 times, most recently from e35197f to 1eb5c72 Compare February 8, 2021 17:14
@xmudrii
Copy link
Member

xmudrii commented Feb 16, 2021

/assign

Copy link
Member

@xmudrii xmudrii left a comment

Choose a reason for hiding this comment

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

I did the first run and overall it looks good to me. I've left a bunch of comments, but I hope that most of them are minor. I still haven't reviewed everything and I might have some additional comments and questions, but I'll try to take a deeper look tomorrow.

pkg/apis/kubeone/types.go Outdated Show resolved Hide resolved
pkg/apis/kubeone/v1alpha1/types.go Outdated Show resolved Hide resolved
pkg/cmd/apply.go Outdated Show resolved Hide resolved
pkg/cmd/config.go Show resolved Hide resolved
pkg/cmd/config.go Outdated Show resolved Hide resolved
pkg/templates/encryption-providers/encryption_providers.go Outdated Show resolved Hide resolved
pkg/templates/encryption-providers/encryption_providers.go Outdated Show resolved Hide resolved
pkg/templates/encryption-providers/encryption_providers.go Outdated Show resolved Hide resolved
pkg/cmd/apply.go Outdated Show resolved Hide resolved
pkg/cmd/apply.go Outdated Show resolved Hide resolved
@kubermatic-bot kubermatic-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 21, 2021
@moelsayed moelsayed force-pushed the encryption_providers_1 branch 2 times, most recently from 5785e8d to 2a84376 Compare February 21, 2021 18:06
@moelsayed
Copy link
Contributor Author

/retest

1 similar comment
@moelsayed
Copy link
Contributor Author

/retest

pkg/tasks/probes.go Outdated Show resolved Hide resolved
return err
}

func UploadIdentityFirstEncryptionConficguration(s *state.State) error {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: typo.

Suggested change
func UploadIdentityFirstEncryptionConficguration(s *state.State) error {
func UploadIdentityFirstEncryptionConfiguration(s *state.State) error {

Comment on lines +254 to +269
if opts.RotateEncryptionKey {
if !s.EncryptionEnabled() {
return errors.New("Encryption Providers support is not enabled for this cluster")
}

if s.Cluster.Features.EncryptionProviders != nil &&
s.Cluster.Features.EncryptionProviders.CustomEncryptionConfiguration != "" {
return errors.New("key rotation of custom providers file is not supported")
}
return runApplyRotateKey(s, opts)
}
Copy link
Member

Choose a reason for hiding this comment

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

There two edge cases that might not be covered by this:

  1. What if we need to repair the cluster, but the --rotate-encryption-key flag is provided? Should we show a warning/error or do something?
  2. What if the cluster is supposed to be upgraded, but the user also provided the --rotate-encryption-key flag? In that case, I'd expect that we do both if possible. Also, in that case, we don't need to require the --force-upgrade flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What if we need to repair the cluster, but the --rotate-encryption-key flag is provided? Should we show a warning/error or do something?

I have added a check to error out if the cluster is not healthy.

What if the cluster is supposed to be upgraded, but the user also provided the --rotate-encryption-key flag? In that case, I'd expect that we do both if possible. Also, in that case, we don't need to require the --force-upgrade flag.

I did this to split the two operations. Both rotation and upgrade are disruptive operations. I think it makes sense to try to minimize these sort of operations in each run. I also used the --force-upgrade here as a sort of make-sure-you-know-what-you're-doing barrier the same why it's used to update the Features section configuration.


fmt.Println("The following actions will be taken: ")
fmt.Println("Run with --verbose flag for more information.")
tasksToRun := tasks.WithRotateKey(nil)
Copy link
Member

Choose a reason for hiding this comment

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

How is this going to behave if a custom EncryptionConfiguration is used? I think that we should fail in that case and ask the user to do it manually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's checked earlier here

if feature == nil || !feature.Enable {
return
}
args.APIServer.ExtraArgs[apiServerEncryptionProviderFlag] = apiServerEncryptionProviderConfigPath
Copy link
Member

Choose a reason for hiding this comment

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

This is always going to set the flag to encryption-providers.yaml. How this works if we're using a custom EncryptionConfiguration? Isn't the file called custom-encryption-providers.yaml in that case?

return err
}

func UploadIdentityFirstEncryptionConficguration(s *state.State) error {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should safeguard this function that it can't be used if a custom EncryptionConfiguration is used.

pkg/tasks/tasks.go Outdated Show resolved Hide resolved
@kubermatic-bot kubermatic-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 4, 2021
@moelsayed
Copy link
Contributor Author

/test pull-kubeone-test

@kubermatic-bot kubermatic-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 18, 2021
@kubermatic-bot kubermatic-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 19, 2021
@moelsayed
Copy link
Contributor Author

/test pull-kubeone-test

pkg/scripts/configs.go Outdated Show resolved Hide resolved
@kubermatic-bot kubermatic-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 7, 2021
pkg/scripts/configs.go Outdated Show resolved Hide resolved
pkg/cmd/apply.go Show resolved Hide resolved
pkg/tasks/tasks.go Outdated Show resolved Hide resolved
@@ -315,9 +339,20 @@ func runApplyUpgradeIfNeeded(s *state.State, opts *applyOpts) error {

operations := []string{}

tasksToRun := tasks.WithResources(nil)
var tasksToRun tasks.Tasks
Copy link
Member

Choose a reason for hiding this comment

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

But what tasks to run when upgradeNeeded || opts.ForceUpgrade is not true? We need to run tasks.WithResources in that case, but it will not happen this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kron4eg nice catch, updated 👍

@moelsayed
Copy link
Contributor Author

/retest

@moelsayed
Copy link
Contributor Author

/test pull-kubeone-lint

@moelsayed
Copy link
Contributor Author

/test pull-kubeone-e2e-aws-upgrade-1.18-1.19

@moelsayed
Copy link
Contributor Author

/retest

@xmudrii
Copy link
Member

xmudrii commented Apr 8, 2021

/hold
there is one more thing to fix before we merge this

@kubermatic-bot kubermatic-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 8, 2021
pkg/apis/kubeone/types.go Outdated Show resolved Hide resolved
Copy link
Member

@kron4eg kron4eg left a comment

Choose a reason for hiding this comment

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

/approve

@kubermatic-bot kubermatic-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 18, 2021
@kubermatic-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 1f36d0afd9f63a61476493af827360074faacbc1

@kubermatic-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kron4eg, moelsayed

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

@kubermatic-bot kubermatic-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 18, 2021
@kron4eg
Copy link
Member

kron4eg commented Apr 19, 2021

/unhold

@kubermatic-bot kubermatic-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 19, 2021
@kubermatic-bot kubermatic-bot merged commit fef8d68 into kubermatic:master Apr 19, 2021
@kubermatic-bot kubermatic-bot added this to the KubeOne 1.3 milestone Apr 19, 2021
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. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement enable/disable/key rotatation for Encryption Providers in KubeOne
4 participants