Skip to content

Commit

Permalink
Merge branch 'main' into naming
Browse files Browse the repository at this point in the history
  • Loading branch information
zanhsieh authored Jun 23, 2022
2 parents 87a4dab + c4ff06b commit b9eb97a
Show file tree
Hide file tree
Showing 11 changed files with 742 additions and 5 deletions.
6 changes: 3 additions & 3 deletions charts/kube-prometheus-stack/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ dependencies:
version: 3.3.0
- name: grafana
repository: https://grafana.github.io/helm-charts
version: 6.29.11
digest: sha256:63805fe7ce9942b928b4c5d2d03c0fd0b73f6924e4126c66f658079bd7a8d435
generated: "2022-06-20T10:09:14.407533489+02:00"
version: 6.31.0
digest: sha256:f93a0e3d320f36dd95a3de335219d70d140ead8a0a853a37725cdf2f7c6ecc83
generated: "2022-06-23T06:58:32.0817776+02:00"
4 changes: 2 additions & 2 deletions charts/kube-prometheus-stack/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ name: kube-prometheus-stack
sources:
- https://github.com/prometheus-community/helm-charts
- https://github.com/prometheus-operator/kube-prometheus
version: 36.0.4
version: 36.2.1
appVersion: 0.57.0
kubeVersion: ">=1.16.0-0"
home: https://github.com/prometheus-operator/kube-prometheus
Expand All @@ -49,6 +49,6 @@ dependencies:
repository: https://prometheus-community.github.io/helm-charts
condition: nodeExporter.enabled
- name: grafana
version: "6.29.*"
version: "6.31.*"
repository: https://grafana.github.io/helm-charts
condition: grafana.enabled
13 changes: 13 additions & 0 deletions charts/kube-prometheus-stack/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ The longest name that gets created adds and extra 37 characters, so truncation s
{{- else }}
{{- printf "%s-alertmanager" (include "kube-prometheus-stack.fullname" .) -}}
{{- end }}

{{/* Fullname suffixed with thanos-ruler */}}
{{- define "kube-prometheus-stack.thanosRuler.fullname" -}}
{{- printf "%s-thanos-ruler" (include "kube-prometheus-stack.fullname" .) -}}
{{- end }}

{{/* Create chart name and version as used by the chart label. */}}
Expand Down Expand Up @@ -103,6 +107,15 @@ heritage: {{ $.Release.Service | quote }}
{{- end -}}
{{- end -}}

