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

NatsServiceRole creates invalid tokens in wrong namespaces with Cluster-scoped installation #319

Open
valeneiko opened this issue Apr 27, 2021 · 0 comments

Comments

@valeneiko
Copy link

Description

If I create NatsServiceRole with a mathcing name in 2 different namespaces, Nats Operator will crate a total of 4 secrets, two in each namespace, but if I try to use it to connect to the cluster the connection will fail with Authentication error.

Steps to reproduce
0. Have 2 clusters deployed with NatsOperator in 2 namespaces (dev, staging).

  1. kubectl apply -n dev -f nats.yaml && kubectl apply -n staging -f nats.yaml
    # nats.yaml
    ---
    kind: ServiceAccount
    apiVersion: v1
    metadata:
      name: nats-test
      namespace: dev
    ---
    apiVersion: nats.io/v1alpha2
    kind: NatsServiceRole
    metadata:
      labels:
        nats_cluster: dev-nats
      name: nats-test
      namespace: dev
    spec:
      permissions:
        publish:
        - 'a.>'
        subscribe:
        - 'a.>'
  2. Observe 4 secrets beeing created:
    NAMESPACE   NAME                                 TYPE
    dev         nats-test-dev-nats-bound-token       Opaque
    dev         nats-test-staging-nats-bound-token   Opaque
    staging     nats-test-dev-nats-bound-token       Opaque
    staging     nats-test-staging-nats-bound-token   Opaque
  3. Try to connect using the above secrets. Observe "Authentication failed" error in Nats logs.

Expected Behaviour
Only 2 secrets to be created: nats-test-dev-nats-bound-token (in dev) and nats-test-staging-nats-bound-token (in staging), which are valid to authenticate with Nats in the corresponding namespace.

Workaround
Make sure Service Account names are unique (e.g. dev-nats-test in dev and staging-nats-test in staging). Then everything works as expected and only 2 valid secrets are created.

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

No branches or pull requests

1 participant