File tree Expand file tree Collapse file tree 7 files changed +81
-1
lines changed
Expand file tree Collapse file tree 7 files changed +81
-1
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ keywords:
99 - finops
1010 - monitoring
1111 - opencost
12- version : 1.42.3
12+ version : 1.43.0
1313maintainers :
1414 - name : mattray
1515 url : https://mattray.dev
Original file line number Diff line number Diff line change @@ -120,6 +120,15 @@ Check that either thanos external or internal is defined
120120 { {- end -} }
121121{ {- end -} }
122122
123+ { {/*
124+ Fail if both kube-rbac-proxy and bearer token are set
125+ */} }
126+ { {- define " kubeRBACProxyBearerTokenCheck" -} }
127+ { {- if and .Values.opencost.prometheus.kubeRBACProxy .Values.opencost.prometheus.bearer_token } }
128+ { {- fail " Both kubeRBACProxy and bearer_token are set. Please specify only one." -} }
129+ { {- end -} }
130+ { {- end -} }
131+
123132{ {/*
124133Check that the config is valid
125134*/} }
Original file line number Diff line number Diff line change @@ -15,4 +15,27 @@ subjects:
1515 - kind : ServiceAccount
1616 name : {{ template "opencost.serviceAccountName" . }}
1717 namespace : {{ include "opencost.namespace" . }}
18+ ---
1819{{- end }}
20+ {{- if .Values.opencost.prometheus.createMonitoringClusterRoleBinding }}
21+ apiVersion : rbac.authorization.k8s.io/v1
22+ kind : ClusterRoleBinding
23+ metadata :
24+ name : {{ include "opencost.fullname" . }}-operator
25+ labels : {{- include "opencost.labels" . | nindent 4 }}
26+ {{- with .Values.annotations }}
27+ annotations : {{- toYaml . | nindent 4 }}
28+ {{- end }}
29+ roleRef :
30+ # Grant the OpenCost ServiceAccount the cluster-monitoring-view role to enable it to query a KUBE_RBAC_PROXY enabled Prometheus.
31+ # This is necessary for OpenCost to get access and query the in-cluster Prometheus instance using its service account token.
32+ # https://docs.redhat.com/en/documentation/openshift_container_platform/4.2/html/monitoring/cluster-monitoring#monitoring-accessing-prometheus-alerting-ui-grafana-using-the-web-console_accessing-prometheus
33+ apiGroup : rbac.authorization.k8s.io
34+ kind : ClusterRole
35+ name : cluster-monitoring-view
36+ subjects :
37+ - kind : ServiceAccount
38+ name : {{ template "opencost.serviceAccountName" . }}
39+ namespace : {{ include "opencost.namespace" . }}
40+ {{- end }}
41+ ---
Original file line number Diff line number Diff line change 11{{- include "isPrometheusConfigValid" . }}
2+ {{- include "kubeRBACProxyBearerTokenCheck" . }}
23apiVersion : apps/v1
34kind : Deployment
45metadata :
@@ -166,6 +167,10 @@ spec:
166167 name : {{ .Values.opencost.prometheus.existingSecretName | default (include "opencost.prometheus.secretname" .) }}
167168 key : {{ .Values.opencost.prometheus.bearer_token_key }}
168169 {{- end }}
170+ {{- if .Values.opencost.prometheus.kubeRBACProxy }}
171+ - name : KUBE_RBAC_PROXY_ENABLED
172+ value : {{ (quote .Values.opencost.prometheus.kubeRBACProxy) }}
173+ {{- end }}
169174 {{- if and .Values.opencost.exporter.persistence.enabled .Values.opencost.exporter.csv_path }}
170175 - name : EXPORT_CSV_FILE
171176 value : {{ .Values.opencost.exporter.csv_path | quote }}
Original file line number Diff line number Diff line change 1+ {{- if (.Values.opencost.prometheus.createMonitoringResourceReaderRoleBinding) }}
2+ apiVersion : rbac.authorization.k8s.io/v1
3+ kind : RoleBinding
4+ metadata :
5+ namespace : {{ include "opencost.namespace" . }}
6+ name : {{ include "opencost.fullname" . }}-reader
7+ subjects :
8+ - kind : ServiceAccount
9+ name : {{ .Values.opencost.prometheus.monitoringServiceAccountName | quote }}
10+ namespace : {{ .Values.opencost.prometheus.monitoringServiceAccountNamespace | quote }}
11+ roleRef :
12+ kind : Role
13+ name : {{ include "opencost.fullname" . }}-reader
14+ apiGroup : rbac.authorization.k8s.io
15+ {{- end -}}
Original file line number Diff line number Diff line change 1+ {{- if (.Values.opencost.prometheus.createMonitoringResourceReaderRoleBinding) }}
2+ apiVersion : rbac.authorization.k8s.io/v1
3+ kind : Role
4+ metadata :
5+ namespace : {{ include "opencost.namespace" . }}
6+ name : {{ include "opencost.fullname" . }}-reader
7+ rules :
8+ - apiGroups :
9+ - ' '
10+ resources :
11+ - " pods"
12+ - " services"
13+ - " endpoints"
14+ verbs :
15+ - list
16+ - watch
17+ {{- end -}}
Original file line number Diff line number Diff line change @@ -333,6 +333,17 @@ opencost:
333333 # -- Prometheus Bearer token
334334 bearer_token : " "
335335 bearer_token_key : DB_BEARER_TOKEN
336+ # -- If true, opencost will use kube-rbac-proxy to authenticate with in cluster Prometheus for openshift
337+ kubeRBACProxy : false
338+ # OPTIONAL. The following configs only to be enabled when using a Prometheus instance already installed in the cluster.
339+ # -- If true, the helm chart will create a ClusterRoleBinding to grant the OpenCost ServiceAccount access to query Prometheus.
340+ createMonitoringClusterRoleBinding : false
341+ # -- If true, create a Role and RoleBinding to allow Prometheus to list and watch OpenCost resources.
342+ createMonitoringResourceReaderRoleBinding : false
343+ # -- Name of the Prometheus serviceaccount to bind to the Resource Reader Role Binding.
344+ monitoringServiceAccountName : prometheus-k8s
345+ # -- Namespace of the Prometheus serviceaccount to bind to the Resource Reader Role Binding.
346+ monitoringServiceAccountNamespace : openshift-monitoring
336347 external :
337348 # -- Use external Prometheus (eg. Grafana Cloud)
338349 enabled : false
You can’t perform that action at this time.
0 commit comments