Skip to content

Commit

Permalink
Run operator container as non-root (#777)
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Tomlinson <jtomlinson@nvidia.com>
  • Loading branch information
droctothorpe and jacobtomlinson committed Jul 26, 2023
1 parent 26e137a commit 1ff7534
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
6 changes: 6 additions & 0 deletions dask_kubernetes/operator/deployment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ WORKDIR /src/dask_kubernetes
# Install dependencies
RUN pip install .

# Add non-root user
RUN useradd -s /bin/bash dask

# Run container as non-root
USER 1000

# Start operator
ENTRYPOINT ["/usr/local/bin/kopf", "run", "-m", "dask_kubernetes.operator.controller"]
CMD ["--liveness=http://0.0.0.0:8080/healthz", "--verbose", "--all-namespaces"]
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ The following table lists the configurable parameters of the Dask-kubernetes-ope
| `rbac.cluster` | Creates a ClusterRole if true, else create a namespaced Role | `true` |
| `podAnnotations` | Extra annotations for the operator pod | `{}` |
| `podSecurityContext` | Security context for the operator pod | `{}` |
| `securityContext` | Security context for the operator container | `{}` |
| `securityContext.capabilities.drop` | | `["ALL"]` |
| `securityContext.runAsNonRoot` | | `true` |
| `securityContext.runAsUser` | | `1000` |
| `securityContext.allowPrivilegeEscalation` | | `false` |
| `resources` | Resources for the operator pod | `{}` |
| `volumes` | Volumes for the operator pod | `[]` |
| `volumeMounts` | Volume mounts for the operator container | `[]` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ podAnnotations: {} # Extra annotations for the operator pod
podSecurityContext: {} # Security context for the operator pod
# fsGroup: 2000

securityContext: {} # Security context for the operator container
# capabilities:
# drop:
# - ALL
securityContext: # Security context for the operator container
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 1000
allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

resources: {} # Resources for the operator pod
# We usually recommend not to specify default resources and to leave this as a conscious
Expand Down

0 comments on commit 1ff7534

Please sign in to comment.