Skip to content

Set nextcloud.podSecurityContext.fsGroup to 33 by default and allow users to configure it if needed. - #379

Open
jessebot wants to merge 5 commits into
mainfrom
fix-default-fsgroup
Open

Set nextcloud.podSecurityContext.fsGroup to 33 by default and allow users to configure it if needed.#379
jessebot wants to merge 5 commits into
mainfrom
fix-default-fsgroup

Conversation

@jessebot

@jessebotjessebot commented Apr 16, 2023

Copy link
Copy Markdown
Collaborator

Pull Request

Description of the change

Changes default fsGroup to be 33. In all apache and regular fpm, the www-data user is 33.

The www-data user is 82 in all alpine images (including nginx), so I added a note in the README about it.

Previously we relied on if the user was using nginx.enabled which is alpine by default, but using nginx:alpine doesn't mean you're using nextcloud:fpm-alpine.

Benefits

If someone uses image.flavor of apache or fpm, the fsGroup should be 33 by default.

Possible drawbacks

If you used an alpine image, you will now have to manually set nextcloud.podSecurityContext.fsGroup to be 82 in your values.yaml.

Applicable issues

Additional information

Checklist

Comment threadcharts/nextcloud/templates/deployment.yaml Outdated
Comment threadcharts/nextcloud/templates/deployment.yaml Outdated
Comment threadcharts/nextcloud/templates/deployment.yaml Outdated
Comment threadcharts/nextcloud/templates/deployment.yaml Outdated
Comment threadcharts/nextcloud/templates/deployment.yaml Outdated
Comment threadcharts/nextcloud/templates/deployment.yaml Outdated
Comment threadcharts/nextcloud/templates/deployment.yaml Outdated
@jessebot
jessebotforce-pushed the fix-default-fsgroup branch 5 times, most recently from 5a6eb60 to 4ee5f70CompareApril 23, 2023 19:55
@jessebotjessebot changed the title Only set the fsGroup to 82 if the image.flavor is fpm-alpineDon't set podSecurityContext.fsGroup by default; set nextcloud.securityContext by defaultApr 23, 2023
@jessebotjessebot changed the title Don't set podSecurityContext.fsGroup by default; set nextcloud.securityContext by defaultSet podSecurityContext.fsGroup to 33 by default; set nextcloud.securityContext by defaultApr 23, 2023
@jessebot
jessebotforce-pushed the fix-default-fsgroup branch from a5d1faa to 180635aCompareApril 23, 2023 20:11
@jessebotjessebot changed the title Set podSecurityContext.fsGroup to 33 by default; set nextcloud.securityContext by defaultSet podSecurityContext.fsGroup to 33 by defaultApr 23, 2023
@jessebot

Copy link
Copy Markdown
CollaboratorAuthor

just need to rebase to fix the commits, but this seems to be okay now I think

@jessebot
jessebotforce-pushed the fix-default-fsgroup branch from f6816df to 057c957CompareApril 23, 2023 21:24
@jessebotjessebot removed the help wanted Extra attention is needed label Apr 23, 2023
@provokateurin

Copy link
Copy Markdown
Member

The name of the commit/PR is a bit misleading because fsGroup was 33 by default if using apache, so nothing changes for those cases.

@jessebotjessebot changed the title Set podSecurityContext.fsGroup to 33 by defaultAlways podSecurityContext.fsGroup to 33, even if nginx is enabledApr 24, 2023
@jessebot

Copy link
Copy Markdown
CollaboratorAuthor

Fixed the PR and can fix the commits. does this work?

Always podSecurityContext.fsGroup to 33, even if nginx is enabled

Happy to change it to whatever makes most sense. Also, thank you again for all your patience through this. It's been a doozy 😅

@jessebot
jessebotforce-pushed the fix-default-fsgroup branch 2 times, most recently from 3f280fa to 2e62198CompareApril 24, 2023 14:15
@jessebot

Copy link
Copy Markdown
CollaboratorAuthor

fixed commit message :)

@jessebot
jessebotforce-pushed the fix-default-fsgroup branch from 2e62198 to 8f0fbf9CompareApril 24, 2023 14:50
@jessebot

jessebot commented Apr 24, 2023

Copy link
Copy Markdown
CollaboratorAuthor

Getting this error still in the linting step in the github workflow:

Run ct lint --config ct.yaml
ct lint --config ct.yaml
shell: /usr/bin/bash -e {0}
env:
CT_CONFIG_DIR: /opt/hostedtoolcache/ct/v3.8.0/x86_64/etc
VIRTUAL_ENV: /opt/hostedtoolcache/ct/v3.8.0/x86_64/venv
Linting charts...
Error: failed linting charts: failed identifying charts to process: failed running process: exit status 128
------------------------------------------------------------------------------------------------------------------------
No chart changes detected.
------------------------------------------------------------------------------------------------------------------------
failed linting charts: failed identifying charts to process: failed running process: exit status 128
Error: Process completed with exit code 1.

