jedcunningham commented on code in PR #24588:
URL: https://github.com/apache/airflow/pull/24588#discussion_r973172870


##########
chart/templates/_helpers.yaml:
##########
@@ -755,33 +761,68 @@ runAsUser: {{ .uid }}
 
 {{/*
 Set the default value for workers chown for persistent storage
-If no value is passed for securityContext or <node>.securityContext, defaults 
to global uid and gid.
+If no value is passed for securityContexts.pod or <node>.securityContexts.pod 
or legacy securityContext and <node>.securityContext, defaults to global uid 
and gid.
 The template looks for `runAsUser` and `fsGroup` specifically, any other 
parameter will be ignored.
 
-    +------------------------+      +-----------------+      
+-------------------------+
-    | <node>.securityContext |  ->  | securityContext |  ->  | Values.uid + 
Values.gid |
-    +------------------------+      +-----------------+      
+-------------------------+
+    +------------------------+           +-----------------+    
+------------------------+           +-----------------+           
+----------------------+
+    | <node>.securityContexts.pod |  ->  | securityContexts.pod | 
<node>.securityContexts.pod |  ->  | securityContexts |  ->  | Values.uid + 
Values.gid |
+    +------------------------+           +-----------------+    
+------------------------+           +-----------------+           
+----------------------+
 
-Values are not accumulated meaning that if runAsUser is set to 10 in 
<node>.securityContext,
-any extra values set to securityContext or uid+gid will be ignored.
+Values are not accumulated meaning that if runAsUser is set to 10 in 
<node>.securityContexts.pod,
+any extra values set to securityContexts or uid+gid will be ignored.
 
 The template can be called like so:
-   include "airflowSecurityContextIds" (list . .Values.workers)
+   include "localPodSecurityContextsIds" (list . .Values.webserver)

Review Comment:
   ```suggestion
      include "airflowPodSecurityContextsIds" (list . .Values.webserver)
   ```



##########
chart/templates/_helpers.yaml:
##########
@@ -755,33 +761,68 @@ runAsUser: {{ .uid }}
 
 {{/*
 Set the default value for workers chown for persistent storage
-If no value is passed for securityContext or <node>.securityContext, defaults 
to global uid and gid.
+If no value is passed for securityContexts.pod or <node>.securityContexts.pod 
or legacy securityContext and <node>.securityContext, defaults to global uid 
and gid.
 The template looks for `runAsUser` and `fsGroup` specifically, any other 
parameter will be ignored.
 
-    +------------------------+      +-----------------+      
+-------------------------+
-    | <node>.securityContext |  ->  | securityContext |  ->  | Values.uid + 
Values.gid |
-    +------------------------+      +-----------------+      
+-------------------------+
+    +------------------------+           +-----------------+    
+------------------------+           +-----------------+           
+----------------------+
+    | <node>.securityContexts.pod |  ->  | securityContexts.pod | 
<node>.securityContexts.pod |  ->  | securityContexts |  ->  | Values.uid + 
Values.gid |
+    +------------------------+           +-----------------+    
+------------------------+           +-----------------+           
+----------------------+
 
-Values are not accumulated meaning that if runAsUser is set to 10 in 
<node>.securityContext,
-any extra values set to securityContext or uid+gid will be ignored.
+Values are not accumulated meaning that if runAsUser is set to 10 in 
<node>.securityContexts.pod,
+any extra values set to securityContexts or uid+gid will be ignored.
 
 The template can be called like so:
-   include "airflowSecurityContextIds" (list . .Values.workers)
+   include "localPodSecurityContextsIds" (list . .Values.webserver)
 
 Where `.` is the global variables scope and `.Values.workers` the local 
variables scope for the workers template.
 */}}
-{{- define "airflowSecurityContextIds" -}}
+{{- define "airflowPodSecurityContextsIds" -}}
   {{- $ := index . 0 -}}
   {{- with index . 1 }}
