Failed to watch *v1.Secret: unknown (get secrets)\n

Asking for help? Comment out what you need so we can get more information to help you!

Cluster information:

Kubernetes version: 1.27
Cloud being used: AWS
Installation method: flux
Host OS: Linux
CNI and version: v1.15.0-eksbuild.2
CRI and version:

0

I have deployed csi secret store driver in my cluster and it running as deamon set. When I checked log of deamon set it is showing as below

E1108 04:03:14.312307       1 reflector.go:140] "pkg/mod/k8s.io/client-go@v0.25.0/tools/cache/reflector.go:169: Failed to watch *v1.Secret: unknown (get secrets)\n"
E1108 04:04:03.313703       1 reflector.go:140] "pkg/mod/k8s.io/client-go@v0.25.0/tools/cache/reflector.go:169: Failed to watch *v1.Secret: unknown (get secrets)\n"
E1108 04:04:44.944725       1 reflector.go:140] "pkg/mod/k8s.io/client-go@v0.25.0/tools/cache/reflector.go:169: Failed to watch *v1.Secret: unknown (get secrets)\n"
E1108 04:05:19.718411       1 reflector.go:140] "pkg/mod/k8s.io/client-go@v0.25.0/tools/cache/reflector.go:169: Failed to watch *v1.Secret: unknown (get secrets)\n"

I have below servieaccount,clusterrole and clusterrolebinding setup

kubectl describe ds secrets-store-csi-driver
Name:           secrets-store-csi-driver
Selector:       app=secrets-store-csi-driver
Node-Selector:  kubernetes.io/os=linux
Labels:         app=secrets-store-csi-driver
                app.kubernetes.io/instance=secrets-store-csi-driver
                app.kubernetes.io/managed-by=Helm
                app.kubernetes.io/name=secrets-store-csi-driver
                app.kubernetes.io/version=1.3.4
                helm.sh/chart=secrets-store-csi-driver-1.3.4
                helm.toolkit.fluxcd.io/name=secrets-store-csi-driver
                helm.toolkit.fluxcd.io/namespace=kube-system
Annotations:    deprecated.daemonset.template.generation: 1
                meta.helm.sh/release-name: secrets-store-csi-driver
                meta.helm.sh/release-namespace: kube-system
