Skip to content

Commit

Permalink
Add clsuterName to support clusters with non-default names (#236)
Browse files Browse the repository at this point in the history
Signed-off-by: xirehat <[email protected]>
  • Loading branch information
xirehat authored Jan 20, 2025
1 parent a03c6f5 commit 701178b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 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:
- finops
- monitoring
- opencost
version: 1.43.1
version: 1.43.2
maintainers:
- name: mattray
url: https://mattray.dev
Expand Down
8 changes: 5 additions & 3 deletions charts/opencost/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ Create the name of the controller service account to use
{{- else -}}
{{- $host := tpl .Values.opencost.prometheus.internal.serviceName . }}
{{- $ns := tpl .Values.opencost.prometheus.internal.namespaceName . }}
{{- $clusterName := .Values.clusterName }}
{{- $port := .Values.opencost.prometheus.internal.port | int }}
{{- printf "http://%s.%s.svc.cluster.local:%d" $host $ns $port -}}
{{- printf "http://%s.%s.svc.%s:%d" $host $ns $clusterName $port -}}
{{- end -}}
{{- end -}}

Expand All @@ -115,8 +116,9 @@ Check that either thanos external or internal is defined
{{- else -}}
{{- $host := .Values.opencost.prometheus.thanos.internal.serviceName }}
{{- $ns := .Values.opencost.prometheus.thanos.internal.namespaceName }}
{{- $clusterName := .Values.clusterName }}
{{- $port := .Values.opencost.prometheus.thanos.internal.port | int }}
{{- printf "http://%s.%s.svc.cluster.local:%d" $host $ns $port -}}
{{- printf "http://%s.%s.svc.%s:%d" $host $ns $clusterName $port -}}
{{- end -}}
{{- end -}}

Expand Down Expand Up @@ -188,4 +190,4 @@ apiVersion: networking.k8s.io/v1beta1
{{- else}}
{{- .Values.opencost.ui.image.registry -}}/{{- .Values.opencost.ui.image.repository -}}:{{- include "opencostUi.imageTag" . -}}
{{- end -}}
{{- end -}}
{{- end -}}
2 changes: 2 additions & 0 deletions charts/opencost/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ nameOverride: ""
fullnameOverride: ""
# -- Override the deployment namespace
namespaceOverride: ""
# -- Override the default name of cluster - Can be found in /etc/kubernetes/admin.conf: clusters -> cluster -> name
clusterName: "cluster.local"

loglevel: info

Expand Down

0 comments on commit 701178b

Please sign in to comment.