diff --git a/charts/opencost/Chart.yaml b/charts/opencost/Chart.yaml index 00bf5d7..6775d1e 100755 --- a/charts/opencost/Chart.yaml +++ b/charts/opencost/Chart.yaml @@ -9,7 +9,7 @@ keywords: - kubecost - opencost - monitoring -version: 1.12.0 +version: 1.13.0 maintainers: - name: mattray url: https://mattray.dev diff --git a/charts/opencost/templates/deployment.yaml b/charts/opencost/templates/deployment.yaml index a8f174b..430bb9b 100644 --- a/charts/opencost/templates/deployment.yaml +++ b/charts/opencost/templates/deployment.yaml @@ -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 @@ -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 }} @@ -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) }}" @@ -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 }} diff --git a/charts/opencost/templates/pvc.yaml b/charts/opencost/templates/pvc.yaml new file mode 100644 index 0000000..6d84b3c --- /dev/null +++ b/charts/opencost/templates/pvc.yaml @@ -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 }} \ No newline at end of file diff --git a/charts/opencost/templates/secret.yaml b/charts/opencost/templates/secret.yaml index 263de9a..0e09370 100644 --- a/charts/opencost/templates/secret.yaml +++ b/charts/opencost/templates/secret.yaml @@ -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 }} diff --git a/charts/opencost/values.yaml b/charts/opencost/values.yaml index 23c41c2..c95bc4c 100644 --- a/charts/opencost/values.yaml +++ b/charts/opencost/values.yaml @@ -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