Desired Number of Nodes Scheduled: 8
Current Number of Nodes Scheduled: 8
Number of Nodes Scheduled with Up-to-date Pods: 8
Number of Nodes Scheduled with Available Pods: 8
Number of Nodes Misscheduled: 0
Pods Status:  8 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:           app=secrets-store-csi-driver
                    app.kubernetes.io/instance=secrets-store-csi-driver
                    app.kubernetes.io/managed-by=Helm
                    app.kubernetes.io/name=secrets-store-csi-driver
                    app.kubernetes.io/version=1.3.4
                    helm.sh/chart=secrets-store-csi-driver-1.3.4
  Annotations:      kubectl.kubernetes.io/default-container: secrets-store
  Service Account:  secrets-store-csi-driver
  Containers:
   node-driver-registrar:
    Image:      registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.8.0
    Port:       <none>
    Host Port:  <none>
    Args:
      --v=5
      --csi-address=/csi/csi.sock
      --kubelet-registration-path=/var/lib/kubelet/plugins/csi-secrets-store/csi.sock
    Limits:
      cpu:     100m
      memory:  100Mi
    Requests:
      cpu:        10m
      memory:     20Mi
    Liveness:     exec [/csi-node-driver-registrar --kubelet-registration-path=/var/lib/kubelet/plugins/csi-secrets-store/csi.sock --mode=kubelet-registration-probe] delay=30s timeout=15s period=10s #success=1 #failure=3
    Environment:  <none>
    Mounts:
      /csi from plugin-dir (rw)
      /registration from registration-dir (rw)
   secrets-store:
    Image:       registry.k8s.io/csi-secrets-store/driver:v1.3.4
    Ports:       9808/TCP, 8095/TCP
    Host Ports:  0/TCP, 0/TCP
    Args:
      --endpoint=$(CSI_ENDPOINT)
      --nodeid=$(KUBE_NODE_NAME)
      --provider-volume=/var/run/secrets-store-csi-providers
      --additional-provider-volume-paths=/etc/kubernetes/secrets-store-csi-providers
      --metrics-addr=:8095
      --provider-health-check-interval=2m
      --max-call-recv-msg-size=4194304
    Limits:
      cpu:     200m
      memory:  200Mi
    Requests:
      cpu:     50m
      memory:  100Mi
    Liveness:  http-get http://:healthz/healthz delay=30s timeout=10s period=15s #success=1 #failure=5
    Environment:
      CSI_ENDPOINT:    unix:///csi/csi.sock
      KUBE_NODE_NAME:   (v1:spec.nodeName)
    Mounts:
      /csi from plugin-dir (rw)
      /etc/kubernetes/secrets-store-csi-providers from providers-dir-0 (rw)
      /var/lib/kubelet/pods from mountpoint-dir (rw)
      /var/run/secrets-store-csi-providers from providers-dir (rw)
   liveness-probe:
    Image:      registry.k8s.io/sig-storage/livenessprobe:v2.10.0
    Port:       <none>
    Host Port:  <none>
    Args:
      --csi-address=/csi/csi.sock
      --probe-timeout=3s
      --http-endpoint=0.0.0.0:9808
      -v=2
    Limits:
      cpu:     100m
      memory:  100Mi
    Requests:
      cpu:        10m
      memory:     20Mi
    Environment:  <none>
    Mounts:
      /csi from plugin-dir (rw)
  Volumes:
   mountpoint-dir:
    Type:          HostPath (bare host directory volume)
    Path:          /var/lib/kubelet/pods
    HostPathType:  DirectoryOrCreate
   registration-dir:
    Type:          HostPath (bare host directory volume)
    Path:          /var/lib/kubelet/plugins_registry/
    HostPathType:  Directory
   plugin-dir:
    Type:          HostPath (bare host directory volume)
    Path:          /var/lib/kubelet/plugins/csi-secrets-store/
    HostPathType:  DirectoryOrCreate
   providers-dir:
    Type:          HostPath (bare host directory volume)
    Path:          /var/run/secrets-store-csi-providers
    HostPathType:  DirectoryOrCreate
   providers-dir-0:
    Type:          HostPath (bare host directory volume)
    Path:          /etc/kubernetes/secrets-store-csi-providers
    HostPathType:  DirectoryOrCreate
Events:            <none>
 kubectl describe serviceaccount secrets-store-csi-driver
Name:                secrets-store-csi-driver
Namespace:           kube-system
Labels:              app=secrets-store-csi-driver
                     app.kubernetes.io/instance=secrets-store-csi-driver
                     app.kubernetes.io/managed-by=Helm
                     app.kubernetes.io/name=secrets-store-csi-driver
                     app.kubernetes.io/version=1.3.4
                     helm.sh/chart=secrets-store-csi-driver-1.3.4
                     helm.toolkit.fluxcd.io/name=secrets-store-csi-driver
                     helm.toolkit.fluxcd.io/namespace=kube-system
Annotations:         meta.helm.sh/release-name: secrets-store-csi-driver
                     meta.helm.sh/release-namespace: kube-system
Image pull secrets:  <none>
Mountable secrets:   <none>
Tokens:              <none>
Events:              <none>
kubectl describe clusterrole csi-secrets-store-provider-aws-cluster-role
Name:         csi-secrets-store-provider-aws-cluster-role
Labels:       app=secrets-store-csi-driver-provider-aws
              app.kubernetes.io/instance=secrets-provider-aws
              app.kubernetes.io/managed-by=Helm
              app.kubernetes.io/name=secrets-store-csi-driver-provider-aws
              helm.sh/chart=secrets-store-csi-driver-provider-aws-0.3.4
              helm.toolkit.fluxcd.io/name=secrets-provider-aws
              helm.toolkit.fluxcd.io/namespace=kube-system
Annotations:  meta.helm.sh/release-name: secrets-provider-aws
              meta.helm.sh/release-namespace: kube-system
PolicyRule:
  Resources              Non-Resource URLs  Resource Names  Verbs
  ---------              -----------------  --------------  -----
  serviceaccounts/token  []                 []              [create]
  nodes                  []                 []              [get]
  pods                   []                 []              [get]
  serviceaccounts        []                 []              [get]
  secrets                []                 []              [list]
