opencadc / science-platform

Science Platform Infrastructure
GNU Affero General Public License v3.0
15 stars 29 forks source link

Explicit/refactored security contexts for containers #664

Closed rptaylor closed 3 months ago

rptaylor commented 4 months ago
kubectl explain pod.spec.securityContext
kubectl explain pod.spec.containers.securityContext

Things that can only be in pod securityContext: fsGroup, fsGroupChangePolicy supplementalGroups sysctls Things that can only be in container securityContext: allowPrivilegeEscalation capabilities
privileged
procMount readOnlyRootFilesystem Everything else can be in either, but pod-level properties apply to all containers by default unless overridden by the container securityContext.

From what I saw every pod spec of every job already had

      securityContext:
        runAsUser: ${skaha.posixid}
        runAsGroup: ${skaha.posixid}
        fsGroup: ${skaha.posixid}
        supplementalGroups: [${skaha.supgroups}]
        runAsNonRoot: true

so none of those need to be set again in containers, while OTOH other container-level security controls need to be applied.

This MR:

Overall this should make the different securityContexts more explicit and consistent and make Skaha more secure and portable.

rptaylor commented 4 months ago

@brianmajor