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

Service Account Auth - authorization violation on stan-cluster-1 (NatsStreamingCluster) #58

Open
Upperfoot opened this issue Oct 24, 2019 · 2 comments

Comments

@Upperfoot
Copy link

I recently implemented service accounts and it works great for standard NATS communication on the nats-cluster, however, the NatsStreamingCluster isn't making use of the Service Accounts setup, do I have to manually define what credentials it uses? And if so, where would I put this in the Kubernetes YAML config?

apiVersion: "streaming.nats.io/v1alpha1"
kind: "NatsStreamingCluster"
metadata:
  name: "stan-cluster"
spec:
  natsSvc: "nats-cluster"

..... (rest of config is irrelevant and relates to persistent storage)

Any ideas?

@rchenzheng
Copy link

Same issue here

@wallyqs
Copy link
Member

wallyqs commented Jan 28, 2020

currently serviceaccount auth can't be done with the streaming operator, something like the following would work with statefulsets though:

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: stan-conf
data:
  stan.conf: |
     streaming {
       ns: $NATS_SERVER_URL
     }
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: stan
  labels:
    app: stan
spec:
  selector:
    matchLabels:
      app: stan
  replicas: 1
  serviceName: stan
  template:
    metadata:
      labels:
        app: stan
    spec:
      volumes:
      - name: stan-conf
        configMap:
          name: stan-conf
      containers:
        - name: nats-streaming
          image: nats-streaming:0.16.2
          args:
            - "-sc"
            - "/etc/stan/config/stan.conf"
          ports:
          - containerPort: 8222
            name: monitor
          env:
          - name: SECRET_TOKEN
            valueFrom:
              secretKeyRef:
                name: stan-pass
                key: token
          - name: NATS_SERVER_URL
            value: "nats://svc-account:$(SECRET_TOKEN)@nats:4222"
          volumeMounts:
          - mountPath: /etc/stan/config
            name: stan-conf
            readOnly: true
---
apiVersion: v1
kind: Service
metadata:
  name: stan
  labels:
    app: stan
spec:
  selector:
    app: stan
  clusterIP: None
  ports:
  - name: monitor
    port: 8222

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

3 participants