@@ -86,6 +86,8 @@ type CDAPMasterSpec struct {
86
86
// To disable this service: either omit or set the field to nil
87
87
// To enable this service: set it to a pointer to a AuthenticationSpec struct (can be an empty struct)
88
88
Authentication * AuthenticationSpec `json:"authentication,omitempty"`
89
+ // SecurityContext defines the security context for all pods for all services.
90
+ SecurityContext * SecurityContext `json:"securityContext,omitempty"`
89
91
}
90
92
91
93
// CDAPServiceSpec defines the base set of specifications applicable to all master services.
@@ -115,6 +117,8 @@ type CDAPServiceSpec struct {
115
117
// Key is the secret object name. Value is the mount path.
116
118
// This adds Secret data to the directory specified by the volume mount path.
117
119
SecretVolumes map [string ]string `json:"secretVolumes,omitempty"`
120
+ // SecurityContext overrides the security context for the service pods.
121
+ SecurityContext * SecurityContext `json:"securityContext,omitempty"`
118
122
}
119
123
120
124
// CDAPScalableServiceSpec defines the base specification for master services that can have more than one instance.
@@ -230,6 +234,32 @@ type CDAPMasterList struct {
230
234
Items []CDAPMaster `json:"items"`
231
235
}
232
236
237
+ // SecurityContext defines fields for setting corev1.SecurityContext for containers and
238
+ // corev1.PodSecurityContext for pods.
239
+ // For additional information, see https://kubernetes.io/docs/tasks/configure-pod-container/security-context/.
240
+ type SecurityContext struct {
241
+ // RunAsUser runs the pod as the specified user ID. It is applied at the pod level.
242
+ RunAsUser * int64 `json:"runAsUser,omitempty"`
243
+ // RunAsGroup runs the pod as the specified group ID. It is applied at the pod level.
244
+ RunAsGroup * int64 `json:"runAsGroup,omitempty"`
245
+ // FSGroup mounts volumes as the specified group ID and gives the primary user access
246
+ // to that group. It is applied at the pod level.
247
+ FSGroup * int64 `json:"fsGroup,omitempty"`
248
+ // AllowPrivilegeEscalation prevents the container process from running SUID binaries.
249
+ // It is applied at the container level.
250
+ AllowPrivilegeEscalation * bool `json:"allowPrivilegeEscalation,omitempty"`
251
+ // RunAsNonRoot indicates that the container must run as a non-root user.
252
+ // If true, the Kubelet will validate the image at runtime to ensure that it
253
+ // does not run as UID 0 (root) and fail to start the container if it does.
254
+ RunAsNonRoot * bool `json:"runAsNonRoot,omitempty"`
255
+ // Privileged runs container in privileged mode. It is applied at the container level.
256
+ // Processes in privileged containers are essentially equivalent to root on the host.
257
+ Privileged * bool `json:"privileged,omitempty"`
258
+ // ReadOnlyRootFilesystem specifies whether the container's root filesystem is read-only.
259
+ // It is applied at the container level.
260
+ ReadOnlyRootFilesystem * bool `json:"readOnlyRootFilesystem,omitempty"`
261
+ }
262
+
233
263
func init () {
234
264
SchemeBuilder .Register (& CDAPMaster {}, & CDAPMasterList {})
235
265
}
0 commit comments