Skip to content

Commit

Permalink
Merge pull request #796 from verrazzano/karak/add_security_context_fo…
Browse files Browse the repository at this point in the history
…r_fluentbit

Add security context for fluenbit container
  • Loading branch information
adiforluls committed Jun 16, 2023
2 parents 7d5eabe + fed8efd commit 7820789
Show file tree
Hide file tree
Showing 9 changed files with 651 additions and 2 deletions.
2 changes: 2 additions & 0 deletions apis/fluentbit/v1alpha2/fluentbit_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ type FluentBitSpec struct {
Labels map[string]string `json:"labels,omitempty"`
// SecurityContext holds pod-level security attributes and common container settings.
SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"`
// ContainerSecurityContext holds container-level security attributes.
ContainerSecurityContext *corev1.SecurityContext `json:"containerSecurityContext,omitempty"`
// Host networking is requested for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified. Default to false.
HostNetwork bool `json:"hostNetwork,omitempty"`
// EnvVars represent environment variables that can be passed to fluentbit pods.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.3
creationTimestamp: null
name: fluentbits.fluentbit.fluent.io
spec:
group: fluentbit.fluent.io
Expand Down Expand Up @@ -883,6 +882,166 @@ spec:
containerLogRealPath:
description: Container log path
type: string
containerSecurityContext:
description: ContainerSecurityContext holds container-level security
attributes.
properties:
allowPrivilegeEscalation:
description: 'AllowPrivilegeEscalation controls whether a process
can gain more privileges than its parent process. This bool
directly controls if the no_new_privs flag will be set on the
container process. AllowPrivilegeEscalation is true always when
the container is: 1) run as Privileged 2) has CAP_SYS_ADMIN
Note that this field cannot be set when spec.os.name is windows.'
type: boolean
capabilities:
description: The capabilities to add/drop when running containers.
Defaults to the default set of capabilities granted by the container
runtime. Note that this field cannot be set when spec.os.name
is windows.
properties:
add:
description: Added capabilities
items:
description: Capability represent POSIX capabilities type
type: string
type: array
drop:
description: Removed capabilities
items:
description: Capability represent POSIX capabilities type
type: string
type: array
type: object
privileged:
description: Run container in privileged mode. Processes in privileged
containers are essentially equivalent to root on the host. Defaults
to false. Note that this field cannot be set when spec.os.name
is windows.
type: boolean
procMount:
description: procMount denotes the type of proc mount to use for
the containers. The default is DefaultProcMount which uses the
container runtime defaults for readonly paths and masked paths.
This requires the ProcMountType feature flag to be enabled.
Note that this field cannot be set when spec.os.name is windows.
type: string
readOnlyRootFilesystem:
description: Whether this container has a read-only root filesystem.
Default is false. Note that this field cannot be set when spec.os.name
is windows.
type: boolean
runAsGroup:
description: The GID to run the entrypoint of the container process.
Uses runtime default if unset. May also be set in PodSecurityContext. 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 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 PodSecurityContext. 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 PodSecurityContext. 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 windows.
format: int64
type: integer
seLinuxOptions:
description: The SELinux context to be applied to the container.
If unspecified, the container runtime will allocate a random
SELinux context for each container. May also be set in PodSecurityContext. 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 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 this container. If
seccomp options are provided at both the pod & container level,
the container options override the pod options. 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
windowsOptions:
description: The Windows specific settings applied to all containers.
If unspecified, the options from the PodSecurityContext 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
disableService:
description: DisableService tells if the fluentbit service should
be deployed.
Expand Down
4 changes: 4 additions & 0 deletions charts/fluent-operator/templates/fluentbit-fluentBit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ spec:
envVars:
{{ toYaml .Values.fluentbit.envVars | indent 4 }}
{{- end }}
{{- if .Values.fluentbit.securityContext }}
containerSecurityContext:
{{ toYaml .Values.fluentbit.securityContext | nindent 4 }}
{{- end }}
{{- with .Values.fluentbit.tolerations }}
tolerations:
{{ toYaml . | indent 4 }}
Expand Down
2 changes: 2 additions & 0 deletions charts/fluent-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ fluentbit:
secrets: []
# Pod security context for Fluent Bit pods. Ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
podSecurityContext: {}
# Security context for Fluent Bit container. Ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
securityContext: {}
# List of volumes that can be mounted by containers belonging to the pod.
additionalVolumes: []
# Pod volumes to mount into the container's filesystem.
Expand Down

0 comments on commit 7820789

Please sign in to comment.