Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bitnami/apache] htdocsConfigMap is incompatible with containerSecurityContext #25669

Open
hybby opened this issue May 10, 2024 · 2 comments · May be fixed by #26304
Open

[bitnami/apache] htdocsConfigMap is incompatible with containerSecurityContext #25669

hybby opened this issue May 10, 2024 · 2 comments · May be fixed by #26304
Assignees
Labels
apache in-progress tech-issues The user has a technical issue about an application

Comments

@hybby
Copy link

hybby commented May 10, 2024

Name and Version

bitnami/apache 11.0.2

What architecture are you using?

arm64

What steps will reproduce the bug?

There is an option to overwrite the contents of the Apache htdocs directory with the contents of a configmap (htdocsConfigMap).

When set, Apache containers fail to come up with:

apache 09:12:49.11 INFO  ==> ** Starting Apache setup **
apache 09:12:49.22 INFO  ==> Mounting application files from '/app'
rm: cannot remove '/opt/bitnami/apache/htdocs/index.html': Read-only file system

This is due to this script in the container entrypoint:

https://github.com/bitnami/containers/blob/553a1efd8556e38d226a19dd2d2535cf9b08e756/bitnami/apache/2.4/debian-12/rootfs/opt/bitnami/scripts/apache/setup.sh#L76-L80

This conflicts with the default containerSecurityContext options:

containerSecurityContext:
...
  runAsNonRoot: true
...
  readOnlyRootFilesystem: true

Because setting htdocsConfigMap requires both writing to /opt/bitnami/apache/htdocs/ and interacting with files that have an ownership of root, both of the above must be set to false for it to work.

Is there another intended usage pattern meant for this setting, or should it be documented that its usage requires relaxation of the containerSecurityContext options?

Are you using any custom parameters or values?

Configuring htdocsConfigMap to the name of a configmap where it is unset by default.

What is the expected behavior?

The configmap should be mounted to the htdocs directory successfully while containerSecurityContext should not need altered.

What do you see instead?

I get an error:

apache 09:12:49.11 INFO  ==> ** Starting Apache setup **
apache 09:12:49.22 INFO  ==> Mounting application files from '/app'
rm: cannot remove '/opt/bitnami/apache/htdocs/index.html': Read-only file system

I need to configure the following for the configmap mounting to work:

containerSecurityContext:
  readOnlyRootFilesystem: false
  runAsNonRoot: false
  runAsUser: 0
  runAsGroup: 0
@hybby hybby added the tech-issues The user has a technical issue about an application label May 10, 2024
@hybby hybby changed the title htdocsConfigMap is incompatible with containerSecurityContext [bitnami/apache 11.0.2] htdocsConfigMap is incompatible with containerSecurityContext May 10, 2024
@github-actions github-actions bot added the triage Triage is needed label May 10, 2024
@hybby hybby changed the title [bitnami/apache 11.0.2] htdocsConfigMap is incompatible with containerSecurityContext [bitnami/apache] htdocsConfigMap is incompatible with containerSecurityContext May 10, 2024
@hybby
Copy link
Author

hybby commented May 10, 2024

A workaround to mount a configmap containing static HTTP file data while maintaining a read-only root filesystem is to use the extraVolume... functionality of the chart. But I'd suggest that this makes htdocsConfigMap redundant.

extraVolumes:
  - name: htdocs
    configMap:
      name: apache-http-content

extraVolumeMounts:
  - mountPath: "/opt/bitnami/apache/htdocs"
    name: htdocs

@github-actions github-actions bot removed the triage Triage is needed label May 13, 2024
@github-actions github-actions bot assigned migruiz4 and unassigned carrodher May 13, 2024
@migruiz4 migruiz4 linked a pull request May 21, 2024 that will close this issue
4 tasks
@migruiz4
Copy link
Member

Hi @hybby,

Thank you for reporting this issue! I have submitted this PR (#26304) which aims to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apache in-progress tech-issues The user has a technical issue about an application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants