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

[RFE] Backup Operator ignores "*.*" in EncryptionConfiguration #591

Closed
bvankampen opened this issue Oct 2, 2024 · 7 comments
Closed

[RFE] Backup Operator ignores "*.*" in EncryptionConfiguration #591

bvankampen opened this issue Oct 2, 2024 · 7 comments
Assignees
Labels
Milestone

Comments

@bvankampen
Copy link

Rancher Server Setup

  • Rancher version: 2.9.2
  • Backup Operator rancher-backup:104.0.1+up5.0.1

Describe the bug
If you define *.* in the resources of a EncryptionConfiguration for an encrypted backup, nothing gets encrypted. Is this intended behaviour?

To Reproduce

  1. Create a EncryptionConfiguration:
apiVersion: apiserver.config.k8s.io/v1
kind: EncryptionConfiguration
resources:
  - resources:
      - "*.*"
    providers:
      - secretbox:
          keys:
            - name: key1
              secret: <REDACTED>
  1. Create secret with this file as content.
kubectl create secret generic encryptionconfig \
    --from-file=./encryption-provider-config.yaml \
    -n cattle-resource-system
  1. Create a encrypted Rancher backup with the backup operator.
  2. Download the backup, (rename to tar.gz and) extract, inspect the resource json's
  3. None of the resource json are encrypted.

Expected behavior
All the resources json are encrypted (like when you use secrets as resource.

@bvankampen
Copy link
Author

Using * instead of *.* doesn't work too.

image

@mallardduck
Copy link
Member

Identified the source of the bug to around here:

encryptionTransformer := h.TransformerMap[gr]

Gist being that it only currently allows direct matches and cannot work with wildcards. Looking into potential solutions.

@mallardduck mallardduck changed the title Backup Operator ignores "*.*" in EncryptionConfiguration [RFE] Backup Operator ignores "*.*" in EncryptionConfiguration Oct 3, 2024
@mallardduck mallardduck added the enhancement New feature or request label Oct 3, 2024
@mallardduck
Copy link
Member

After further investigation, I've realized that the upstream ability to use this feature (wildcard resource selection for EncryptionConfiguration) is something that requires k8s 1.27+.

The k8s docs indicate this in their examples:

      - '*.*' # wildcard match requires Kubernetes 1.27 or later

So this is more of an RFE rather than an outright bug. The main reason being that BRO releases are tied to Rancher releases and must support the same range of k8s versions. So ideally a feature like this is included when Rancher minimum k8s matches the version that upstream adds the feature in.

Thankfully in this case that lines up with 2.9.x Rancher - so there's no "bake in" time for that window to expire. I have been able to make a lot of progress to be confident on how we can fix backups. However the fix needs to be symmetrical or it will leave restorations broken.


Dev notes: To fix we will want to more directly replicate the logic k8s uses when dealing with EncryptionConfiguration. The glaring issue is that we use keys to find the transformers to use and this wildcard feature requires a less direct approach.

Because the wildcard feature allows for: true wildcards (*.*), core wildcards (*.), partial wildcards (*.apps) and for those to use the no operation (identity) provider. This mix of new combinations means that: a) we need to take that in mind when resolving transformers and b) even unencrypted files will likely have transformers now.

Attached is a backup-encrypt.patch
file that fixes uploads, but as mentioned a symmetrical fix to restores must be applied as well. Likely this is a M or L task.

@mallardduck
Copy link
Member

The PR work on this is complete but given that it targets Rancher 2.11 it is blocked until after 2.10 release.

@jbiers
Copy link
Member

jbiers commented Oct 17, 2024

We managed to get QA cycles to get this tested for the 2.10 release so I'll be merging the PR and moving the issue from blocked ;)

@jbiers
Copy link
Member

jbiers commented Oct 25, 2024

QA notes: Unit and integration testing for this feature were added in a separate PR. Maybe it is part of standard procedure to use the latest RC version, but I'm commenting this here just to make sure. Latest version including the updated tests is 105.0.0+up6.0.0-rc.7

@nickwsuse
Copy link

Verified on v2.10-alpha ID: 212d8b6 & Rancher Backups v105.0.0+up6.0.0-rc.7

Verified on fresh install of v2.10-head and upgrades from v2.9.3 the encryption config correctly encrypts the right resources. If specific resources are given in the config, or if the wildcard operator is used, encryption is working for backups and for restores.

resources:
  - resources:
      - secrets
      - configmaps
resources:
  - resources:
      - "*.*"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants