Skip to content

feat(ksm): ksmurl from global #439

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

Merged
merged 5 commits into from
Nov 26, 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
2 changes: 1 addition & 1 deletion charts/argus/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ maintainers:
- email: [email protected]
name: LogicMonitor
name: argus
version: 11.1.0-rc03
version: 11.1.0-rc04
home: https://logicmonitor.github.io/helm-charts-qa
appVersion: v15.1.0-rc03
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion charts/argus/templates/_argus_config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ proxy:
proxy:
url: {{ .Values.global.proxy.url }}
{{- end }}
ksmUrl: {{ include "ksm-url" . }}
ksmUrl: {{ include "ksm-url" . | quote }}
{{- end -}}
21 changes: 16 additions & 5 deletions charts/argus/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,28 @@ Collector Pod security context

{{- define "ksm-url" -}}
{{- $url := "" }}
{{- $ksm := index .Values "kube-state-metrics" }}
{{- $ksm := index .Values.global "kube-state-metrics" }}
{{- if not (empty .Values.ksmUrl) }}
{{- $url = .Values.ksmUrl }}
{{- else if $ksm.enabled }}
{{- $port := "" }}
{{- range $p := .Release.Service.spec.ports }}
{{- $port := 8080 }}
{{- $url = printf "http://%s-kube-state-metrics.%s.svc.cluster.local:%d/metrics" .Release.Name .Release.Namespace $port }}
{{- else }}
{{- $nsservices := (lookup "v1" "Service" .Release.Namespace "") | default dict }}
{{- $nsfilteredServices := dict "items" (list) }}
{{- range $service := $nsservices.items }}
{{- if eq (index $service.metadata.labels "app.kubernetes.io/name" | default "") "kube-state-metrics" }}
{{- $_ := set $nsfilteredServices "items" (append $nsfilteredServices.items $service) }}
{{- $port := "" }}
{{- range $p := $service.spec.ports }}
{{- if or (eq $p.name "http") (eq $p.name "http-metrics") }}
{{- $port = $p.port }}
{{- end }}
{{- end }}
{{- $url = printf "http://%s-kube-state-metrics.%s.svc.cluster.local:%d/metrics" .Release.metadata.name .Release.Namespace $port }}
{{- else }}
{{- $url = printf "http://%s.%s.svc.cluster.local:%d/metrics" $service.metadata.name $service.metadata.namespace $port }}
{{- end }}
{{- end }}
{{- if (empty $url)}}
{{- $services := (lookup "v1" "Service" "" "") | default dict }}
{{- $filteredServices := dict "items" (list) }}
{{- range $service := $services.items }}
Expand All @@ -146,6 +156,7 @@ Collector Pod security context
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- $url }}
{{- end }}

Expand Down
8 changes: 8 additions & 0 deletions charts/argus/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2335,6 +2335,14 @@
"default": "",
"description" : "The Logicmonitor account domain"
},
"kube-state-metrics": {
"$id": "#/properties/global/properties/kube-state-metrics",
"type": "object",
"title": "Kube state metrics config",
"description": "Kube state metrics.",
"additionalItems": true,
"additionalProperties": true
},
"imagePullSecrets": {
"description": "ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. For example, in the case of docker, only DockerConfig type secrets are honored. More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod",
"examples": [
Expand Down
Loading