shy-guitar-84777
05/31/2024, 2:49 PMaverage-finland-92144
05/31/2024, 4:12 PMdefault
container name in the PodTemplate will turn its spec into what Flyte uses for all containers in a Pod, not only the primary. I'll try to repro this behavior and will let you knowshy-guitar-84777
06/01/2024, 3:16 PMshy-guitar-84777
06/03/2024, 7:28 AMname="default"
in the PodTemplate seems to create another container, without affecting the others...shy-guitar-84777
06/03/2024, 3:35 PMaverage-finland-92144
06/04/2024, 11:44 AMshy-guitar-84777
06/04/2024, 3:20 PMaverage-finland-92144
06/04/2024, 3:40 PMPodTemplate
definitionshy-guitar-84777
06/04/2024, 3:48 PMapiVersion: v1
kind: PodTemplate
metadata:
name: flyte-template
namespace: flyte
template:
spec:
securityContext:
runAsNonRoot: true
seccompProfile:
type: "RuntimeDefault"
runAsUser: 1000
containers:
- name: default
image: <http://docker.io/rwgrim/docker-noop|docker.io/rwgrim/docker-noop>
securityContext:
allowPrivilegeEscalation: false
privileged: false
runAsNonRoot: true
capabilities:
drop:
- SYS_PTRACE
- ALL
And these are defintions in the workflow-python-file:
1. The template
pod_template_data_management = Pod(
pod_spec=V1PodSpec(
containers=[
V1Container(
name="primary",
resources=V1ResourceRequirements(
limits={"memory": "16Gi", "cpu": "0.8"},
requests={"memory": "500Mi", "cpu": "0.25"},
),
image_pull_policy="Always",
)
],
image_pull_secrets=[
# the secrets referenced here must be defined beforehand (in the flux-config repository)
V1LocalObjectReference("imagepullsecrets")
],
# node_selector = {"<http://kubernetes.io/hostname|kubernetes.io/hostname>" : "srv-k8s-test-cpu1"}
),
)
2. The task itself, using both the runtime (flyte-template
) and compile time (pod_template_data_management
) templates
download_data_from_minio = ContainerTask(
name="DownloadData",
image=FLYTE_IMAGE,
command=["python", "-m", "src.download_data"],
arguments=["--file_prefix", "{{.inputs.file_prefix}}",
"--bucket_name", "{{.inputs.bucket_name}}",
"--output_path", MOUNT_PATH,
"--output_filename", "kodi_preprocessed_data",
'-vvvv'
],
output_data_dir=MOUNT_PATH,
inputs=kwtypes(
file_prefix = str,
bucket_name = str
),
outputs=kwtypes(
kodi_preprocessed_data=FlyteFile
),
pod_template=pod_template_data_management,
pod_template_name="flyte-template"
)
average-finland-92144
06/04/2024, 3:57 PMplugins.k8s.default-pod-template-name
key?shy-guitar-84777
06/04/2024, 4:03 PMplugins.k8s.default-security-context
and plugins.k8s.default-pod-security-context
(i.e. setting the security-context parameters directly there) but that didn't work (perhaps it's not correct at all).
ok so I can try setting plugins.k8s.default-pod-template-name
! (didnt do so as I thought it would be redundant to using it in the task directly). Would then pod_template_name=...
in the task definition be unnecessary?shy-guitar-84777
06/04/2024, 4:03 PMaverage-finland-92144
06/04/2024, 4:05 PMshy-guitar-84777
06/04/2024, 4:06 PMshy-guitar-84777
06/06/2024, 8:58 AMaverage-finland-92144
06/06/2024, 11:00 AMshy-guitar-84777
06/06/2024, 11:47 AMsecurityContext.capabilities.add=['SYS_PTRACE']
, and even though I can effectively override it by coniguring the podTemplate (securityContext.capabilities.drop=['SYS_PTRACE']
), the original add-statement remains in the manifest and makes the PodSecurity Admission Controller complain about it (even in the baseline version).average-finland-92144
06/06/2024, 7:36 PMshy-guitar-84777
06/07/2024, 7:53 AMsecurityContext:
allowPrivilegeEscalation: false
capabilities:
add:
- SYS_PTRACE
drop:
- SYS_PTRACE
- ALL
The relevant part in the template is
containers:
- name: default
securityContext:
drop:
- SYS_PTRACE
- ALL
I also had a quick look at the source code, looks like the cap is added in flyteplugins/go/tasks/pluginmachinery/flytek8s/copilot.go as follows
var pTraceCapability = v1.Capability("SYS_PTRACE")
<.....>
c.SecurityContext.Capabilities.Add = append(c.SecurityContext.Capabilities.Add, pTraceCapability)
Doesn't seem to be configurable...
Thanks!shy-guitar-84777
06/07/2024, 8:09 AMaverage-finland-92144
06/07/2024, 3:17 PMshy-guitar-84777
06/07/2024, 3:23 PMaverage-finland-92144
06/07/2024, 3:23 PMshy-guitar-84777
06/10/2024, 9:51 AMaverage-finland-92144
06/11/2024, 7:21 PMshy-guitar-84777
06/17/2024, 7:44 AMshy-guitar-84777
06/17/2024, 11:50 AMmake build_native_flyte
is doing what I want! Should we discuss in github from now on? (the link to the issue above)? I posted another question there (regarding how to set the config for SYS_PTRACE).average-finland-92144
06/17/2024, 12:13 PMshy-guitar-84777
06/17/2024, 12:14 PMstraight-alligator-31443
06/17/2024, 2:47 PM6/14/2024 3:13:01 PM UTC task submitted to K8s
6/14/2024 3:13:01 PM UTC POD_UNSUPPORTED_ON_FARGATE:Pod not supported on Fargate: invalid SecurityContext fields: Capabilities added: SYS_PTRACE
Will this fix my issue as well? For now i have created a flytekit wrapper around the R code and triggered subprocess for the R scripts i need.
Just wondering if down the line i can switch to raw containers itself.shy-guitar-84777
06/17/2024, 2:50 PMstraight-alligator-31443
06/17/2024, 2:50 PMshy-guitar-84777
06/17/2024, 2:53 PM