ELSBLRM-406344:terraform rajn1$
 kubectl describe clusterrolebinding csi-secrets-store-provider-aws-cluster-role
Name:         csi-secrets-store-provider-aws-cluster-role
Labels:       app=secrets-store-csi-driver-provider-aws
              app.kubernetes.io/instance=secrets-provider-aws
              app.kubernetes.io/managed-by=Helm
              app.kubernetes.io/name=secrets-store-csi-driver-provider-aws
              helm.sh/chart=secrets-store-csi-driver-provider-aws-0.3.4
              helm.toolkit.fluxcd.io/name=secrets-provider-aws
              helm.toolkit.fluxcd.io/namespace=kube-system
Annotations:  meta.helm.sh/release-name: secrets-provider-aws
              meta.helm.sh/release-namespace: kube-system
Role:
  Kind:  ClusterRole
  Name:  csi-secrets-store-provider-aws-cluster-role
Subjects:
  Kind            Name                      Namespace
  ----            ----                      ---------
  ServiceAccount  secrets-store-csi-driver  kube-system

I added list secret permission to the cluster role but deamonset logs is still showing an error

Thankyou for the resolution steps.

I checked serviceaccout, clusterrole and clusterbinding as below and it looks fine to me. I have also added watch permission to service account but still the csi secret store driver is unable to create secret.

kubectl describe serviceaccount secrets-store-csi-driver
Name:                secrets-store-csi-driver
Namespace:           kube-system
Labels:              app=secrets-store-csi-driver
                     app.kubernetes.io/instance=secrets-store-csi-driver
                     app.kubernetes.io/managed-by=Helm
                     app.kubernetes.io/name=secrets-store-csi-driver
                     app.kubernetes.io/version=1.3.4
                     helm.sh/chart=secrets-store-csi-driver-1.3.4
                     helm.toolkit.fluxcd.io/name=secrets-store-csi-driver
                     helm.toolkit.fluxcd.io/namespace=kube-system
Annotations:         meta.helm.sh/release-name: secrets-store-csi-driver
                     meta.helm.sh/release-namespace: kube-system
Image pull secrets:  <none>
Mountable secrets:   <none>
Tokens:              <none>
Events:              <none>
kubectl describe clusterrole csi-secrets-store-provider-aws-cluster-role
Name:         csi-secrets-store-provider-aws-cluster-role
Labels:       app=secrets-store-csi-driver-provider-aws
              app.kubernetes.io/instance=secrets-provider-aws
              app.kubernetes.io/managed-by=Helm
              app.kubernetes.io/name=secrets-store-csi-driver-provider-aws
              helm.sh/chart=secrets-store-csi-driver-provider-aws-0.3.4
              helm.toolkit.fluxcd.io/name=secrets-provider-aws
              helm.toolkit.fluxcd.io/namespace=kube-system
Annotations:  meta.helm.sh/release-name: secrets-provider-aws
              meta.helm.sh/release-namespace: kube-system
PolicyRule:
  Resources              Non-Resource URLs  Resource Names  Verbs
  ---------              -----------------  --------------  -----
  serviceaccounts/token  []                 []              [create]
  nodes                  []                 []              [get]
  pods                   []                 []              [get]
  serviceaccounts        []                 []              [get]
  secrets                []                 []              [list get watch]
kubectl describe clusterrolebinding csi-secrets-store-provider-aws-cluster-role
Name:         csi-secrets-store-provider-aws-cluster-role
Labels:       app=secrets-store-csi-driver-provider-aws
              app.kubernetes.io/instance=secrets-provider-aws
              app.kubernetes.io/managed-by=Helm
              app.kubernetes.io/name=secrets-store-csi-driver-provider-aws
              helm.sh/chart=secrets-store-csi-driver-provider-aws-0.3.4
              helm.toolkit.fluxcd.io/name=secrets-provider-aws
              helm.toolkit.fluxcd.io/namespace=kube-system
Annotations:  meta.helm.sh/release-name: secrets-provider-aws
              meta.helm.sh/release-namespace: kube-system
Role:
  Kind:  ClusterRole
  Name:  csi-secrets-store-provider-aws-cluster-role
Subjects:
  Kind            Name                      Namespace
  ----            ----                      ---------
  ServiceAccount  secrets-store-csi-driver  kube-system

I also checked Daemon set is it is running all nodes