Skip to content

Commit

Permalink
Improve Openshift support, allow to use existing SCCs
Browse files Browse the repository at this point in the history
- 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 <kirill_peretrukhin@epam.com>
  • Loading branch information
Kirill Thirteen committed Jun 12, 2023
1 parent 4e502ac commit 7cff4ab
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
4 changes: 2 additions & 2 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.30.4
version: 0.30.5
appVersion: 2.1.4
icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/fluentd/fluentbit/icon/fluentbit-icon-color.svg
home: https://fluentbit.io/
Expand All @@ -23,4 +23,4 @@ maintainers:
annotations:
artifacthub.io/changes: |
- kind: added
description: "Use Helm release specific Grafana dashboard filenames."
description: "Add ability to use existing SecurityContextConstraints in OpenShift, for the fluent-bit chart."
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.openShift.securityContextConstraints.name" -}}
{{- if .Values.openShift.securityContextConstraints.create -}}
{{ default (include "fluent-bit.fullname" .) .Values.openShift.securityContextConstraints.name }}
{{- else if .Values.openShift.securityContextConstraints.existingName -}}
{{- printf "%s" .Values.openShift.securityContextConstraints.existingName -}}
{{- 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 or .Values.openShift.securityContextConstraints.create .Values.openShift.securityContextConstraints.existingName }}
- apiGroups:
- security.openshift.io
resources:
- securitycontextconstraints
resourceNames:
- {{ include "fluent-bit.fullname" . }}
- {{ include "fluent-bit.openShift.securityContextConstraints.name" . }}
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
@@ -1,12 +1,14 @@
{{- if and .Values.openShift.enabled .Values.openShift.securityContextConstraints.create }}
apiVersion: security.openshift.io/v1
{{- if and .Values.openShift.securityContextConstraints.create }}
apiVersion: security.openShift.io/v1
kind: SecurityContextConstraints
metadata:
name: {{ include "fluent-bit.fullname" . }}
{{- if .Values.openShift.securityContextConstraints.annotations }}
name: {{ include "fluent-bit.openShift.securityContextConstraints.name" . }}
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 @@ -30,8 +32,10 @@ supplementalGroups:
type: RunAsAny
volumes:
- configMap
- downwardAPI
- emptyDir
- hostPath
- persistentVolumeClaim
- projected
- secret
{{- end }}
10 changes: 6 additions & 4 deletions charts/fluent-bit/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ 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: true
# Create SCC for Fluent-bit and allow use it
create: false
name: ""
annotations: {}
# Use existing SCC in cluster, rather then create new one
existingName: ""

podSecurityContext: {}
# fsGroup: 2000
Expand Down

0 comments on commit 7cff4ab

Please sign in to comment.