dapr to access kubernetes secrets as secretstore

335 Views Asked by At

following my previous question about dapr and k8s secrets. I have a k8s secret defined as follow:

apiVersion: v1
kind: Secret
metadata:
  name: secretstore
  namespace: my-namespace
type: Opaque
data:
  MY_KEY: <some base64>

I then defined a dpar component as:

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: secretstore
  namespace: my-namespace
spec:
  type: secretstores.kubernetes
  version: v1
  metadata: []

and gave the permission to access the secrets (according with dapr docs)

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: secret-reader
  namespace: my-namespace
rules:
- apiGroups: [""]
  resources: ["secrets"]
  verbs: ["get", "watch", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: dapr-secret-reader
  namespace: my-namespace
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: secret-reader
subjects:
- kind: ServiceAccount
  name: default

but with all of this, dapr cannot access the secret I want it to retrieve.

The error is

Stacktrace: {"Status":{"StatusCode":13,"Detail":"failed getting secret with key MY_KEY from secret store secretstore: secrets \"MY_KEY\" not found","DebugException":null},"StatusCode":13,"Trailers":[],"Message":"Status(StatusCode=\"Internal\", Detail=\"failed getting secret with key MY_KEY from secret store secretstore: secrets \"MY_KEY\" not found\")","Data":{},"InnerException":null,"HelpLink":null,"Source":"System.Private.CoreLib","HResult":-2146233088,"StackTrace":"   at Dapr.Client.DaprClientGrpc.GetSecretAsync(String storeName, String key, IReadOnlyDictionary`2 metadata, CancellationToken cancellationToken)"}

Any clue about what I am missing? I went through dapr documentation several times but I wan't able to find anything that could help. Thanks in advance!!

0

There are 0 best solutions below