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

refactor(singlebinary): move from trigger to helpers #12727

Closed
wants to merge 6 commits into from
Closed
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
7 changes: 7 additions & 0 deletions production/helm/loki/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ singleBinary fullname
{{- end -}}
{{- end -}}

{{/*
Return if deployment mode is single binary
*/}}
{{- define "loki.deployment.isSingleBinary" -}}
{{- or (eq .Values.deploymentMode "SingleBinary") (eq .Values.deploymentMode "SingleBinary<->OtherModes") (and (eq .Values.oldDeploymentMode "SingleBinary") (ne .Values.deploymentMode "SingleBinary")) }}
{{- end -}}

{{/*
Resource name template
Params:
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/templates/backend/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (not .Values.rbac.namespaced) (not .Values.rbac.useExistingRole) }}
{{- if and $isSimpleScalable (not .Values.rbac.namespaced) (not .Values.rbac.useExistingRole) (not (include "loki.deployment.isSingleBinary" .)) }}
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (not .Values.rbac.namespaced) }}
{{- if and $isSimpleScalable (not .Values.rbac.namespaced) (not (include "loki.deployment.isSingleBinary" .)) }}
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/templates/backend/hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- $autoscalingv2 := .Capabilities.APIVersions.Has "autoscaling/v2" -}}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) ( .Values.backend.autoscaling.enabled ) }}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) ( .Values.backend.autoscaling.enabled ) (not (include "loki.deployment.isSingleBinary" .)) }}
{{- if $autoscalingv2 }}
apiVersion: autoscaling/v2
{{- else }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (gt (int .Values.backend.replicas) 1) (not .Values.read.legacyReadTarget ) }}
{{- if and $isSimpleScalable (gt (int .Values.backend.replicas) 1) (not .Values.read.legacyReadTarget ) (not (include "loki.deployment.isSingleBinary" .)) }}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) }}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) (not (include "loki.deployment.isSingleBinary" .)) }}
---
apiVersion: v1
kind: Service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) }}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) (not (include "loki.deployment.isSingleBinary" .)) }}
---
apiVersion: v1
kind: Service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) }}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) (not (include "loki.deployment.isSingleBinary" .)) }}
---
apiVersion: v1
kind: Service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) }}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) (not (include "loki.deployment.isSingleBinary" .)) }}
---
apiVersion: apps/v1
kind: StatefulSet
Expand All @@ -19,12 +19,8 @@ metadata:
{{- end }}
{{- end }}
spec:
{{- if not .Values.write.autoscaling.enabled }}
{{- if eq .Values.deploymentMode "SingleBinary" }}
replicas: 0
{{- else }}
replicas: {{ .Values.write.replicas }}
{{- end }}
{{- if not .Values.backend.autoscaling.enabled }}
replicas: {{ .Values.backend.replicas }}
{{- end }}
podManagementPolicy: {{ .Values.backend.podManagementPolicy }}
updateStrategy:
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/templates/read/deployment-read.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) }}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) (not (include "loki.deployment.isSingleBinary" .)) }}
---
apiVersion: apps/v1
kind: Deployment
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/templates/read/hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- $autoscalingv2 := .Capabilities.APIVersions.Has "autoscaling/v2" -}}
{{- if and $isSimpleScalable ( .Values.read.autoscaling.enabled ) }}
{{- if and $isSimpleScalable ( .Values.read.autoscaling.enabled ) (not (include "loki.deployment.isSingleBinary" .)) }}
{{- if $autoscalingv2 }}
apiVersion: autoscaling/v2
{{- else }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (gt (int .Values.read.replicas) 1) }}
{{- if and $isSimpleScalable (gt (int .Values.read.replicas) 1) (not (include "loki.deployment.isSingleBinary" .)) }}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{ if $isSimpleScalable }}
{{- if and $isSimpleScalable (not (include "loki.deployment.isSingleBinary" .)) }}
---
apiVersion: v1
kind: Service
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/templates/read/service-read.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if $isSimpleScalable }}
{{- if and $isSimpleScalable (not (include "loki.deployment.isSingleBinary" .)) }}
---
apiVersion: v1
kind: Service
Expand Down
6 changes: 1 addition & 5 deletions production/helm/loki/templates/read/statefulset-read.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (.Values.read.legacyReadTarget ) }}
{{- if and $isSimpleScalable (.Values.read.legacyReadTarget ) (not (include "loki.deployment.isSingleBinary" .)) }}
---
apiVersion: apps/v1
kind: StatefulSet
Expand All @@ -20,11 +20,7 @@ metadata:
{{- end }}
spec:
{{- if not .Values.write.autoscaling.enabled }}
{{- if eq .Values.deploymentMode "SingleBinary" }}
replicas: 0
{{- else }}
replicas: {{ .Values.write.replicas }}
{{- end }}
{{- end }}
podManagementPolicy: {{ .Values.read.podManagementPolicy }}
updateStrategy:
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/templates/write/hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- $autoscalingv2 := .Capabilities.APIVersions.Has "autoscaling/v2" -}}
{{- if and $isSimpleScalable ( .Values.write.autoscaling.enabled ) }}
{{- if and $isSimpleScalable ( .Values.write.autoscaling.enabled ) (not (include "loki.deployment.isSingleBinary" .)) }}
{{- if $autoscalingv2 }}
apiVersion: autoscaling/v2
{{- else }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (gt (int .Values.write.replicas) 1) }}
{{- if and $isSimpleScalable (gt (int .Values.write.replicas) 1) (not (include "loki.deployment.isSingleBinary" .)) }}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if $isSimpleScalable }}
{{- if and $isSimpleScalable (not (include "loki.deployment.isSingleBinary" .)) }}
---
apiVersion: v1
kind: Service
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/templates/write/service-write.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if $isSimpleScalable }}
{{- if and $isSimpleScalable (not (include "loki.deployment.isSingleBinary" .)) }}
---
apiVersion: v1
kind: Service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if $isSimpleScalable }}
{{- if and $isSimpleScalable (not (include "loki.deployment.isSingleBinary" .)) }}
---
apiVersion: apps/v1
kind: StatefulSet
Expand All @@ -20,11 +20,7 @@ metadata:
{{- end }}
spec:
{{- if not .Values.write.autoscaling.enabled }}
{{- if eq .Values.deploymentMode "SingleBinary" }}
replicas: 0
{{- else }}
replicas: {{ .Values.write.replicas }}
{{- end }}
{{- end }}
podManagementPolicy: {{ .Values.write.podManagementPolicy }}
updateStrategy:
Expand Down
Loading