Skip to content

Commit

Permalink
introduce the idea of a chart mode
Browse files Browse the repository at this point in the history
Signed-off-by: Edward Welch <[email protected]>
  • Loading branch information
slim-bean committed Feb 28, 2024
1 parent 289c74c commit a5ddb10
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
9 changes: 3 additions & 6 deletions production/helm/loki/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,21 @@ Params:
Return if deployment mode is simple scalable
*/}}
{{- define "loki.deployment.isScalable" -}}
{{- $nonZeroScalableReplicas := (or (gt (int .Values.backend.replicas) 0) (gt (int .Values.read.replicas) 0) (gt (int .Values.write.replicas) 0)) }}
{{- and (eq (include "loki.isUsingObjectStorage" . ) "true") (eq (int .Values.singleBinary.replicas) 0) ($nonZeroScalableReplicas) }}
{{- and (eq (include "loki.isUsingObjectStorage" . ) "true") (or (eq .Values.deploymentMode "SimpleScalable")) (eq .Values.deploymentMode "SimpleScalable-Distributed") }}
{{- end -}}

{{/*
Return if deployment mode is single binary
*/}}
{{- define "loki.deployment.isSingleBinary" -}}
{{- $nonZeroReplicas := gt (int .Values.singleBinary.replicas) 0 }}
{{- or (eq (include "loki.isUsingObjectStorage" . ) "false") ($nonZeroReplicas) }}
{{- or (eq .Values.deploymentMode "SingleBinary") (eq .Values.deploymentMode "SingleBinary-SimpleScalable") }}
{{- end -}}

{{/*
Return if deployment mode is distributed
*/}}
{{- define "loki.deployment.isDistributed" -}}
{{- $zeroScalableReplicas := (and (eq (int .Values.backend.replicas) 0) (eq (int .Values.read.replicas) 0) (eq (int .Values.write.replicas) 0)) }}
{{- and (eq (include "loki.isUsingObjectStorage" . ) "true") ($zeroScalableReplicas) }}
{{- and (eq (include "loki.isUsingObjectStorage" . ) "true") (or (eq .Values.deploymentMode "Distributed") (eq .Values.deploymentMode "SimpleScalable-Distributed")) }}
{{- end -}}


Expand Down
8 changes: 4 additions & 4 deletions production/helm/loki/templates/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
{{- fail "Cannot run scalable targets (backend, read, write) or distributed targets without an object storage backend."}}
{{- end }}

{{- if and $atLeastOneScalableReplica $atLeastOneDistributedReplica }}
{{- fail "Cannot run replicas of both scalable targets (backend, read, write) and distributed targets. Must pick one deployment type."}}
{{- if and $atLeastOneScalableReplica $atLeastOneDistributedReplica (ne .Values.deploymentMode "SimpleScalable-Distributed") }}
{{- fail "You have more than zero replicas configured for scalable targets (backend, read, write) and distributed targets. If this was intentional change the deploymentMode to the transitional 'SimpleScalable-Distributed' mode" }}
{{- end }}

{{- if and (gt $singleBinaryReplicas 0) $atLeastOneDistributedReplica }}
{{- fail "Cannot run replicas of both distributed targets and single binary targets. Must pick one deployment type."}}
{{- fail "You have more than zero replicas configured for both the single binary and distributed targets, there is no transition mode between these targets please change one or the other to zero or transition to the SimpleScalable mode first."}}
{{- end }}

{{- if and (gt $singleBinaryReplicas 0) $atLeastOneScalableReplica }}
{{- fail "Cannot run replicas of both scalable targets (read, write, backend) and single binary targets. Must pick one deployment type."}}
{{- fail "You have more than zero replicas configured for both the single binary and simple scalable targets. If this was intentional change the deploymentMode to the transitional 'SingleBinary-SimpleScalable' mode"}}
{{- end }}
10 changes: 10 additions & 0 deletions production/helm/loki/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ clusterLabelOverride: null
# -- Image pull secrets for Docker images
imagePullSecrets: []

# -- Deployment mode lets you specify how to deploy Loki.
# There are 3 options:
# - SingleBinary: Loki is deployed as a single binary, useful for small installs typically without HA, up to a few tens of GB/day.
# - SimpleScalable: Loki is deployed as 3 targets: read, write, and backend. Useful for medium installs easier to manage than distributed, up to a about 1TB/day.
# - Distributed: Loki is deployed as individual microservices. The most complicated but most capable, useful for large installs, typically over 1TB/day.
# There are also 2 additional modes used for migrating between deployment modes:
# - SingleBinary-SimpleScalable: Migrate from SingleBinary to SimpleScalable (or vice versa)
# - SimpleScalable-Distributed: Migrate from SimpleScalable to Distributed (or vice versa)
# Note: SimpleScalable and Distributed REQUIRE the use of object storage.
deploymentMode: SimpleScalable

######################################################################################################################
#
Expand Down

0 comments on commit a5ddb10

Please sign in to comment.