Set permission of a file in a pod

11/7/2019

We are creating a file in a pod which should be only readable by process running in a pod. Is there a way to restrict the access of a file so that only pod can read the content of the file ?

-- BobCoder
kubernetes
pod

1 Answer

11/8/2019

While building the container you can

  1. create a user.

    RUN useradd -ms /bin/bash newuser

  2. Change the ownership of file

chown "username" "filename"

  1. Change the permissions of the file so that only the created user has access to file.

chmod 600 "filename"

  1. Specify the container startup script to run as newly created user
-- asolanki
Source: StackOverflow