-    {{- if .securityContext -}}
-{{ pluck "runAsUser" .securityContext | first | default $.Values.uid }}:{{ 
pluck "fsGroup" .securityContext | first | default $.Values.gid }}
+    {{- if .securityContexts.pod -}}
+{{ pluck "runAsUser" .securityContexts.pod | first | default $.Values.uid 
}}:{{ pluck "fsGroup" .securityContexts.pod | first | default $.Values.gid }}
+    {{- else if $.Values.securityContext -}}
+{{ pluck "runAsUser" $.Values.securityContext | first | default $.Values.uid 
}}:{{ pluck "fsGroup" $.Values.securityContext | first | default $.Values.gid }}
+    {{- else if $.Values.securityContexts.pod -}}
+{{ pluck "runAsUser" $.Values.securityContexts.pod | first | default 
$.Values.uid }}:{{ pluck "fsGroup" $.Values.securityContexts.pod | first | 
default $.Values.gid }}
     {{- else if $.Values.securityContext -}}
 {{ pluck "runAsUser" $.Values.securityContext | first | default $.Values.uid 
}}:{{ pluck "fsGroup" $.Values.securityContext | first | default $.Values.gid }}
     {{- else -}}
 {{ $.Values.uid }}:{{ $.Values.gid }}
     {{- end -}}
   {{- end -}}
 {{- end -}}
+
+{{/*
+Set the default value for container securityContext
+If no value is passed for securityContexts.container or 
<node>.securityContexts.container, defaults to deny privileges escallation and 
dropping all POSIX capabilities.
+
+    +------------------------+                +-----------------+              
  +-------------------------+
+    | <node>.securityContexts.container |  ->  | securityContexts.container |  
->  | allowPrivilegesEscalation: false, capabilities.drop: [ALL]|
+    +------------------------+                +-----------------+              
  +-------------------------+
+
+
+The template can be called like so:
+   include "airflowContainerSecurityContext" (list . .Values.statsd)
+
+Where `.` is the global variables scope and `.Values.webserver` the local 
variables scope for the webserver template.
+*/}}
+{{- define "airflowContainerSecurityContext" -}}

Review Comment:
   I wonder if we should call this `containerSecurityContext` instead, since 
it's used for more than just Airflow containers?



##########
chart/templates/_helpers.yaml:
##########
@@ -755,33 +761,68 @@ runAsUser: {{ .uid }}
 
 {{/*
 Set the default value for workers chown for persistent storage
-If no value is passed for securityContext or <node>.securityContext, defaults 
to global uid and gid.
+If no value is passed for securityContexts.pod or <node>.securityContexts.pod 
or legacy securityContext and <node>.securityContext, defaults to global uid 
and gid.
 The template looks for `runAsUser` and `fsGroup` specifically, any other 
parameter will be ignored.
 
-    +------------------------+      +-----------------+      
+-------------------------+
-    | <node>.securityContext |  ->  | securityContext |  ->  | Values.uid + 
Values.gid |
-    +------------------------+      +-----------------+      
+-------------------------+
+    +------------------------+           +-----------------+    
+------------------------+           +-----------------+           
+----------------------+
+    | <node>.securityContexts.pod |  ->  | securityContexts.pod | 
<node>.securityContexts.pod |  ->  | securityContexts |  ->  | Values.uid + 
Values.gid |
+    +------------------------+           +-----------------+    
+------------------------+           +-----------------+           
+----------------------+
 
-Values are not accumulated meaning that if runAsUser is set to 10 in 
<node>.securityContext,
-any extra values set to securityContext or uid+gid will be ignored.
+Values are not accumulated meaning that if runAsUser is set to 10 in 
<node>.securityContexts.pod,
+any extra values set to securityContexts or uid+gid will be ignored.
 
 The template can be called like so:
-   include "airflowSecurityContextIds" (list . .Values.workers)
+   include "localPodSecurityContextsIds" (list . .Values.webserver)
 
 Where `.` is the global variables scope and `.Values.workers` the local 
variables scope for the workers template.
 */}}
-{{- define "airflowSecurityContextIds" -}}
+{{- define "airflowPodSecurityContextsIds" -}}
   {{- $ := index . 0 -}}
   {{- with index . 1 }}
