Skip to content

Commit

Permalink
Support for extra egress rules and metricConfig ConfigMap (#183)
Browse files Browse the repository at this point in the history
* feat: Adds support for extra egress rules for NetworkPolicy

* feat: Adds support for metricsConfig ConfigMap

This will create the /var/configs/metrics.json file for OpenCost to read.

* fix: remove extra whitespace

---------

Co-authored-by: Tony Scott <[email protected]>
  • Loading branch information
valdisrigdon and Tony Scott authored Mar 26, 2024
1 parent 5046f8f commit e9fb1d8
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/opencost/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ keywords:
- finops
- monitoring
- opencost
version: 1.32.0
version: 1.33.0
maintainers:
- name: mattray
- name: toscott
Expand Down
11 changes: 11 additions & 0 deletions charts/opencost/templates/configmap-metrics-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if .Values.opencost.metrics.config.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-metrics-config
namespace: {{ include "opencost.namespace" . }}
labels: {{- include "opencost.labels" . | nindent 4 }}
data:
metrics.json: |-
{"disabledMetrics": {{ toJson .Values.opencost.metrics.config.disabledMetrics }} }
{{- end }}
6 changes: 6 additions & 0 deletions charts/opencost/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ spec:
value: {{ .Values.loglevel }}
- name: CUSTOM_COST_ENABLED
value: {{ .Values.plugins.enabled | quote }}
- name: KUBECOST_NAMESPACE
value: {{ include "opencost.namespace" . }}
{{- if .Values.opencost.metrics.config.enabled }}
- name: METRICS_CONFIGMAP_NAME
value: {{ .Release.Name }}-metrics-config
{{- end }}
{{- if .Values.opencost.exporter.apiPort }}
- name: API_PORT
value: {{ .Values.opencost.exporter.apiPort | quote }}
Expand Down
3 changes: 3 additions & 0 deletions charts/opencost/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ spec:
{{- end }}
ports:
- port: {{ .Values.networkPolicies.prometheus.port }}
{{- if .Values.networkPolicies.extraEgress -}}
{{ toYaml .Values.networkPolicies.extraEgress | nindent 4 }}
{{- end -}}
{{- end }}
{{- end }}
11 changes: 11 additions & 0 deletions charts/opencost/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ networkPolicies:
labels:
app.kubernetes.io/name: prometheus

# -- Extra egress rule
extraEgress: []

# -- Strategy to be used for the Deployment
updateStrategy:
rollingUpdate:
Expand Down Expand Up @@ -295,6 +298,14 @@ opencost:
# insecureSkipVerify: true
# keyFile: /etc/prom-certs/key.pem

config:
# -- Enables creating the metrics.json configuration as a ConfigMap
enabled: false
# -- List of metrics to be disabled
disabledMetrics: []
# - <metric-to-be-disabled>
# - <metric-to-be-disabled>

prometheus:
# -- Secret name that contains credentials for Prometheus
secret_name: ~
Expand Down

0 comments on commit e9fb1d8

Please sign in to comment.