From 634c04481495cc388a9709aaaa48881959f39873 Mon Sep 17 00:00:00 2001 From: Richard Kovacs Date: Wed, 14 Aug 2024 15:34:30 +0200 Subject: [PATCH 1/2] Adding value for Linode token via secret Signed-off-by: Richard Kovacs --- charts/opencost/README.md | 1 + charts/opencost/templates/deployment.yaml | 7 +++++++ charts/opencost/values.yaml | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/charts/opencost/README.md b/charts/opencost/README.md index 984219b..a542802 100644 --- a/charts/opencost/README.md +++ b/charts/opencost/README.md @@ -59,6 +59,7 @@ $ helm install opencost opencost/opencost | opencost.exporter.apiPort | int | `9003` | | | opencost.exporter.aws.access_key_id | string | `""` | AWS secret key id | | opencost.exporter.aws.secret_access_key | string | `""` | AWS secret access key | +| opencost.exporter.linode.tokenSecret | string | `""` | Linode API token secret name | | opencost.exporter.cloudProviderApiKey | string | `""` | The GCP Pricing API requires a key. This is supplied just for evaluation. | | opencost.exporter.csv_path | string | `""` | | | opencost.exporter.defaultClusterId | string | `"default-cluster"` | Default cluster ID to use if cluster_id is not set in Prometheus metrics. | diff --git a/charts/opencost/templates/deployment.yaml b/charts/opencost/templates/deployment.yaml index 1d8e291..5ecd3fc 100644 --- a/charts/opencost/templates/deployment.yaml +++ b/charts/opencost/templates/deployment.yaml @@ -146,6 +146,13 @@ spec: name: {{ include "opencost.prometheus.secretname" . }} key: AWS_SECRET_ACCESS_KEY {{- end }} + {{- if .Values.opencost.exporter.linode.tokenSecret }} + - name: LINODE_TOKEN + valueFrom: + secretKeyRef: + name: {{ .Values.opencost.exporter.linode.tokenSecret | quote }} + key: token + {{- end }} {{- if and .Values.opencost.prometheus.username_key (or .Values.opencost.prometheus.username .Values.opencost.prometheus.existingSecretName) }} - name: DB_BASIC_AUTH_USERNAME valueFrom: diff --git a/charts/opencost/values.yaml b/charts/opencost/values.yaml index ed1ce77..0c61c91 100644 --- a/charts/opencost/values.yaml +++ b/charts/opencost/values.yaml @@ -213,6 +213,11 @@ opencost: secret_access_key: "" # -- AWS secret key id access_key_id: "" + + linode: + # -- Linode API token secret name + tokenSecret: "" + # -- A list of volume mounts to be added to the pod extraVolumeMounts: [] # -- List of additional environment variables to set in the container From 92dbed7377fff05276ec295c79cca393ac59b41b Mon Sep 17 00:00:00 2001 From: Mateusz Urbanek Date: Mon, 13 Jan 2025 17:41:26 +0100 Subject: [PATCH 2/2] fix: make token static Signed-off-by: Mateusz Urbanek --- charts/opencost/README.md | 2 +- charts/opencost/templates/deployment.yaml | 6 +++--- charts/opencost/templates/secret.yaml | 5 ++++- charts/opencost/values.yaml | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/charts/opencost/README.md b/charts/opencost/README.md index d68e871..5674cff 100644 --- a/charts/opencost/README.md +++ b/charts/opencost/README.md @@ -59,7 +59,7 @@ $ helm install opencost opencost/opencost | opencost.exporter.apiPort | int | `9003` | | | opencost.exporter.aws.access_key_id | string | `""` | AWS secret key id | | opencost.exporter.aws.secret_access_key | string | `""` | AWS secret access key | -| opencost.exporter.linode.tokenSecret | string | `""` | Linode API token secret name | +| opencost.exporter.linode.token | string | `""` | Linode API token | | opencost.exporter.cloudProviderApiKey | string | `""` | The GCP Pricing API requires a key. This is supplied just for evaluation. | | opencost.exporter.csv_path | string | `""` | | | opencost.exporter.defaultClusterId | string | `"default-cluster"` | Default cluster ID to use if cluster_id is not set in Prometheus metrics. | diff --git a/charts/opencost/templates/deployment.yaml b/charts/opencost/templates/deployment.yaml index 7e4c23c..28c6b3e 100644 --- a/charts/opencost/templates/deployment.yaml +++ b/charts/opencost/templates/deployment.yaml @@ -147,12 +147,12 @@ spec: name: {{ include "opencost.prometheus.secretname" . }} key: AWS_SECRET_ACCESS_KEY {{- end }} - {{- if .Values.opencost.exporter.linode.tokenSecret }} + {{- if .Values.opencost.exporter.linode.token }} - name: LINODE_TOKEN valueFrom: secretKeyRef: - name: {{ .Values.opencost.exporter.linode.tokenSecret | quote }} - key: token + name: {{ include "opencost.prometheus.secretname" . }} + key: LINODE_TOKEN {{- end }} {{- if and .Values.opencost.prometheus.username_key (or .Values.opencost.prometheus.username .Values.opencost.prometheus.existingSecretName) }} - name: DB_BASIC_AUTH_USERNAME diff --git a/charts/opencost/templates/secret.yaml b/charts/opencost/templates/secret.yaml index 214f649..45eea24 100644 --- a/charts/opencost/templates/secret.yaml +++ b/charts/opencost/templates/secret.yaml @@ -1,4 +1,4 @@ -{{- if or .Values.opencost.prometheus.username .Values.opencost.prometheus.password .Values.opencost.prometheus.bearer_token .Values.opencost.exporter.aws.access_key_id .Values.opencost.exporter.cloudProviderApiKey }} +{{- if or .Values.opencost.prometheus.username .Values.opencost.prometheus.password .Values.opencost.prometheus.bearer_token .Values.opencost.exporter.aws.access_key_id .Values.opencost.exporter.linode.token .Values.opencost.exporter.cloudProviderApiKey }} apiVersion: v1 kind: Secret metadata: @@ -24,6 +24,9 @@ data: {{- if .Values.opencost.exporter.aws.access_key_id }} AWS_SECRET_ACCESS_KEY: {{ .Values.opencost.exporter.aws.secret_access_key | b64enc | quote }} {{- end }} + {{- if .Values.opencost.exporter.linode.token }} + LINODE_TOKEN: {{ .Values.opencost.exporter.linode.token | b64enc | quote }} + {{- end }} {{- if .Values.opencost.exporter.cloudProviderApiKey }} CLOUD_PROVIDER_API_KEY: {{ .Values.opencost.exporter.cloudProviderApiKey | b64enc | quote }} {{- end }} diff --git a/charts/opencost/values.yaml b/charts/opencost/values.yaml index 9453966..be69c0e 100644 --- a/charts/opencost/values.yaml +++ b/charts/opencost/values.yaml @@ -215,8 +215,8 @@ opencost: access_key_id: "" linode: - # -- Linode API token secret name - tokenSecret: "" + # -- Linode API token + token: "" # -- A list of volume mounts to be added to the pod extraVolumeMounts: []