PureDevOps Community

Var/run/secrets/kubernetes.io/serviceaccount/token: No such file or directory

I was trying to create a sidecar for the existing kibana from elastic-cloud using the below manifest. The thing is kibana container is coming up but not the tailscale sidecar , upon checking the logs i see this error var/run/secrets/kubernetes.io/serviceaccount/token: No such file or directory

the manifest

apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
  name: kibana
  namespace: elastic-system
spec:
  version: 7.15.1
  http:
    service:
      spec:
        ports:
        - port: 5601
          protocol: TCP
          targetPort: 5601
        type: NodePort
    tls:
      selfSignedCertificate:
        disabled: true
  count: 1
  elasticsearchRef:
    name: elastic
  podTemplate:
    spec:
      serviceAccountName: ts
      containers:
      - name: ts-sidecar
        imagePullPolicy: Always
        image: "ghcr.io/tailscale/tailscale:latest"
        env:
        - name: TS_KUBE_SECRET
          value: "secre_key"
        - name: TS_USERSPACE
          value: "false"
        - name: TS_AUTH_KEY
          valueFrom:
            secretKeyRef:
              name: tailscale-auth
              key: TS_AUTH_KEY
              optional: true
        securityContext:
          capabilities:
            add:
            - NET_ADMIN

Solution:
After many trials and googling i found automountServiceAccountToken is set to false and so the error. Then I updated as automountServiceAccountToken: true as below it worked

podTemplate:
    spec:
      serviceAccountName: ts
      automountServiceAccountToken: true
      containers:
      - name: ts-sidecar