Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sanity check for cloudIntegrationSecret (cherry-pick #3048) #3058

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cost-analyzer/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
--------------------------------------------------
{{- include "kubecostV2-preconditions" . -}}
{{- include "eksCheck" . -}}
{{- include "cloudIntegrationSecretCheck" . -}}
{{- $servicePort := .Values.service.port | default 9090 }}
Kubecost {{ .Chart.Version }} has been successfully installed.

Expand Down
16 changes: 15 additions & 1 deletion cost-analyzer/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ ERROR: MISSING EBS-CSI DRIVER WHICH IS REQUIRED ON EKS v1.23+ TO MANAGE PERSISTE
{{- end -}}
{{- end -}}

{{/*
Verify the cloud integration secret exists with the expected key when cloud integration is enabled.
*/}}
{{- define "cloudIntegrationSecretCheck" -}}
{{- if (.Values.kubecostProductConfigs).cloudIntegrationSecret }}
{{- if .Capabilities.APIVersions.Has "v1/Secret" }}
{{- $secret := lookup "v1" "Secret" .Release.Namespace .Values.kubecostProductConfigs.cloudIntegrationSecret }}
{{- if or (not $secret) (not (index $secret.data "cloud-integration.json")) }}
{{- fail (printf "The cloud integration secret '%s' does not exist or does not contain the expected key 'cloud-integration.json'" .Values.kubecostProductConfigs.cloudIntegrationSecret) }}
{{- end }}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Expand the name of the chart.
*/}}
Expand Down Expand Up @@ -992,7 +1006,7 @@ Begin Kubecost 2.0 templates
readOnly: true
{{- end }}
{{- if (.Values.kubecostProductConfigs).cloudIntegrationSecret }}
- name: {{ .Values.kubecostProductConfigs.cloudIntegrationSecret }}
- name: cloud-integration
mountPath: /var/configs/cloud-integration
{{- end }}
env:
Expand Down
Loading