-
Notifications
You must be signed in to change notification settings - Fork 16.4k
feat(KubernetesPodOperator): Add support of container_security_context #25530
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
feat(KubernetesPodOperator): Add support of container_security_context #25530
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
|
|
@uranusjr please ☀️ |
|
You didn’t answer why you changed the |
@uranusjr I was answed you ..... I re-copy here my previous answer, please read it => @uranusjr Why => Because for me that was incorrect but isn't related to my main change as I write previously. The variable security_context is injected on k8s.V1PodSpec => Look API documentation of K8s and you can see that security_context don't have a property securityContext => https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1PodSpec.md Perhaps we must change the type of security_context & container_security_context on class KubernetesPodOperator that is actually defined as Dict security_context: Optional[Dict] = None, container_security_context: Optional[Dict] = None, Should be more safer to declare it as is security_context: Optional[k8s.V1PodSecurityContext] = None, container_security_context: Optional[k8s.V1SecurityContext] = None, But should make on a different PR is you approved to change types |
This is the context I was looking for. |
|
Awesome work, congrats on your first merged pull request! |
Allow to define a container security context on KubernetesPodOperator.
Why:
On clusters restricted with strong security policy, pods cannot be executed without disable privilege escalation.
About test :
I successfully run locally there tests : tests/providers/cncf/kubernetes/operators/test_kubernetes_pod.py
But I was not able to run tests kubernetes_tests/test_kubernetes_pod_operator.py :-(