maybe it has something to do with the fact that we changed the default branch from master to main, and when I opened this PR, it was against "master" 🤔 I could open a new PR and see if it persists? 🤷

@jessebot

Copy link
Copy Markdown
CollaboratorAuthor

seems to be happening on another PR as well, checking something, going to do a test commit here

@jessebot

Copy link
Copy Markdown
CollaboratorAuthor

ok, fixed the additional warnings in #387 after testing here. Will undo the commit here where #387 is merged, then rebase again, and rerequest review after the GHA check is passing.

@jessebot
jessebotforce-pushed the fix-default-fsgroup branch from 477b13c to 8f0fbf9CompareApril 24, 2023 15:47
@jessebot

Copy link
Copy Markdown
CollaboratorAuthor

github actions queuing is so slow:
Screenshot 2023-04-24 at 17 53 33

@provokateurin

Copy link
Copy Markdown
Member

Yeah, Nextcloud uses a lot of GH actions and there is a max limit per org. I think some people are experimenting with adding our own runners to speed this up.

@jessebot

Copy link
Copy Markdown
CollaboratorAuthor

Oh, thank you for letting me know! Then I will not try to cancel and re-run them. Sorry about doing that earlier. I only tried to cancel and rerun one of them after it'd been over 15 minutes, because I thought there was something wrong with my own rate limiting, because I do a lot of stuff on github. 😅

@jessebot

Copy link
Copy Markdown
CollaboratorAuthor

CI finished, this is a working PR, finally!

Comment threadcharts/nextcloud/README.md Outdated
add note in README about alpine containers needing to change to 82 manually
this ensures our defaults work when using image.flavor fpm or apache
Signed-off-by: Jesse Hitch <jessebot@linux.com>
Signed-off-by: JesseBot <jessebot@linux.com>
Signed-off-by: Jesse Hitch <jessebot@linux.com>
@jessebot
jessebotforce-pushed the fix-default-fsgroup branch from 9d42830 to fa070ccCompareApril 29, 2023 01:16
Signed-off-by: JesseBot <jessebot@linux.com>
@jessebot

jessebot commented Nov 8, 2023

Copy link
Copy Markdown
CollaboratorAuthor

I haven't merged this because I switched to using the image.flavor: fpm-alpine exclusively, which doesn't have the issues with at least mounting PostgreSQL SSL certs, and then I started using s3 for the primary object store, so I stopped having to deal with backups running as root for nextcloud's persistent volumes, because I'm not using them anymore, which means I can't do a final test to make sure this is solid. If this is breaking anyone else's flow and they really need it, we can still resolve the conflicts and merge it, but I can't easily test this at this moment. I'll close this for now, but if others like, they can ask that I either reopen this, or submit their own PR. Apologies for all the back and forth Kate 💙

@jessebot

Copy link
Copy Markdown
CollaboratorAuthor

ok, I have to begrudgingly reopen this because I want to solve #367 but if this is not merged, then I cannot test using the fpm container with no nginx container.

@jessebotjessebot reopened this Nov 29, 2023
Signed-off-by: JesseBot <jessebot@linux.com>
@jessebotjessebot changed the title Always podSecurityContext.fsGroup to 33, even if nginx is enabledSet nextcloud.podSecurityContext.fsGroup to 33 by default and allow users to configure it if needed.Nov 29, 2023
Signed-off-by: JesseBot <jessebot@linux.com>
@jessebotjessebot mentioned this pull request Dec 1, 2023
@jessebotjessebot self-assigned this Jul 26, 2024
| `nextcloud.securityContext` | Optional security context for the NextCloud container | `nil` |
| `nextcloud.podSecurityContext` | Optional security context for the NextCloud pod (applies to all containers in the pod) | `nil` |
| `nextcloud.podSecurityContext` | Optional security context for the NextCloud pod (applies to all containers in the pod) | `{fsgroup: 33}` |
| `nextcloud.podSecurityContext.fsGroup` | special supplemental group that applies to all containers in the NextCloud pod | `33` |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated with the line above

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I combine the description of both? 🤔 Do you prefer we keep the parameter line of 141 or 142? (also congrats on being a collaborator now!! 🎉 )

# runAsUser: 33
# runAsGroup: 33
# runAsNonRoot: true
# readOnlyRootFilesystem: false

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is not part of podSecurityContext

{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
# this is deprecated and will be removed in a future release - use nextcloud.podSecurityContext instead

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we drop securityContext now? And announce it as a breaking change?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nextcloud-nginx container crashlooping after securityContext update; /var/www/html/config always owned by root

3 participants

@jessebot@provokateurin@wrenix