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

Add .spec.podSecurityContext flag #473

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions api/v1/openlibertyapplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ type OpenLibertyApplicationSpec struct {
// Security context for the application container.
// +operator-sdk:csv:customresourcedefinitions:order=29,type=spec,displayName="Security Context"
SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"`

// Security context for the application pod.
// +operator-sdk:csv:customresourcedefinitions:order=30,type=spec,displayName="Pod Security Context"
PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"`
}

// Define health checks on application container to determine whether it is alive or ready to receive traffic
Expand Down Expand Up @@ -1079,6 +1083,11 @@ func (cr *OpenLibertyApplication) GetSecurityContext() *corev1.SecurityContext {
return cr.Spec.SecurityContext
}

// GetPodSecurityContext returns pod security context
func (cr *OpenLibertyApplication) GetPodSecurityContext() *corev1.PodSecurityContext {
return cr.Spec.PodSecurityContext
}

// GetSemeruCloudCompiler returns the Semeru Cloud Compiler configuration
func (cr *OpenLibertyApplication) GetSemeruCloudCompiler() *OpenLibertyApplicationSemeruCloudCompiler {
return cr.Spec.SemeruCloudCompiler
Expand Down
163 changes: 163 additions & 0 deletions bundle/manifests/apps.openliberty.io_openlibertyapplications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2966,6 +2966,169 @@ spec:
is allowed from.
type: object
type: object
podSecurityContext:
description: Security context for the application pod.
properties:
fsGroup:
description: "A special supplemental group that applies to all
containers in a pod. Some volume types allow the Kubelet to
change the ownership of that volume to be owned by the pod:
\n 1. The owning GID will be the FSGroup 2. The setgid bit is
set (new files created in the volume will be owned by FSGroup)
3. The permission bits are OR'd with rw-rw---- \n If unset,
the Kubelet will not modify the ownership and permissions of
any volume. Note that this field cannot be set when spec.os.name
is windows."
format: int64
type: integer
fsGroupChangePolicy:
description: 'fsGroupChangePolicy defines behavior of changing
ownership and permission of the volume before being exposed
inside Pod. This field will only apply to volume types which
support fsGroup based ownership(and permissions). It will have
no effect on ephemeral volume types such as: secret, configmaps
and emptydir. Valid values are "OnRootMismatch" and "Always".
If not specified, "Always" is used. Note that this field cannot
be set when spec.os.name is windows.'
type: string
runAsGroup:
description: The GID to run the entrypoint of the container process.
Uses runtime default if unset. May also be set in SecurityContext. If
set in both SecurityContext and PodSecurityContext, the value
specified in SecurityContext takes precedence for that container.
Note that this field cannot be set when spec.os.name is windows.
format: int64
type: integer
runAsNonRoot:
description: Indicates that the container must run as a non-root
user. If true, the Kubelet will validate the image at runtime
to ensure that it does not run as UID 0 (root) and fail to start
the container if it does. If unset or false, no such validation
will be performed. May also be set in SecurityContext. If set
in both SecurityContext and PodSecurityContext, the value specified
in SecurityContext takes precedence.
type: boolean
runAsUser:
description: The UID to run the entrypoint of the container process.
Defaults to user specified in image metadata if unspecified.
May also be set in SecurityContext. If set in both SecurityContext
and PodSecurityContext, the value specified in SecurityContext
takes precedence for that container. Note that this field cannot
be set when spec.os.name is windows.
format: int64
type: integer
seLinuxOptions:
description: The SELinux context to be applied to all containers.
If unspecified, the container runtime will allocate a random
SELinux context for each container. May also be set in SecurityContext. If
set in both SecurityContext and PodSecurityContext, the value
specified in SecurityContext takes precedence for that container.
Note that this field cannot be set when spec.os.name is windows.
properties:
level:
description: Level is SELinux level label that applies to
the container.
type: string
role:
description: Role is a SELinux role label that applies to
the container.
type: string
type:
description: Type is a SELinux type label that applies to
the container.
type: string
user:
description: User is a SELinux user label that applies to
the container.
type: string
type: object
seccompProfile:
description: The seccomp options to use by the containers in this
pod. Note that this field cannot be set when spec.os.name is
windows.
properties:
localhostProfile:
description: localhostProfile indicates a profile defined
in a file on the node should be used. The profile must be
preconfigured on the node to work. Must be a descending
path, relative to the kubelet's configured seccomp profile
location. Must only be set if type is "Localhost".
type: string
type:
description: "type indicates which kind of seccomp profile
will be applied. Valid options are: \n Localhost - a profile
defined in a file on the node should be used. RuntimeDefault
- the container runtime default profile should be used.
Unconfined - no profile should be applied."
type: string
required:
- type
type: object
supplementalGroups:
description: A list of groups applied to the first process run
in each container, in addition to the container's primary GID. If
unspecified, no groups will be added to any container. Note
that this field cannot be set when spec.os.name is windows.
items:
format: int64
type: integer
type: array
sysctls:
description: Sysctls hold a list of namespaced sysctls used for
the pod. Pods with unsupported sysctls (by the container runtime)
might fail to launch. Note that this field cannot be set when
spec.os.name is windows.
items:
description: Sysctl defines a kernel parameter to be set
properties:
name:
description: Name of a property to set
type: string
value:
description: Value of a property to set
type: string
required:
- name
- value
type: object
type: array
windowsOptions:
description: The Windows specific settings applied to all containers.
If unspecified, the options within a container's SecurityContext
will be used. If set in both SecurityContext and PodSecurityContext,
the value specified in SecurityContext takes precedence. Note
that this field cannot be set when spec.os.name is linux.
properties:
gmsaCredentialSpec:
description: GMSACredentialSpec is where the GMSA admission
webhook (https://github.com/kubernetes-sigs/windows-gmsa)
inlines the contents of the GMSA credential spec named by
the GMSACredentialSpecName field.
type: string
gmsaCredentialSpecName:
description: GMSACredentialSpecName is the name of the GMSA
credential spec to use.
type: string
hostProcess:
description: HostProcess determines if a container should
be run as a 'Host Process' container. This field is alpha-level
and will only be honored by components that enable the WindowsHostProcessContainers
feature flag. Setting this field without the feature flag
will result in errors when validating the Pod. All of a
Pod's containers must have the same effective HostProcess
value (it is not allowed to have a mix of HostProcess containers
and non-HostProcess containers). In addition, if HostProcess
is true then HostNetwork must also be set to true.
type: boolean
runAsUserName:
description: The UserName in Windows to run the entrypoint
of the container process. Defaults to the user specified
in image metadata if unspecified. May also be set in PodSecurityContext.
If set in both SecurityContext and PodSecurityContext, the
value specified in SecurityContext takes precedence.
type: string
type: object
type: object
probes:
description: Define health checks on application container to determine
whether it is alive or ready to receive traffic
Expand Down
5 changes: 4 additions & 1 deletion bundle/manifests/open-liberty.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ metadata:
categories: Application Runtime
certified: "true"
containerImage: icr.io/appcafe/open-liberty-operator:daily
createdAt: "2023-08-22T16:39:10Z"
createdAt: "2023-09-29T15:16:07Z"
description: Deploy and manage containerized Liberty applications
olm.skipRange: '>=0.8.0 <1.2.2'
operators.openshift.io/infrastructure-features: '["disconnected"]'
Expand Down Expand Up @@ -411,6 +411,9 @@ spec:
- description: Security context for the application container.
displayName: Security Context
path: securityContext
- description: Security context for the application pod.
displayName: Pod Security Context
path: podSecurityContext
- description: Labels to set on ServiceMonitor.
displayName: Monitoring Labels
path: monitoring.labels
Expand Down
Loading