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

Fix solr security context #33

Merged
merged 4 commits into from
Feb 27, 2024
Merged

Fix solr security context #33

merged 4 commits into from
Feb 27, 2024

Conversation

BWibo
Copy link
Member

@BWibo BWibo commented Feb 24, 2024

We need to revert 313c09c in #24, as it breaks deployment of the chart (solr) due to file permission issues.
@eidottermihi @klml Is it possible to simply overwrite the defaults at deploytime? Most people don't use OpenShift and I want to keep the default set to values that work for most people. If it's just a config change for you, that would not hurt too much, right?

# -- [k8s: Security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)
podSecurityContext:
  runAsUser: 8983
  runAsGroup: 8983
  fsGroup: 8983

Have you tried:

# -- [k8s: Security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)
podSecurityContext:
  runAsUser: 0
  runAsGroup: 0
  fsGroup: 0

With latest helm version, even this might work now:

# -- [k8s: Security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)
podSecurityContext: {}

@BWibo BWibo added priority: soon type: fix Iterations on existing features or infrastructure. labels Feb 24, 2024
@BWibo BWibo self-assigned this Feb 24, 2024
@klml
Copy link
Contributor

klml commented Feb 26, 2024

@gislab-augsburg could you try using

podSecurityContext:
  runAsUser: null
  runAsGroup: null
  fsGroup: null

@BWibo
Copy link
Member Author

BWibo commented Feb 26, 2024

@klml @gislab-augsburg In OpenShift everything is owned by root, right?
If yes, this should probably work too:

# -- [k8s: Security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)
podSecurityContext:
  runAsUser: 0
  runAsGroup: 0
  fsGroup: 0

@klml
Copy link
Contributor

klml commented Feb 26, 2024

@BWibo

In OpenShift everything is owned by root, right?

No, the exact opposite. Openshift assigns arbitrary UIDs higher than 1000

@BWibo
Copy link
Member Author

BWibo commented Feb 26, 2024

OK, thx. Then my proposal of before is probably no option.

  • Does the value have to be null to allow setting OpenShift this to an arbitrary UID?
  • Can we assign a UUID in the valid range to get it running?

This could be another option worth testing:

# -- [k8s: Security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)
podSecurityContext:
  runAsUser: ""
  runAsGroup: ""
  fsGroup: ""

The problem is that the solr volume for persisting data is not owned by the correct user (which is set in the solr base image to UID 8983).

Executing /opt/docker-solr/scripts/solr-precreate ckan /opt/solr/server/solr/configsets/ckan
Copying solr.xml 
cp: cannot create regular file '/var/solr/data/solr.xml': Permission denied                                                                    
Stream closed EOF for bruno/solr-0 (solr)

So we could resolve this by implementing the same mechanism as in #32 and use an initContainer to fix the permissions. You can then overwrite this initContainer like you do for the ckan pod.

@BWibo BWibo changed the base branch from main to release/3.0.0 February 26, 2024 21:37
@BWibo BWibo mentioned this pull request Feb 26, 2024
2 tasks
@BWibo
Copy link
Member Author

BWibo commented Feb 27, 2024

I solved it as described above. @gislab-augsburg forget about testing the securityContext. But please try out the new approach with initContainer, just like we did for ckan in #32.

@BWibo BWibo merged commit a4b916b into release/3.0.0 Feb 27, 2024
@BWibo BWibo deleted the fix/solr-security-context branch March 2, 2024 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: soon type: fix Iterations on existing features or infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants