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

Support for RKE2 secrets encryption keys rotation #35436

Closed
snasovich opened this issue Nov 10, 2021 · 14 comments
Closed

Support for RKE2 secrets encryption keys rotation #35436

snasovich opened this issue Nov 10, 2021 · 14 comments
Assignees
Labels
area/capr/rke2 RKE2 Provisioning issues involving CAPR area/provisioning-v2 Provisioning issues that are specific to the provisioningv2 generating framework dependency-rke2 Indicates that the rancher issue has a dependency to an RKE2 issue QA/M release-note Note this issue in the milestone's release notes team/hostbusters The team that is responsible for provisioning/managing downstream clusters + K8s version support
Milestone

Comments

@snasovich
Copy link
Collaborator

snasovich commented Nov 10, 2021

Implement support to rotate secrets encryption keys. This will allow the UI equivalent to the following RKE1 UI to be implemented:

Rotate encryption keys:
image

This requires rancher/rke2#748 implemented on RKE2 side.

@snasovich snasovich added dependency-rke2 Indicates that the rancher issue has a dependency to an RKE2 issue area/provisioning-v2 Provisioning issues that are specific to the provisioningv2 generating framework area/capr/rke2 RKE2 Provisioning issues involving CAPR labels Nov 10, 2021
@snasovich snasovich added this to the v2.6.4 milestone Nov 10, 2021
@snasovich snasovich changed the title Support for RKE2 provisioned cluster secrets encryption (with keys rotation) Support for RKE2 secrets encryption keys rotation Nov 10, 2021
@deniseschannon deniseschannon added the team/hostbusters The team that is responsible for provisioning/managing downstream clusters + K8s version support label Nov 23, 2021
@deniseschannon deniseschannon modified the milestones: v2.6.4, v2.6.4 - Triaged Dec 1, 2021
@jakefhyde jakefhyde self-assigned this Jan 10, 2022
@slickwarren slickwarren self-assigned this Jan 27, 2022
@sowmyav27
Copy link
Contributor

sowmyav27 commented Feb 15, 2022

Test cases to validate:

  • Enable default encryption for Secrets on RKE2 cluster. Deploy secrets on the cluster. And perform Rotate Encryption Keys action on the cluster. Verify the key is rotated. and the secrets are encrypted with the new key.
  • Enable custom encryption for Secrets on RKE2 cluster. Deploy secrets on the cluster. And perform Rotate Encryption Keys action on the cluster. Verify the key is rotated. and the secrets are encrypted with the new key.
  • Enable default encryption for Secrets on RKE2 cluster. Deploy about 5k secrets. Verify the secrets are encrypted. Perform Rotate Encryption Keys action on the cluster. Verify the key is rotated. Verify the secrets are encrypted using the new key. And the rewriting of secrets happen smoothly.
  • A few others listed in the internal confluence test plan for this feature

@jakefhyde
Copy link
Contributor

How to rotate encryption keys

Although there will be a UI button to start rotating encryption keys before the v2.6.4 release, currently the encryption keys can be rotated by adding the following:

rotateEncryptionKeys:
  generation: 1

under the rkeConfig section of a cluster object's yaml.

Additional test cases

  • single node rke2/k3s
  • 3 node control plane rke2/k3s
  • creating the cluster with rotateEncryptionKeys.generation in the spec (cluster should not rotate while provisioning).
  • >5 node control plane

@jakefhyde
Copy link
Contributor

Blocked waiting for rke2 and k3s kdm june releases since encryption key rotation is feature gated in KDM.

@jakefhyde
Copy link
Contributor

jakefhyde commented Jul 7, 2022

Root cause

Encryption key rotation did not initially work for rke2/k3s, and plans for etcd only nodes would be in sync and not updated during subsequent reconciliations, which includes prepare, rotate, and reencrypt.

What was fixed, or what changes have occurred

The encryption key rotation feature for rke2/k3s has gone through a few iterations in order to reach a working state for all cluster configurations. A fix has been made to ensure that these system-agent plans are run precisely when they need to.

Areas or cases that should be tested

I've personally tested rke2 & k3s v1.22.11, compiled from source with the required fixes merged in, as well as some testing afterwards. I tested the following cluster configurations using Digital Ocean provisioned nodes.

configuration status
1 node all roles ✔️
1 etcd, 1 cp, 1 worker ✔️
3 nodes all roles ✔️
3 etcd, 2 cp, 3 worker ✔️
3 etcd, 3 cp, 3 worker ✔️
3 etcd, 5 cp, 3 worker ✔️

I personally recommend testing each kubernetes version, both rke2 & k3s, under a variable amount of load (new cluster, >1000 secrets, >1000 secrets and currently adding more, etc.). I also recommend messing with the cluster in various ways, such as deleting a machine.

I've tested the standard user case, and the standard user can rotate encryption keys no problem.

What areas could experience regressions?

N/A

Are the repro steps accurate/minimal?

Set CATTLE_SYSTEM_CHART_DEFAULT_BRANCH=dev-v2.6 when running rancher to use the dev-v2.6 KDM branch.
Rotate Encryption Keys is now an option in the UI.

@thaneunsoo
Copy link
Contributor

thaneunsoo commented Jul 19, 2022

Test Environment:

Rancher version: v2.6-head 2c21373
Rancher cluster type: HA
Docker version: 20.10


Testing:

Tested all scenarios listed here

Result
All scenarios have passed except for the following scenario:

  • Rotate Encryption Key for a RKE2 cluster which has encryption enabled and 10,000 secrets
    Issues found are:
  • 38277 - Unable to rotate encryption keys after rotating once
  • 38283 - Unable to rotate encryption keys for large number of secrets

Closing this ticket as testing is complete and issues will be tracked in the tickets listed above.

@zube zube bot assigned thaneunsoo and unassigned timhaneunsoo Jul 25, 2022
@zube zube bot removed the [zube]: Done label Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/capr/rke2 RKE2 Provisioning issues involving CAPR area/provisioning-v2 Provisioning issues that are specific to the provisioningv2 generating framework dependency-rke2 Indicates that the rancher issue has a dependency to an RKE2 issue QA/M release-note Note this issue in the milestone's release notes team/hostbusters The team that is responsible for provisioning/managing downstream clusters + K8s version support
Projects
Development

No branches or pull requests