Skip to content

Commit

Permalink
[Fluent-Bit] Improve Openshift support, allow to use existing SCCs (#380
Browse files Browse the repository at this point in the history
)

* Improve Openshift support, allow to use existing SCCs

- Add ability to provide existing SecurityContextConstraints name
  instead of create new one
- Add ability to add annotations for SecrutiryContextConstraints
  resource, created with the chart
- Add common labels for SecurityContextConstraints
- Improve variables naming
- Bump up chart version

Signed-off-by: Kirill Thirteen <[email protected]>

* fix openshift SCC template

Signed-off-by: Kirill Thirteen <[email protected]>

* fixes according to suggestions

Signed-off-by: Kirill Thirteen <[email protected]>

* fluent-bit: enable creation of SCC by default, while running in OpenShift

Signed-off-by: Kirill Thirteen <[email protected]>

---------

Signed-off-by: Kirill Thirteen <[email protected]>
Signed-off-by: Kirill Thirteen <[email protected]>
Co-authored-by: Kirill Thirteen <[email protected]>
  • Loading branch information
thethir13en and Kirill Thirteen authored Jul 5, 2023
1 parent 36ce963 commit 5b70817
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
6 changes: 3 additions & 3 deletions charts/fluent-bit/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ keywords:
- logging
- fluent-bit
- fluentd
version: 0.34.1
version: 0.34.2
appVersion: 2.1.6
icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/fluentd/fluentbit/icon/fluentbit-icon-color.svg
home: https://fluentbit.io/
Expand All @@ -22,5 +22,5 @@ maintainers:
email: [email protected]
annotations:
artifacthub.io/changes: |
- kind: fixed
description: "Removed duplicated volumeMounts key in reloader container."
- kind: added
description: "Added support for using an existing SecurityContextConstraints for OpenShift."
11 changes: 11 additions & 0 deletions charts/fluent-bit/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,14 @@ autoscaling/v2beta2
autoscaling/v2
{{- end -}}
{{- end -}}

{{/*
Create the name of OpenShift SecurityContextConstraints to use
*/}}
{{- define "fluent-bit.openShiftSccName" -}}
{{- if not .Values.openShift.securityContextConstraints.create -}}
{{- printf "%s" .Values.openShift.securityContextConstraints.existingName -}}
{{- else -}}
{{- printf "%s" default (include "fluent-bit.fullname" .) .Values.openShift.securityContextConstraints.name -}}
{{- end -}}
{{- end -}}
4 changes: 2 additions & 2 deletions charts/fluent-bit/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ rules:
verbs:
- use
{{- end }}
{{- if and .Values.openShift.enabled .Values.openShift.securityContextConstraints.create }}
{{- if .Values.openShift.enabled }}
- apiGroups:
- security.openshift.io
resources:
- securitycontextconstraints
resourceNames:
- {{ include "fluent-bit.fullname" . }}
- {{ include "fluent-bit.openShiftSccName" . }}
verbs:
- use
{{- end }}
Expand Down
16 changes: 10 additions & 6 deletions charts/fluent-bit/templates/scc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
apiVersion: security.openshift.io/v1
kind: SecurityContextConstraints
metadata:
name: {{ include "fluent-bit.fullname" . }}
{{- if .Values.openShift.securityContextConstraints.annotations }}
name: {{ include "fluent-bit.openShiftSccName" . }}
labels:
{{- include "fluent-bit.labels" . | nindent 4 }}
{{- with .Values.openShift.securityContextConstraints.annotations }}
annotations:
{{- toYaml .Values.openShift.securityContextConstraints.annotations | nindent 4 }}
{{- end }}
{{- toYaml . | nindent 4 }}
{{- end }}
allowPrivilegedContainer: true
allowPrivilegeEscalation: true
allowHostDirVolumePlugin: true
Expand All @@ -18,10 +20,10 @@ allowHostPorts: false
allowHostPID: false
allowedCapabilities: []
forbiddenSysctls:
- "*"
- "*"
readOnlyRootFilesystem: false
requiredDropCapabilities:
- MKNOD
- MKNOD
runAsUser:
type: RunAsAny
seLinuxContext:
Expand All @@ -30,8 +32,10 @@ supplementalGroups:
type: RunAsAny
volumes:
- configMap
- downwardAPI
- emptyDir
- hostPath
- persistentVolumeClaim
- projected
- secret
{{- end }}
7 changes: 5 additions & 2 deletions charts/fluent-bit/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@ podSecurityPolicy:
create: false
annotations: {}

# OpenShift-specific configuration
openShift:
# Sets Openshift support
enabled: false
# Creates SCC for Fluent-bit when Openshift support is enabled
securityContextConstraints:
# Create SCC for Fluent-bit and allow use it
create: true
name: ""
annotations: {}
# Use existing SCC in cluster, rather then create new one
existingName: ""

podSecurityContext: {}
# fsGroup: 2000
Expand Down

0 comments on commit 5b70817

Please sign in to comment.