Changing secret name while mounting to pod

I have a secret with some random name inside data, when I mount the secret inside the pod, the file name is having that random name is it possible to change the name when it is getting mounted inside a pod

Something along these lines should work:

kind: Pod
  name: nginx
  - name: nginx
    image: nginx
    - name: myvolume
      mountPath: "/userdata"
  - name: myvolume
      secretName: scr
      - key: topsecretkey
        path: scr/notsotopsecrekey```

In the datapart of the secret, you basically have a map of key:value where key = filename and value = contents in base64

So you can change the secret key name or do what suggests

In general i’ll always suggest to have the appropriate and required name for the key in the secret. Similar to what suggested.

I wasn’t even aware of the syntax you presented, I have used subPath to mount individual files from secrets into specific paths

I agree with and but creating the secret is not in my control. I have my secrets in Google secrets manager and a job is creating the kubernetes secret based on the external secret source, so whatever name in my external source the job is creating with that name so the random string after the name like secret-23748584-dhajrk. But my application can only look for a specific file name inside a path since the last 2 part were random we cannot define that in advance

Ofcourse there are other workarounds for that as well but is it possible to update the job instead? Because idk why you require adding random strings in the key. Are you using external-secrets?

I don’t have the Control on the job, the string is getting added to the resource as it is created through terraform

So the random is in the name of the secret, not the data key?

Secret is getting created with the data key name only