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

failed setting controller reference error when using a Secret generated by SealedSecret to create a RabbitMQ User #686

Open
AlbertoArconada opened this issue Oct 17, 2023 · 7 comments
Labels
bug Something isn't working never-stale

Comments

@AlbertoArconada
Copy link

AlbertoArconada commented Oct 17, 2023

Describe the bug

To avoid having base64 encoded credentials in my repos, I'm trying to use SealedSecrets to have encrypted credentials.
When a sealedsecret is applied, in the background this operator creates a secret in the same K8s namespace with the same name that contains Base64 encoded. Just for context, when generated, this secret contains some ownerReferences values.

Then, when I try to apply the template of a user that refers to that generated secret, I receive this error:
failed setting controller reference: Object namespace/name-of-the-secret is already owned by another SealedSecret controller name-of-the-sealed-secret

To Reproduce

Steps to reproduce the behavior:

  1. Create a Secret template
  2. Generate the sealed secret using kubeseal command
  3. Apply the generated sealed secret
  4. Create a User template whose importCredentialsSecret->name field points to the secret created in step 1
  5. Apply the User template

Include any YAML or manifest necessary to reproduce the problem.

Cluster template

apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
  name: my-rabbitmq-cluster
  namespace: my-rabbitmq-cluster-namespace
spec:
  replicas: 1

Secret template

apiVersion: v1
data:
  password: dGVzdHVzZXI=
  username: dGVzdHBhc3N3b3Jk
kind: Secret
metadata:
  name: test-user-credentials-secret
  namespace: my-rabbitmq-cluster-namespace
type: Opaque

User template

apiVersion: rabbitmq.com/v1beta1
kind: User
metadata:
  name: test-user
  namespace: my-rabbitmq-cluster-namespace
spec:
  tags:
    - management
  importCredentialsSecret:
    name: test-user-credentials-secret
  rabbitmqClusterReference:
    name: my-rabbitmq-cluster

Expected behavior

The User should be created without any problem using the Secret generated by SealedSecret Operator.

Screenshots

Version and environment information

  • Messaging Topology Operator: bitnami/rmq-messaging-topology-operator:1.12.0-scratch-r0
  • RabbitMQ: 3.12.4-management
  • RabbitMQ Cluster Operator: bitnami/rabbitmq-cluster-operator:2.3.0-scratch-r1
  • Kubernetes: v1.24.14
  • Cloud provider or hardware configuration: Google Cloud

Additional context

@AlbertoArconada AlbertoArconada added the bug Something isn't working label Oct 17, 2023
@AlbertoArconada AlbertoArconada changed the title failed setting controller reference when using a Secret generated by SealedSecret to create a RabbitMQ User failed setting controller reference error when using a Secret generated by SealedSecret to create a RabbitMQ User Oct 17, 2023
@AlbertoArconada AlbertoArconada changed the title failed setting controller reference error when using a Secret generated by SealedSecret to create a RabbitMQ User failed setting controller reference error when using a Secret generated by SealedSecret to create a RabbitMQ User Oct 17, 2023
Copy link

This issue has been marked as stale due to 60 days of inactivity. Stale issues will be closed after a further 30 days of inactivity; please remove the stale label in order to prevent this occurring.

@Zerpet
Copy link
Contributor

Zerpet commented Dec 18, 2023

hey, thank you for reporting this issue. I believe there's value in providing compatibility with sealed secrets. I've marked this issue as never-stale. However, I don't have time to get to this issue any time soon. A contribution would be very welcome 🙂

@MonicaMagoniCom
Copy link

I'm experiencing the same issue..

@VincBar
Copy link

VincBar commented Dec 18, 2024

I am having the same issue.

Is there any workaround, specifying a different sealed secret controller or something in that direction ?

Anything you tried and can recommend ?

@AlbertoArconada
Copy link
Author

Hi @VincBar,
yes, we found a workaround to move forward. In our case, what we did was create our Sealed Secrets skipping set owner references using sealedsecrets.bitnami.com/skip-set-owner-references: "true" annotation (More info here).

Hope it can help...
Regards!

@VincBar
Copy link

VincBar commented Dec 18, 2024

HI @AlbertoArconada , thanks a lot for responding so quickly. The issue seems to still persist for us.

Rabbitmq application is already running and deployed including the user with argocd.

What I have done:

  1. recreate the Secret, including the suggested annotation

    apiVersion: v1
    data:
      password: XXXX
      username: XXXX
    kind: Secret
    metadata:
      creationTimestamp: null
      name: XXX-user-user-credentials
      namespace: rabbitmq-cluster-dev
      annotations:
        sealedsecrets.bitnami.com/skip-set-owner-references: "true"
    type: Opaque
    
  2. Selead it with our kubeseal controller, this results in:

    apiVersion: bitnami.com/v1alpha1
    kind: SealedSecret
    metadata:
      creationTimestamp: null
      name: XXX-user-user-credentials
      namespace: rabbitmq-cluster-dev
      annotations:
        sealedsecrets.bitnami.com/skip-set-owner-references: "true" 
    spec:
      encryptedData:
        password: XXX
        username: XXX
      template:
        metadata:
          annotations:
            sealedsecrets.bitnami.com/skip-set-owner-references: "true"
          creationTimestamp: null
          name: XXX-user-user-credentials
          namespace: rabbitmq-cluster-dev
        type: Opaque
    
  3. Deployed on the cluster through argocd.

  4. Deleted (with kubectl) the user that showed the issue

  5. It was recreated by argocd with the same issue showing still

I can take a look at what versions we are using and look further into debugging, just wanted to check with you that this is the approach, that worked for you, or if I did misunderstand something.

@AlbertoArconada
Copy link
Author

AlbertoArconada commented Dec 20, 2024

Hi @VincBar,
at the beginning it didn't work for us too and, it was because we were using a version of Sealed Secrets that didn't had this feature implemented. It was added on v0.22.0 (Release notes here) so, if your installed version is lower to that then it won't work.

Regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working never-stale
Projects
None yet
Development

No branches or pull requests

4 participants