Skip to content

Commit

Permalink
feat(helm): Optionally add the operational UI
Browse files Browse the repository at this point in the history
  • Loading branch information
cyriltovena committed Feb 17, 2025
1 parent 18210e9 commit 5537884
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 13 deletions.
79 changes: 78 additions & 1 deletion production/helm/loki/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,84 @@
.DEFAULT_GOAL := all
.PHONY: lint lint-yaml
.PHONY: lint lint-yaml install-distributed install-single-binary uninstall update-chart update

# Optional image override, example: make install-distributed IMAGE=grafana/loki:2.9.0
IMAGE ?=

# Optional helm arguments, example: make install-distributed ARGS="--set loki.auth.enabled=true"
ARGS ?=

# Default arguments to disable affinity for testing
DEFAULT_ARGS = --set gateway.affinity=null \
--set ingester.affinity=null \
--set distributor.affinity=null \
--set querier.affinity=null \
--set queryFrontend.affinity=null \
--set queryScheduler.affinity=null \
--set indexGateway.affinity=null \
--set compactor.affinity=null \
--set ruler.affinity=null \
--set backend.affinity=null \
--set read.affinity=null \
--set write.affinity=null \
--set singleBinary.affinity=null \
--set memcachedChunks.affinity=null \
--set memcachedFrontend.affinity=null \
--set memcachedIndexQueries.affinity=null \
--set memcachedMetadata.affinity=null \
--set memcachedResults.affinity=null \
--set global.podAntiAffinity=null \
--set global.podAntiAffinityTopologyKey=null

# Generate image override flag if IMAGE is provided
IMAGE_FLAG = $(if $(IMAGE),\
$(eval PARTS=$(subst :, ,$(IMAGE)))\
$(eval REPO_PARTS=$(subst /, ,$(word 1,$(PARTS))))\
$(eval TAG=$(word 2,$(PARTS)))\
$(eval REPO_COUNT=$(words $(REPO_PARTS)))\
$(if $(filter 3,$(REPO_COUNT)),\
--set loki.image.registry=$(word 1,$(REPO_PARTS))/$(word 2,$(REPO_PARTS)) --set loki.image.repository=$(word 3,$(REPO_PARTS)),\
--set loki.image.registry=$(word 1,$(REPO_PARTS)) --set loki.image.repository=$(word 2,$(REPO_PARTS))\
) --set loki.image.tag=$(TAG),)

lint: lint-yaml

lint-yaml:
yamllint -c $(CURDIR)/src/.yamllint.yaml $(CURDIR)/src

# Helm chart installation targets
install-distributed:
helm upgrade --install loki . \
-f distributed-values.yaml \
--create-namespace \
--namespace loki \
$(DEFAULT_ARGS) \
$(IMAGE_FLAG) \
$(ARGS)

install-single-binary:
helm upgrade --install loki . \
-f single-binary-values.yaml \
--create-namespace \
--namespace loki \
$(DEFAULT_ARGS) \
$(IMAGE_FLAG) \
$(ARGS)

# Uninstall Loki helm release and optionally delete the namespace
uninstall:
helm uninstall loki --namespace loki
kubectl delete namespace loki --ignore-not-found

# Update Helm chart dependencies
update-chart:
helm dependency update .

# Update existing installation with latest changes
update:
@if [ "$$(helm get values loki -n loki -o yaml | grep "deploymentMode: Distributed")" ]; then \
echo "Updating distributed deployment..."; \
helm upgrade loki . -f distributed-values.yaml --namespace loki $(DEFAULT_ARGS) $(IMAGE_FLAG) $(ARGS); \
else \
echo "Updating single binary deployment..."; \
helm upgrade loki . -f single-binary-values.yaml --namespace loki $(DEFAULT_ARGS) $(IMAGE_FLAG) $(ARGS); \
fi
6 changes: 6 additions & 0 deletions production/helm/loki/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,12 @@ http {
{{- $schedulerUrl = $backendUrl }}
{{- end -}}

{{- if .Values.loki.ui.gateway.enabled }}
location ^~ /ui {
proxy_pass {{ $distributorUrl }}$request_uri;
}
{{- end }}

# Distributor
location = /api/prom/push {
proxy_pass {{ $distributorUrl }}$request_uri;
Expand Down
36 changes: 24 additions & 12 deletions production/helm/loki/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ loki:
{{- tpl (. | toYaml) $ | nindent 4 }}
{{- end }}
{{- if .Values.loki.ui.enabled }}
ui:
discovery:
join_peers:
- '{{ include "loki.distributorFullname" . }}.{{ $.Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
{{- end }}
{{- with .Values.loki.querier }}
querier:
{{- tpl (. | toYaml) $ | nindent 4 }}
Expand Down Expand Up @@ -417,27 +423,27 @@ loki:
object_store:
# Type of object store. Valid options are: s3, gcs, azure
type: s3
prefix: null # Optional prefix for storage keys
prefix: null # Optional prefix for storage keys

# S3 configuration (when type is "s3")
s3:
endpoint: null # S3 endpoint URL
region: null # Optional region
access_key_id: null # Optional access key
secret_access_key: null # Optional secret key
insecure: false # Optional. Enable if using self-signed TLS
sse: {} # Optional server-side encryption configuration
http: {} # Optional HTTP client configuration
endpoint: null # S3 endpoint URL
region: null # Optional region
access_key_id: null # Optional access key
secret_access_key: null # Optional secret key
insecure: false # Optional. Enable if using self-signed TLS
sse: {} # Optional server-side encryption configuration
http: {} # Optional HTTP client configuration

# GCS configuration (when type is "gcs")
gcs:
bucket_name: null # Name of the bucket
service_account: null # Optional service account JSON
bucket_name: null # Name of the bucket
service_account: null # Optional service account JSON

# Azure configuration (when type is "azure")
azure:
account_name: null # Storage account name
account_key: null # Optional storage account key
account_name: null # Storage account name
account_key: null # Optional storage account key

# -- Configure memcached as an external cache for chunk and results cache. Disabled by default
# must enable and specify a host for each cache you would like to use.
Expand Down Expand Up @@ -497,6 +503,12 @@ loki:
enabled: false
# -- Optional analytics configuration
analytics: {}
# -- Optional UI configuration
ui:
enabled: false
gateway:
# enable gateway proxying to UI under /ui
enabled: true
# -- Optional querier configuration
query_range: {}
# -- Optional querier configuration
Expand Down

0 comments on commit 5537884

Please sign in to comment.