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

Extend Account to support token and user/password auth #219

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vavsab
Copy link

@vavsab vavsab commented Jan 7, 2025

Also moved repeated parts into shared controller to avoid code duplication.

Why not env var injection like initially proposed?

Injecting as env vars into server URL will leak secrets in logs. To avoid this we need to pass sensitive params into nats client as separate options.

Related to

nats-io/k8s#876
#76

Usage example (token)

apiVersion: v1
kind: Secret
metadata:
  name: nats-token
type: Opaque
data:
  # token. required to be in base64 in Secret.
  token: dG9rZW4=
---
apiVersion: jetstream.nats.io/v1beta2
kind: Account
metadata:
  name: token-acc
spec:
  name: TOKEN_ACCOUNT
  servers:
    - 'nats://localhost:4222'
  token:
    secret:
      name: nats-token
    token: token
---
apiVersion: jetstream.nats.io/v1beta2
kind: Stream
metadata:
  name: js-token
spec:
  account: token-acc
  name: js-token
  storage: file
  subjects:
    - data.>

Usage example (user with password)

apiVersion: v1
kind: Secret
metadata:
  name: nats-user-with-pass
type: Opaque
data:
  # admin/admin. required to be in base64 in Secret.
  user: YWRtaW4=
  password: YWRtaW4=
---
apiVersion: jetstream.nats.io/v1beta2
kind: Account
metadata:
  name: user-pass-acc
spec:
  name: USER_PASS_ACCOUNT
  servers:
    - 'nats://localhost:4222'
  userWithPassword:
    secret:
      name: nats-user-with-pass
    user: user
    password: password
---
apiVersion: jetstream.nats.io/v1beta2
kind: Stream
metadata:
  name: js-user-pass
spec:
  account: user-pass-acc
  name: js-user-pass
  storage: file
  subjects:
    - data.>

@vavsab
Copy link
Author

vavsab commented Jan 7, 2025

@samuelattwood @adriandieter @ramonberrutti @Jarema @johnweldon @vsinger
Could you please review and merge it?

UPD: I will really appreciate if you create a release as well so I could get rid of using a forked docker image.

@Jarema
Copy link
Member

Jarema commented Jan 19, 2025

We will take a look at this one shortly.

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

Successfully merging this pull request may close these issues.

2 participants