Skip to content

Commit

Permalink
add CSV exporter pvc (#62)
Browse files Browse the repository at this point in the history
add csv exporter pvc
  • Loading branch information
Qixuanw authored May 8, 2023
1 parent 19c15f1 commit c5441d9
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
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:
- kubecost
- opencost
- monitoring
version: 1.12.0
version: 1.13.0
maintainers:
- name: mattray
url: https://mattray.dev
Expand Down
31 changes: 30 additions & 1 deletion charts/opencost/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ spec:
{{- end }}
- name: CLUSTER_ID
value: {{ .Values.opencost.exporter.defaultClusterId | quote }}
{{- if .Values.opencost.exporter.aws.access_key_id }}
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: {{ include "opencost.fullname" . }}
key: AWS_ACCESS_KEY_ID
{{- end }}
{{- if .Values.opencost.exporter.aws.secret_access_key }}
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: {{ include "opencost.fullname" . }}
key: AWS_SECRET_ACCESS_KEY
{{- end }}
# If username, password or bearer_token are defined, pull from secrets
{{- if .Values.opencost.prometheus.username }}
- name: DB_BASIC_AUTH_USERNAME
Expand All @@ -127,6 +141,10 @@ spec:
name: {{ include "opencost.fullname" . }}
key: DB_BEARER_TOKEN
{{- end }}
{{- if and .Values.opencost.exporter.persistence.enabled .Values.opencost.exporter.csv_path }}
- name: EXPORT_CSV_FILE
value: {{ .Values.opencost.exporter.csv_path | quote }}
{{- end}}
{{- with .Values.opencost.exporter.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
Expand All @@ -135,6 +153,12 @@ spec:
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- if .Values.opencost.exporter.persistence.enabled }}
volumeMounts:
- mountPath: /mnt/export
name: opencost-export
readOnly: false
{{- end }}
imagePullPolicy: Always
{{- if .Values.opencost.ui.enabled }}
- image: "{{ .Values.opencost.ui.image.registry }}/{{ .Values.opencost.ui.image.repository }}:{{ .Values.opencost.ui.image.tag | default (printf "prod-%s" .Chart.AppVersion) }}"
Expand Down Expand Up @@ -174,7 +198,12 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.extraVolumes }}
volumes:
{{- if .Values.opencost.exporter.persistence.enabled }}
- name: opencost-export
persistentVolumeClaim:
claimName: opencost-export
{{- end }}
{{- with .Values.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
20 changes: 20 additions & 0 deletions charts/opencost/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.opencost.exporter.persistence.enabled }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "opencost.fullname" . }}-pvc
namespace: {{ .Release.Namespace }}
{{- with .Values.opencost.exporter.persistence.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
labels:
{{- include "opencost.labels" . | nindent 4 }}
spec:
accessModes:
- {{ .Values.opencost.exporter.persistence.accessMode | quote }}
storageClassName: {{ default "" .Values.opencost.exporter.persistence.storageClass }}
resources:
requests:
storage: {{ .Values.opencost.exporter.persistence.size | quote }}
{{- end }}
6 changes: 6 additions & 0 deletions charts/opencost/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ data:
{{- if .Values.opencost.prometheus.bearer_token }}
DB_BEARER_TOKEN: {{ .Values.opencost.prometheus.bearer_token | b64enc | quote }}
{{- end }}
{{- if .Values.opencost.exporter.aws.access_key_id }}
AWS_ACCESS_KEY_ID: {{ .Values.opencost.exporter.aws.access_key_id | b64enc | quote }}
{{- end }}
{{- if .Values.opencost.exporter.aws.access_key_id }}
AWS_SECRET_ACCESS_KEY: {{ .Values.opencost.exporter.aws.secret_access_key | b64enc | quote }}
{{- end }}
{{- end }}
20 changes: 20 additions & 0 deletions charts/opencost/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,26 @@ opencost:
# runAsNonRoot: true
# runAsUser: 1000

# Path of CSV file
csv_path: ""

# Persistent volume claim for storing the data. eg: csv file
persistence:
enabled: false
# -- Annotations for persistent volume
annotations: {}
# -- Access mode for persistent volume
accessMode: ""
# --Storage class for persistent volume
storageClass: ""
# -- Size for persistent volume
size: ""

aws:
# -- AWS secret access key
secret_access_key: ""
# -- AWS secret key id
access_key_id: ""
# -- A list of volume mounts to be added to the pod
extraVolumeMounts: []
# -- Any extra environment variables you would like to pass on to the pod
Expand Down

0 comments on commit c5441d9

Please sign in to comment.