When i deploy this Deployment for sock-shop Yaml for sock-shop
but it does not give me write permission in the container so i cannot even write in it
$ kubectl exec -it carts-5496ffc4b6-5xr68 -n sock-shop -- sh
/usr/src/app $ apk add python
ERROR: Unable to lock database: Permission denied
ERROR: Failed to open apk database: Permission denied
/usr/src/app $ echo "Hello world" > sample.txt
sh: can't create sample.txt: Permission denied
/usr/src/app $
You need to run the pod as root to be able to get that permission.Edit the yaml and add below in the carts
deployment
securityContext:
runAsUser: 0
Recommended option would be run apk add python
in the Dockerfile itself and create a image with it installed already.
In the Dockerfile of the container that runs the carts micro-service https://github.com/microservices-demo/carts/blob/master/Dockerfile , add the below line,
USER root
This will make sure root permission is added and apk add may work.