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

Flyte-agent configure pod securityContext #4785

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions charts/flyteagent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ A Helm chart for Flyte agent
| podAnnotations | object | `{}` | Annotations for flyteagent pods |
| podEnv | object | `{}` | Additional flyteagent pod container environment variables |
| podLabels | object | `{}` | Labels for flyteagent pods |
| podSecurityContext | object | `{}` | Security context for pod |
| ports.containerPort | int | `8000` | |
| ports.name | string | `"agent-grpc"` | |
| priorityClassName | string | `""` | Sets priorityClassName for datacatalog pod(s). |
| replicaCount | int | `1` | Replicas count for flyteagent deployment |
| resources | object | `{"limits":{"cpu":"500m","ephemeral-storage":"200Mi","memory":"200Mi"},"requests":{"cpu":"500m","ephemeral-storage":"200Mi","memory":"200Mi"}}` | Default resources requests and limits for flyteagent deployment |
| securityContext | object | `{"allowPrivilegeEscalation":false}` | Security context for container |
| service | object | `{"annotations":{"projectcontour.io/upstream-protocol.h2c":"grpc"},"type":"ClusterIP"}` | Service settings for flyteagent |
| serviceAccount | object | `{"annotations":{},"create":true,"imagePullSecrets":[]}` | Configuration for service accounts for flyteagent |
| serviceAccount.annotations | object | `{}` | Annotations for ServiceAccount attached to flyteagent pods |
Expand Down
4 changes: 4 additions & 0 deletions charts/flyteagent/templates/agent/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ spec:
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- command:
- pyflyte
Expand All @@ -36,6 +38,8 @@ spec:
ports:
- containerPort: {{ .Values.ports.containerPort }}
name: {{ .Values.ports.name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
resources: {{- toYaml .Values.resources | nindent 10 }}
{{- with .Values.additionalVolumeMounts -}}
{{ tpl (toYaml .) $ | nindent 8 }}
Expand Down
5 changes: 5 additions & 0 deletions charts/flyteagent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ serviceAccount:
annotations: {}
# -- ImagePullSecrets to automatically assign to the service account
imagePullSecrets: []
# -- Security context for pod
podSecurityContext: {}
# -- Security context for container
securityContext:
allowPrivilegeEscalation: false
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally the container also needs no Linux caps and this would drop like

capabilities:
     drop:
     - ALL

But given I'm not super familiar with what's inside your agent code (and considering there are more than just "default" agents), I left it off as a default. The most common caps I've seen containers need added back are CAP_CHOWN and CAP_MKNOD. CAP_CHOWN generally results from the container image being setup incorrectly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to test this in your branch? I don't think the CI will catch a potential problem, but in general, I don't see the Task containers needing root caps so dropping all should be fine.
@pingsutw do you see the Agent needing elevated permissions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using a Python-based agent (based on the Flytekit SDK examples), we haven't seen it require any of the default container capabilities. Note that depending on whether or not you're on containerd or cri-o, the defaults are different. OpenShift maintains a smaller list -- so if you have customers on OpenShift that should be good signal that you don't need things like NET_ADMIN

# -- Annotations for flyteagent pods
podAnnotations: {}
# -- Additional flyteagent pod container environment variables
Expand Down
4 changes: 4 additions & 0 deletions deployment/agent/flyte_agent_helm_generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ spec:
helm.sh/chart: flyteagent-v0.1.10
app.kubernetes.io/managed-by: Helm
spec:
securityContext:
{}
containers:
- command:
- pyflyte
Expand All @@ -84,6 +86,8 @@ spec:
ports:
- containerPort: 8000
name: agent-grpc
securityContext:
allowPrivilegeEscalation: false
resources:
limits:
cpu: 500m
Expand Down
Loading