-    {{- if .securityContext -}}
-{{ pluck "runAsUser" .securityContext | first | default $.Values.uid }}:{{ 
pluck "fsGroup" .securityContext | first | default $.Values.gid }}
+    {{- if .securityContexts.pod -}}
+{{ pluck "runAsUser" .securityContexts.pod | first | default $.Values.uid 
}}:{{ pluck "fsGroup" .securityContexts.pod | first | default $.Values.gid }}
+    {{- else if $.Values.securityContext -}}
+{{ pluck "runAsUser" $.Values.securityContext | first | default $.Values.uid 
}}:{{ pluck "fsGroup" $.Values.securityContext | first | default $.Values.gid }}
+    {{- else if $.Values.securityContexts.pod -}}
+{{ pluck "runAsUser" $.Values.securityContexts.pod | first | default 
$.Values.uid }}:{{ pluck "fsGroup" $.Values.securityContexts.pod | first | 
default $.Values.gid }}
     {{- else if $.Values.securityContext -}}
 {{ pluck "runAsUser" $.Values.securityContext | first | default $.Values.uid 
}}:{{ pluck "fsGroup" $.Values.securityContext | first | default $.Values.gid }}
     {{- else -}}
 {{ $.Values.uid }}:{{ $.Values.gid }}
     {{- end -}}
   {{- end -}}
 {{- end -}}
+
+{{/*
+Set the default value for container securityContext
+If no value is passed for securityContexts.container or 
<node>.securityContexts.container, defaults to deny privileges escallation and 
dropping all POSIX capabilities.
+
+    +------------------------+                +-----------------+              
  +-------------------------+
+    | <node>.securityContexts.container |  ->  | securityContexts.container |  
->  | allowPrivilegesEscalation: false, capabilities.drop: [ALL]|
+    +------------------------+                +-----------------+              
  +-------------------------+
+
+
+The template can be called like so:
+   include "airflowContainerSecurityContext" (list . .Values.statsd)
+
+Where `.` is the global variables scope and `.Values.webserver` the local 
variables scope for the webserver template.
+*/}}
+{{- define "airflowContainerSecurityContext" -}}

Review Comment:
   Wait, this isn't even used? Let's drop it?



##########
chart/templates/_helpers.yaml:
##########
@@ -703,26 +703,30 @@ Create the name of the cleanup service account to use
 {{- end -}}
 
 {{/*
-Set the default value for securityContext
-If no value is passed for securityContext or <node>.securityContext, defaults 
to global uid and gid.
+Set the default value for pod securityContext
+If no value is passed for securityContexts.pod or <node>.securityContexts.pod 
or legacy securityContext and <node>.securityContext, defaults to global uid 
and gid.
 
-    +------------------------+      +-----------------+      
+-------------------------+
-    | <node>.securityContext |  ->  | securityContext |  ->  | Values.uid + 
Values.gid |
-    +------------------------+      +-----------------+      
+-------------------------+
+    +------------------------+           +-----------------+             
+-----------------+           +-----------------+      
+-------------------------+
+    | <node>.securityContexts.pod |  ->  | <node>.securityContext |  ->  | 
securityContexts.pod |  ->  | securityContext |  ->  | Values.uid + Values.gid |
+    +------------------------+           +-----------------+             
+-----------------+           +-----------------+      
+-------------------------+

Review Comment:
   ```suggestion
       +-----------------------------+      +------------------------+      
+----------------------+      +-----------------+      
+-------------------------+
       | <node>.securityContexts.pod |  ->  | <node>.securityContext |  ->  | 
securityContexts.pod |  ->  | securityContext |  ->  | Values.uid + Values.gid |
       +-----------------------------+      +------------------------+      
+----------------------+      +-----------------+      
+-------------------------+
   ```
   
   nit: let's keep these prettty



##########
chart/templates/_helpers.yaml:
##########
@@ -733,20 +737,22 @@ fsGroup: {{ $.Values.gid }}
 {{- end -}}
 
 {{/*
-Set the default value for securityContext
-If no value is passed for securityContext or <node>.securityContext, defaults 
to UID in the local node.
+Set the default value for pod securityContext
+If no value is passed for <node>.securityContexts.pod or 
<node>.securityContext, defaults to UID in the local node.
 
-    +------------------------+     +-------------+
-    | <node>.securityContext |  >  | <node>.uid  |
-    +------------------------+     +-------------+
+    +------------------------+           +-----------------+            
+-------------+
+    | <node>.securityContexts.pod |  ->  | <node>.securityContext |  >  | 
<node>.uid  |
+    +------------------------+           +-----------------+            
+-------------+

Review Comment:
   ```suggestion
       +-----------------------------+      +------------------------+      
+-------------+
       | <node>.securityContexts.pod |  ->  | <node>.securityContext |  ->  | 
<node>.uid  |
       +-----------------------------+      +------------------------+      
+-------------+
   ```
   
   (I'm not going to do the rest via suggestions, but you get the idea)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to