{{/* Create the name of thanosRuler service account to use */}}
{{- define "kube-prometheus-stack.thanosRuler.serviceAccountName" -}}
{{- if .Values.thanosRuler.serviceAccount.create -}}
{{ default (include "kube-prometheus-stack.thanosRuler.fullname" .) .Values.thanosRuler.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.thanosRuler.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Allow the release namespace to be overridden for multi-namespace deployments in combined charts
*/}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.thanosRuler.extraSecret.data -}}
{{- $secretName := printf "thanos-ruler-%s-extra" (include "kube-prometheus-stack.fullname" . ) -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ default $secretName .Values.thanosRuler.extraSecret.name }}
namespace: {{ template "kube-prometheus-stack.namespace" . }}
{{- if .Values.thanosRuler.extraSecret.annotations }}
annotations:
{{ toYaml .Values.thanosRuler.extraSecret.annotations | indent 4 }}
{{- end }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-thanos-ruler
app.kubernetes.io/component: thanos-ruler
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
data:
{{- range $key, $val := .Values.thanosRuler.extraSecret.data }}
{{ $key }}: {{ $val | b64enc | quote }}
{{- end }}
{{- end }}
77 changes: 77 additions & 0 deletions charts/kube-prometheus-stack/templates/thanos-ruler/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{{- if and .Values.thanosRuler.enabled .Values.thanosRuler.ingress.enabled }}
{{- $pathType := .Values.thanosRuler.ingress.pathType | default "ImplementationSpecific" }}
{{- $serviceName := printf "%s-%s" (include "kube-prometheus-stack.fullname" .) "thanos-ruler" }}
{{- $servicePort := .Values.thanosRuler.service.port -}}
{{- $routePrefix := list .Values.thanosRuler.thanosRulerSpec.routePrefix }}
{{- $paths := .Values.thanosRuler.ingress.paths | default $routePrefix -}}
{{- $apiIsStable := eq (include "kube-prometheus-stack.ingress.isStable" .) "true" -}}
{{- $ingressSupportsPathType := eq (include "kube-prometheus-stack.ingress.supportsPathType" .) "true" -}}
apiVersion: {{ include "kube-prometheus-stack.ingress.apiVersion" . }}
kind: Ingress
metadata:
name: {{ $serviceName }}
namespace: {{ template "kube-prometheus-stack.namespace" . }}
{{- if .Values.thanosRuler.ingress.annotations }}
annotations:
{{ toYaml .Values.thanosRuler.ingress.annotations | indent 4 }}
{{- end }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-thanos-ruler
{{- if .Values.thanosRuler.ingress.labels }}
{{ toYaml .Values.thanosRuler.ingress.labels | indent 4 }}
{{- end }}
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
spec:
{{- if $apiIsStable }}
{{- if .Values.thanosRuler.ingress.ingressClassName }}
ingressClassName: {{ .Values.thanosRuler.ingress.ingressClassName }}
{{- end }}
{{- end }}
rules:
{{- if .Values.thanosRuler.ingress.hosts }}
{{- range $host := .Values.thanosRuler.ingress.hosts }}
- host: {{ tpl $host $ }}
http:
paths:
{{- range $p := $paths }}
- path: {{ tpl $p $ }}
{{- if and $pathType $ingressSupportsPathType }}
pathType: {{ $pathType }}
{{- end }}
backend:
{{- if $apiIsStable }}
service:
name: {{ $serviceName }}
port:
number: {{ $servicePort }}
{{- else }}
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end }}
{{- end -}}
{{- end -}}
{{- else }}
- http:
paths:
{{- range $p := $paths }}
- path: {{ tpl $p $ }}
{{- if and $pathType $ingressSupportsPathType }}
pathType: {{ $pathType }}
{{- end }}
backend:
{{- if $apiIsStable }}
service:
name: {{ $serviceName }}
port:
number: {{ $servicePort }}
{{- else }}
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end }}
{{- end -}}
{{- end -}}
{{- if .Values.thanosRuler.ingress.tls }}
tls:
{{ tpl (toYaml .Values.thanosRuler.ingress.tls | indent 4) . }}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if and .Values.thanosRuler.enabled .Values.thanosRuler.podDisruptionBudget.enabled }}
apiVersion: {{ include "kube-prometheus-stack.pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ template "kube-prometheus-stack.fullname" . }}-thanos-ruler
namespace: {{ template "kube-prometheus-stack.namespace" . }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-thanos-ruler
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
spec:
{{- if .Values.thanosRuler.podDisruptionBudget.minAvailable }}
minAvailable: {{ .Values.thanosRuler.podDisruptionBudget.minAvailable }}
{{- end }}
{{- if .Values.thanosRuler.podDisruptionBudget.maxUnavailable }}
maxUnavailable: {{ .Values.thanosRuler.podDisruptionBudget.maxUnavailable }}
{{- end }}
selector:
matchLabels:
app.kubernetes.io/name: thanos-ruler
thanos-ruler: {{ template "kube-prometheus-stack.fullname" . }}-thanos-ruler
{{- end }}
150 changes: 150 additions & 0 deletions charts/kube-prometheus-stack/templates/thanos-ruler/ruler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{{- if .Values.thanosRuler.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ThanosRuler
metadata:
name: {{ template "kube-prometheus-stack.fullname" . }}-thanos-ruler
namespace: {{ template "kube-prometheus-stack.namespace" . }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-thanos-ruler
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
{{- if .Values.thanosRuler.annotations }}
annotations:
{{ toYaml .Values.thanosRuler.annotations | indent 4 }}
{{- end }}
spec:
{{- if .Values.thanosRuler.thanosRulerSpec.image }}
{{- if and .Values.thanosRuler.thanosRulerSpec.image.tag .Values.thanosRuler.thanosRulerSpec.image.sha }}
image: "{{ .Values.thanosRuler.thanosRulerSpec.image.repository }}:{{ .Values.thanosRuler.thanosRulerSpec.image.tag }}@sha256:{{ .Values.thanosRuler.thanosRulerSpec.image.sha }}"
{{- else if .Values.thanosRuler.thanosRulerSpec.image.sha }}
image: "{{ .Values.thanosRuler.thanosRulerSpec.image.repository }}@sha256:{{ .Values.thanosRuler.thanosRulerSpec.image.sha }}"
{{- else if .Values.thanosRuler.thanosRulerSpec.image.tag }}
image: "{{ .Values.thanosRuler.thanosRulerSpec.image.repository }}:{{ .Values.thanosRuler.thanosRulerSpec.image.tag }}"
{{- else }}
image: "{{ .Values.thanosRuler.thanosRulerSpec.image.repository }}"
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.image.sha }}
sha: {{ .Values.thanosRuler.thanosRulerSpec.image.sha }}
{{- end }}
{{- end }}
replicas: {{ .Values.thanosRuler.thanosRulerSpec.replicas }}
listenLocal: {{ .Values.thanosRuler.thanosRulerSpec.listenLocal }}
serviceAccountName: {{ template "kube-prometheus-stack.thanosRuler.serviceAccountName" . }}
{{- if .Values.thanosRuler.thanosRulerSpec.externalPrefix }}
externalPrefix: "{{ tpl .Values.thanosRuler.thanosRulerSpec.externalPrefix . }}"
{{- else if and .Values.thanosRuler.ingress.enabled .Values.thanosRuler.ingress.hosts }}
externalPrefix: "http://{{ tpl (index .Values.thanosRuler.ingress.hosts 0) . }}{{ .Values.thanosRuler.thanosRulerSpec.routePrefix }}"
{{- else }}
externalPrefix: http://{{ template "kube-prometheus-stack.fullname" . }}-thanosRuler.{{ template "kube-prometheus-stack.namespace" . }}:{{ .Values.thanosRuler.service.port }}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.nodeSelector }}
nodeSelector:
{{ toYaml .Values.thanosRuler.thanosRulerSpec.nodeSelector | indent 4 }}
{{- end }}
paused: {{ .Values.thanosRuler.thanosRulerSpec.paused }}
logFormat: {{ .Values.thanosRuler.thanosRulerSpec.logFormat | quote }}
logLevel: {{ .Values.thanosRuler.thanosRulerSpec.logLevel | quote }}
retention: {{ .Values.thanosRuler.thanosRulerSpec.retention | quote }}
{{- if .Values.thanosRuler.thanosRulerSpec.ruleNamespaceSelector }}
ruleNamespaceSelector:
{{ toYaml .Values.thanosRuler.thanosRulerSpec.ruleNamespaceSelector | indent 4 }}
{{ else }}
ruleNamespaceSelector: {}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.ruleSelector }}
ruleSelector:
{{ toYaml .Values.thanosRuler.thanosRulerSpec.ruleSelector | indent 4}}
{{- else if .Values.thanosRuler.thanosRulerSpec.ruleSelectorNilUsesHelmValues }}
ruleSelector:
matchLabels:
release: {{ $.Release.Name | quote }}
{{ else }}
ruleSelector: {}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.alertQueryUrl }}
alertQueryUrl: "{{ .Values.thanosRuler.thanosRulerSpec.alertQueryUrl }}"
{{- end}}
{{- if .Values.thanosRuler.thanosRulerSpec.alertmanagersUrl }}
alertmanagersUrl:
{{ toYaml .Values.thanosRuler.thanosRulerSpec.alertmanagersUrl | indent 4 }}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.queryEndpoints }}
queryEndpoints:
{{ toYaml .Values.thanosRuler.thanosRulerSpec.queryEndpoints | indent 4 }}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.resources }}
resources:
{{ toYaml .Values.thanosRuler.thanosRulerSpec.resources | indent 4 }}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.routePrefix }}
routePrefix: "{{ .Values.thanosRuler.thanosRulerSpec.routePrefix }}"
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.securityContext }}
securityContext:
{{ toYaml .Values.thanosRuler.thanosRulerSpec.securityContext | indent 4 }}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.storage }}
storage:
{{ toYaml .Values.thanosRuler.thanosRulerSpec.storage | indent 4 }}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.podMetadata }}
podMetadata:
{{ toYaml .Values.thanosRuler.thanosRulerSpec.podMetadata | indent 4 }}
{{- end }}
{{- if or .Values.thanosRuler.thanosRulerSpec.podAntiAffinity .Values.thanosRuler.thanosRulerSpec.affinity }}
affinity:
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.affinity }}
{{ toYaml .Values.thanosRuler.thanosRulerSpec.affinity | indent 4 }}
{{- end }}
{{- if eq .Values.thanosRuler.thanosRulerSpec.podAntiAffinity "hard" }}
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey: {{ .Values.thanosRuler.thanosRulerSpec.podAntiAffinityTopologyKey }}
labelSelector:
matchExpressions:
- {key: app.kubernetes.io/name, operator: In, values: [thanos-ruler]}
- {key: thanos-ruler, operator: In, values: [{{ template "kube-prometheus-stack.fullname" . }}-thanos-ruler]}
{{- else if eq .Values.thanosRuler.thanosRulerSpec.podAntiAffinity "soft" }}
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
topologyKey: {{ .Values.thanosRuler.thanosRulerSpec.podAntiAffinityTopologyKey }}
labelSelector:
matchExpressions:
- {key: app.kubernetes.io/name, operator: In, values: [thanos-ruler]}
- {key: thanos-ruler, operator: In, values: [{{ template "kube-prometheus-stack.fullname" . }}-thanos-ruler]}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.tolerations }}
tolerations:
{{ toYaml .Values.thanosRuler.thanosRulerSpec.tolerations | indent 4 }}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.topologySpreadConstraints }}
topologySpreadConstraints:
{{ toYaml .Values.thanosRuler.thanosRulerSpec.topologySpreadConstraints | indent 4 }}
{{- end }}
{{- if .Values.global.imagePullSecrets }}
imagePullSecrets:
{{ toYaml .Values.global.imagePullSecrets | indent 4 }}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.containers }}
containers:
{{ toYaml .Values.thanosRuler.thanosRulerSpec.containers | indent 4 }}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.initContainers }}
initContainers:
{{ toYaml .Values.thanosRuler.thanosRulerSpec.initContainers | indent 4 }}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.priorityClassName }}
priorityClassName: {{.Values.thanosRuler.thanosRulerSpec.priorityClassName }}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.volumes }}
volumes:
{{ toYaml .Values.thanosRuler.thanosRulerSpec.volumes | indent 4 }}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.volumeMounts }}
volumeMounts:
{{ toYaml .Values.thanosRuler.thanosRulerSpec.volumeMounts | indent 4 }}
{{- end }}
portName: {{ .Values.thanosRuler.thanosRulerSpec.portName }}
{{- end }}
53 changes: 53 additions & 0 deletions charts/kube-prometheus-stack/templates/thanos-ruler/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{{- if .Values.thanosRuler.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "kube-prometheus-stack.fullname" . }}-thanos-ruler
namespace: {{ template "kube-prometheus-stack.namespace" . }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-thanos-ruler
self-monitor: {{ .Values.thanosRuler.serviceMonitor.selfMonitor | quote }}
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
{{- if .Values.thanosRuler.service.labels }}
{{ toYaml .Values.thanosRuler.service.labels | indent 4 }}
{{- end }}
{{- if .Values.thanosRuler.service.annotations }}
annotations:
{{ toYaml .Values.thanosRuler.service.annotations | indent 4 }}
{{- end }}
spec:
{{- if .Values.thanosRuler.service.clusterIP }}
clusterIP: {{ .Values.thanosRuler.service.clusterIP }}
{{- end }}
{{- if .Values.thanosRuler.service.externalIPs }}
externalIPs:
{{ toYaml .Values.thanosRuler.service.externalIPs | indent 4 }}
{{- end }}
{{- if .Values.thanosRuler.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.thanosRuler.service.loadBalancerIP }}
{{- end }}
{{- if .Values.thanosRuler.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{- range $cidr := .Values.thanosRuler.service.loadBalancerSourceRanges }}
- {{ $cidr }}
{{- end }}
{{- end }}
{{- if ne .Values.thanosRuler.service.type "ClusterIP" }}
externalTrafficPolicy: {{ .Values.thanosRuler.service.externalTrafficPolicy }}
{{- end }}
ports:
- name: {{ .Values.thanosRuler.thanosRulerSpec.portName }}
{{- if eq .Values.thanosRuler.service.type "NodePort" }}
nodePort: {{ .Values.thanosRuler.service.nodePort }}
{{- end }}
port: {{ .Values.thanosRuler.service.port }}
targetPort: {{ .Values.thanosRuler.service.targetPort }}
protocol: TCP
{{- if .Values.thanosRuler.service.additionalPorts }}
{{ toYaml .Values.thanosRuler.service.additionalPorts | indent 2 }}
{{- end }}
selector:
app.kubernetes.io/name: thanos-ruler
thanos-ruler: {{ template "kube-prometheus-stack.fullname" . }}-thanos-ruler
type: "{{ .Values.thanosRuler.service.type }}"
{{- end }}
Loading

0 comments on commit b9eb97a

Please sign in to comment.