Skip to content

Commit

Permalink
Split templates of resources per kind - fix helm linting. (fix #819).
Browse files Browse the repository at this point in the history
  • Loading branch information
MemberIT committed Dec 20, 2023
1 parent a31c66f commit 86d08c0
Show file tree
Hide file tree
Showing 11 changed files with 374 additions and 383 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
{{- if .Values.vmagent.enabled }}
---
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMAgent
metadata:
{{- with .Values.vmagent.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ .Values.vmagent.name | default (include "victoria-metrics-k8s-stack.fullname" .) }}
namespace: {{ .Release.Namespace }}
labels: {{ include "victoria-metrics-k8s-stack.labels" . | nindent 4 }}
spec:
{{ include "victoria-metrics-k8s-stack.vmAgentSpec" . | indent 2 }}
{{- end }}

{{ if and .Values.vmagent.enabled .Values.vmagent.ingress.enabled -}}
---
{{- $servicePort := 8429 -}}
{{- $ingressPath := .Values.vmagent.ingress.path -}}
{{- $serviceName := printf "%s-%s" "vmagent" (include "victoria-metrics-k8s-stack.fullname" .) | trunc 63 | trimSuffix "-" }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.vmagent.enabled }}
---
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMAgent
metadata:
{{- with .Values.vmagent.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ .Values.vmagent.name | default (include "victoria-metrics-k8s-stack.fullname" .) }}
namespace: {{ .Release.Namespace }}
labels: {{ include "victoria-metrics-k8s-stack.labels" . | nindent 4 }}
spec:
{{ include "victoria-metrics-k8s-stack.vmAgentSpec" . | indent 2 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{{ if and .Values.vmalert.enabled .Values.vmalert.ingress.enabled -}}
{{- $servicePort := 8080 -}}
{{- $ingressPath := .Values.vmalert.ingress.path -}}
{{- $serviceName := printf "%s-%s" "vmalert" (include "victoria-metrics-k8s-stack.fullname" .) | trunc 63 | trimSuffix "-" }}
{{- $ingressPathType := .Values.vmalert.ingress.pathType | default "" -}}
{{- $extraPaths := .Values.vmalert.ingress.extraPaths -}}
{{- $newAPI := .Capabilities.APIVersions.Has "networking.k8s.io/v1" -}}
{{- if $newAPI -}}
apiVersion: networking.k8s.io/v1
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" }}
apiVersion: networking.k8s.io/v1beta1
{{- else }}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ .Values.vmalert.name | default $serviceName }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/component: {{ include "victoria-metrics-k8s-stack.name" $ }}-vmalert
{{ include "victoria-metrics-k8s-stack.labels" . | indent 4 }}
{{- if .Values.vmalert.ingress.labels }}
{{ toYaml .Values.vmalert.ingress.labels | indent 4 }}
{{- end }}
{{- if .Values.vmalert.ingress.annotations }}
annotations:
{{- range $key, $value := .Values.vmalert.ingress.annotations }}
{{ $key }}: {{ tpl $value $ | quote }}
{{- end }}
{{- end }}
spec:
{{- if .Values.vmalert.ingress.ingressClassName }}
ingressClassName: {{ .Values.vmalert.ingress.ingressClassName }}
{{- end -}}
{{- if .Values.vmalert.ingress.tls }}
tls:
{{ tpl (toYaml .Values.vmalert.ingress.tls) $ | indent 4 }}
{{- end }}
rules:
{{- if .Values.vmalert.ingress.hosts }}
{{- range .Values.vmalert.ingress.hosts }}
- host: {{ tpl . $}}
http:
paths:
{{- if $extraPaths }}
{{ toYaml $extraPaths | indent 10 }}
{{- end }}
- path: {{ $ingressPath }}
{{- if $newAPI }}
pathType: {{ $ingressPathType }}
{{- end }}
backend:
{{- if $newAPI }}
service:
name: {{ $serviceName }}
port:
number: {{ $servicePort }}
{{- else }}
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end }}
{{- end }}
{{- else }}
- http:
paths:
- backend:
{{- if $newAPI }}
service:
name: {{ $serviceName }}
port:
number: {{ $servicePort }}
pathType: {{ $ingressPathType }}
{{- else }}
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end }}
{{- if $ingressPath }}
path: {{ $ingressPath }}
{{- end }}
{{- end -}}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -13,86 +13,3 @@ metadata:
spec:
{{ include "victoria-metrics-k8s-stack.vmAlertSpec" . | indent 2 }}
{{- end }}

{{ if and .Values.vmalert.enabled .Values.vmalert.ingress.enabled -}}
---
{{- $servicePort := 8080 -}}
{{- $ingressPath := .Values.vmalert.ingress.path -}}
{{- $serviceName := printf "%s-%s" "vmalert" (include "victoria-metrics-k8s-stack.fullname" .) | trunc 63 | trimSuffix "-" }}
{{- $ingressPathType := .Values.vmalert.ingress.pathType | default "" -}}
{{- $extraPaths := .Values.vmalert.ingress.extraPaths -}}
{{- $newAPI := .Capabilities.APIVersions.Has "networking.k8s.io/v1" -}}
{{- if $newAPI -}}
apiVersion: networking.k8s.io/v1
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" }}
apiVersion: networking.k8s.io/v1beta1
{{- else }}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ .Values.vmalert.name | default $serviceName }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/component: {{ include "victoria-metrics-k8s-stack.name" $ }}-vmalert
{{ include "victoria-metrics-k8s-stack.labels" . | indent 4 }}
{{- if .Values.vmalert.ingress.labels }}
{{ toYaml .Values.vmalert.ingress.labels | indent 4 }}
{{- end }}
{{- if .Values.vmalert.ingress.annotations }}
annotations:
{{- range $key, $value := .Values.vmalert.ingress.annotations }}
{{ $key }}: {{ tpl $value $ | quote }}
{{- end }}
{{- end }}
spec:
{{- if .Values.vmalert.ingress.ingressClassName }}
ingressClassName: {{ .Values.vmalert.ingress.ingressClassName }}
{{- end -}}
{{- if .Values.vmalert.ingress.tls }}
tls:
{{ tpl (toYaml .Values.vmalert.ingress.tls) $ | indent 4 }}
{{- end }}
rules:
{{- if .Values.vmalert.ingress.hosts }}
{{- range .Values.vmalert.ingress.hosts }}
- host: {{ tpl . $}}
http:
paths:
{{- if $extraPaths }}
{{ toYaml $extraPaths | indent 10 }}
{{- end }}
- path: {{ $ingressPath }}
{{- if $newAPI }}
pathType: {{ $ingressPathType }}
{{- end }}
backend:
{{- if $newAPI }}
service:
name: {{ $serviceName }}
port:
number: {{ $servicePort }}
{{- else }}
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end }}
{{- end }}
{{- else }}
- http:
paths:
- backend:
{{- if $newAPI }}
service:
name: {{ $serviceName }}
port:
number: {{ $servicePort }}
pathType: {{ $ingressPathType }}
{{- else }}
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end }}
{{- if $ingressPath }}
path: {{ $ingressPath }}
{{- end }}
{{- end -}}
{{- end }}
Loading

0 comments on commit 86d08c0

Please sign in to comment.