Closed saharshMMC closed 3 years ago
Hi @saharshMMC
That's expected, please note that by default the chart runs the container with an unprivileged user for security reasons. You can learn more about the reasons to use non-root containers in our docs:
To add custom NPM packages and continue using the non-root container, you can extend the image and use your own customized Ghost container with a Dockerfile like the one below:
FROM bitnami/ghost
## Change user to perform privileged actions
USER 0
## Install NPM packages
RUN npm install ...
## Revert to the original non-root user
USER 1001
Then, you can install the Ghost chart using a values.yaml like the one below:
image:
registry: YOUR-CUSTOM-REGISTY
repository: YOUR-CUSTOM-IMAGE
tag: YOUR-CUSTOM-TAG
Note: replace
YOUR-CUSTOM-REGISTY
,YOUR-CUSTOM-IMAGE
, andYOUR-CUSTOM-TAG
placeholder with the actual custom values you want to use.
That said, you can also run the container as "root" by modifying the containerSecurityContext
and podSecurityContext
in the values.yaml:
podSecurityContext:
enabled: true
fsGroup: 0
runAsUser: 0
containerSecurityContext:
enabled: false
runAsUser: 0
runAsNonRoot: false
When you do so, you can connect to the Ghost container and check that the container is actually run as root and the ghost process run as the ghost
user:
$ kubectl exec -it GHOST_POD_NAME -- bash
root@GHOST_POD_NAME:/opt/bitnami/ghost# whoami
root
root@GHOST_POD_NAME:/opt/bitnami/ghost# # ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 2280 760 ? Ss 06:39 0:00 tini -- /run.sh
ghost 243 1.0 0.6 635900 50892 ? Sl 06:41 0:01 ghost log
ghost 327 0.6 0.6 633768 48984 ? Ssl 06:41 0:00 ghost run
ghost 356 5.2 1.8 971996 138552 ? Sl 06:41 0:06 /opt/bitnami/node/bin/node current/index.js
root 391 0.0 0.0 4000 3096 pts/0 Ss 06:41 0:00 bash
root 398 0.0 0.0 7640 2756 pts/0 R+ 06:43 0:00 ps aux
Thanks a lot @juan131 for prompt reply. I get why we are using non root container. Will try to build custom container myself. Thanks again.
Using helm charts to deploy Ghost inside a k8s cluster on AWS EKS. By default it works fine but I need to install storage adapter to transfer my files to S3. Unable to do so without gaining more privilege.
Chart version :10.2.3
Describe the bug I am unable to to do npm install or even add a user when pod gets created via k8s/helm. I have to attach s3 storage adapter but failing as i cannot do anything other than running ghost basic commands.
Errors:
Logging few commands and the errors I get
Helm chart config
ghost version
npm install
sudo npm install
sudo chown -R 1001:0 "/.npm"
cat /etc/passwd
ghost ls
ghost doctor
To Reproduce Steps to reproduce the behavior:
Expected behavior I should be able to install different packages for plugins. Atleast able to update the cli and npm packages
Version of Helm and Kubernetes:
helm version
:kubectl version
: