Skip to content

Commit 44ebb3b

Browse files
authored
feat: Add ability to define securityContexts and podSecurityContext (#38)
Signed-off-by: Marco Kilchhofer <mkilchhofer@users.noreply.github.com>
1 parent 4926425 commit 44ebb3b

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

charts/opencost/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ keywords:
99
- kubecost
1010
- opencost
1111
- monitoring
12-
version: 1.5.0
12+
version: 1.6.0
1313
maintainers:
1414
- name: mattray
1515
url: https://mattray.dev

charts/opencost/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
OpenCost and OpenCost UI
44

5-
![Version: 1.5.0](https://img.shields.io/badge/Version-1.5.0-informational?style=flat-square)
5+
![Version: 1.6.0](https://img.shields.io/badge/Version-1.6.0-informational?style=flat-square)
66
![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
77
![AppVersion: 1.101.2](https://img.shields.io/badge/AppVersion-1.101.2-informational?style=flat-square)
88

@@ -37,6 +37,7 @@ $ helm install opencost opencost/opencost
3737
| opencost.exporter.replicas | int | `1` | Number of OpenCost replicas to run |
3838
| opencost.exporter.resources.limits | object | `{"cpu":"999m","memory":"1Gi"}` | CPU/Memory resource limits |
3939
| opencost.exporter.resources.requests | object | `{"cpu":"10m","memory":"55Mi"}` | CPU/Memory resource requests |
40+
| opencost.exporter.securityContext | object | `{}` | The security options the container should be run with |
4041
| opencost.metrics.serviceMonitor.additionalLabels | object | `{}` | Additional labels to add to the ServiceMonitor |
4142
| opencost.metrics.serviceMonitor.enabled | bool | `false` | Create ServiceMonitor resource for scraping metrics using PrometheusOperator |
4243
| opencost.metrics.serviceMonitor.honorLabels | bool | `false` | HonorLabels chooses the metric's labels on collisions with target labels |
@@ -62,7 +63,9 @@ $ helm install opencost opencost/opencost
6263
| opencost.ui.image.tag | string | `""` (use appVersion in Chart.yaml) | UI container image tag |
6364
| opencost.ui.resources.limits | object | `{"cpu":"999m","memory":"1Gi"}` | CPU/Memory resource limits |
6465
| opencost.ui.resources.requests | object | `{"cpu":"10m","memory":"55Mi"}` | CPU/Memory resource requests |
66+
| opencost.ui.securityContext | object | `{}` | The security options the container should be run with |
6567
| podAnnotations | object | `{}` | Annotations to add to the OpenCost Pod |
68+
| podSecurityContext | object | `{}` | Holds pod-level security attributes and common container settings |
6669
| service.annotations | object | `{}` | Annotations to add to the service |
6770
| service.labels | object | `{}` | Labels to add to the service account |
6871
| service.type | string | `"ClusterIP"` | Kubernetes Service type |

charts/opencost/templates/deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ spec:
3131
{{- if .Values.imagePullSecrets }}
3232
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 8 }}
3333
{{- end }}
34+
securityContext:
35+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
3436
serviceAccountName: {{ template "opencost.serviceAccountName" . }}
3537
tolerations:
3638
{{- toYaml .Values.opencost.tolerations | nindent 8 }}
@@ -54,6 +56,8 @@ spec:
5456
ports:
5557
- containerPort: 9003
5658
name: http
59+
securityContext:
60+
{{- toYaml .Values.opencost.exporter.securityContext | nindent 12 }}
5761
volumeMounts:
5862
{{- if .Values.opencost.exporter.extraVolumeMounts }}
5963
{{- toYaml .Values.opencost.exporter.extraVolumeMounts | nindent 12 }}
@@ -106,6 +110,8 @@ spec:
106110
ports:
107111
- containerPort: 9090
108112
name: http-ui
113+
securityContext:
114+
{{- toYaml .Values.opencost.ui.securityContext | nindent 12 }}
109115
{{- end }}
110116
volumes:
111117
{{- if .Values.extraVolumes }}

charts/opencost/values.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ annotations: {}
1313
# -- Annotations to add to the OpenCost Pod
1414
podAnnotations: {}
1515

16+
# -- Holds pod-level security attributes and common container settings
17+
podSecurityContext: {}
18+
# fsGroup: 2000
19+
1620
service:
1721
# -- Annotations to add to the service
1822
annotations: {}
@@ -46,6 +50,15 @@ opencost:
4650
limits:
4751
cpu: '999m'
4852
memory: '1Gi'
53+
# -- The security options the container should be run with
54+
securityContext: {}
55+
# capabilities:
56+
# drop:
57+
# - ALL
58+
# readOnlyRootFilesystem: true
59+
# runAsNonRoot: true
60+
# runAsUser: 1000
61+
4962
# -- A list of volume mounts to be added to the pod
5063
extraVolumeMounts: []
5164
# -- Any extra environment variables you would like to pass on to the pod
@@ -111,6 +124,14 @@ opencost:
111124
limits:
112125
cpu: '999m'
113126
memory: '1Gi'
127+
# -- The security options the container should be run with
128+
securityContext: {}
129+
# capabilities:
130+
# drop:
131+
# - ALL
132+
# readOnlyRootFilesystem: true
133+
# runAsNonRoot: true
134+
# runAsUser: 1000
114135

115136
# -- Toleration labels for pod assignment
116137
tolerations: []

0 commit comments

Comments
 (0)