Skip to content

Commit

Permalink
Merge pull request #1325 from trevorwhitney/combine-gel-oss-ssd
Browse files Browse the repository at this point in the history
[loki-simple-scalable] Make enterprise a configurable option
  • Loading branch information
trevorwhitney authored May 2, 2022
2 parents dbd1951 + 5f31332 commit 86b5a9f
Show file tree
Hide file tree
Showing 21 changed files with 612 additions and 53 deletions.
6 changes: 6 additions & 0 deletions charts/loki-simple-scalable/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: minio
repository: https://helm.min.io/
version: 8.0.9
digest: sha256:87380dcd409a28ba7ece02fff63993a66077cba05350dbae0b60b3dd410d04df
generated: "2022-04-22T16:01:21.40225696-06:00"
8 changes: 7 additions & 1 deletion charts/loki-simple-scalable/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ name: loki-simple-scalable
description: Helm chart for Grafana Loki in simple, scalable mode
type: application
appVersion: 2.5.0
version: 0.4.0
version: 1.0.0
home: https://grafana.github.io/helm-charts
sources:
- https://github.com/grafana/loki
- https://grafana.com/oss/loki/
- https://grafana.com/docs/loki/latest/
icon: https://grafana.com/docs/loki/latest/logo_and_name.png
dependencies:
- name: minio
alias: minio
version: 8.0.9
repository: https://helm.min.io/
condition: minio.enabled
maintainers:
- name: trevorwhitney
8 changes: 8 additions & 0 deletions charts/loki-simple-scalable/ci/default-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
loki:
commonConfig:
replication_factor: 1
read:
replicas: 1
write:
replicas: 1
25 changes: 25 additions & 0 deletions charts/loki-simple-scalable/ci/enterprise.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
enterprise:
enabled: true
config: |
auth:
type: trust
auth_enabled: false
cluster_name: {{ .Release.Name }}
license:
path: /etc/loki/license/license.jwt
loki:
commonConfig:
replication_factor: 1
storage:
type: local
read:
replicas: 1
persistence:
enabled: true
size: 100Mi
write:
replicas: 1
persistence:
enabled: true
size: 100Mi
8 changes: 8 additions & 0 deletions charts/loki-simple-scalable/ci/ingress-values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
gateway:
ingress:
enabled: true
Expand All @@ -7,3 +8,10 @@ gateway:
paths:
- path: /
pathType: Prefix
loki:
commonConfig:
replication_factor: 1
read:
replicas: 1
write:
replicas: 1
6 changes: 6 additions & 0 deletions charts/loki-simple-scalable/ci/persistence-values.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
read:
replicas: 1
persistence:
enabled: true
size: 100Mi

write:
replicas: 1
persistence:
enabled: true
size: 100Mi

loki:
commonConfig:
replication_factor: 1

gateway:
nginxConfig:
httpSnippet: |-
Expand Down
83 changes: 74 additions & 9 deletions charts/loki-simple-scalable/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
Expand the name of the chart.
*/}}
{{- define "loki.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- $default := ternary "enterprise-logs" "loki" .Values.enterprise.enabled }}
{{- coalesce .Values.nameOverride $default | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Expand All @@ -14,7 +15,7 @@ If release name contains chart name it will be used as a full name.
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- $name := include "loki.name" . }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand Down Expand Up @@ -73,23 +74,78 @@ Create the name of the service account to use
{{- end -}}
{{- end -}}

{{/*
Base template for building docker image reference
*/}}
{{- define "loki.baseImage" }}
{{- $registry := .global.registry | default .service.registry -}}
{{- $repository := .service.repository -}}
{{- $tag := .service.tag | default .defaultVersion | toString -}}
{{- printf "%s/%s:%s" $registry $repository $tag -}}
{{- end -}}

{{/*
Docker image name for Loki
*/}}
{{- define "loki.lokiImage" -}}
{{- $registry := coalesce .global.registry .service.registry .loki.registry -}}
{{- $repository := coalesce .service.repository .loki.repository -}}
{{- $tag := coalesce .service.tag .loki.tag .defaultVersion | toString -}}
{{- printf "%s/%s:%s" $registry $repository $tag -}}
{{- $dict := dict "service" .Values.loki.image "global" .Values.global.image "defaultVersion" .Chart.AppVersion -}}
{{- include "loki.baseImage" $dict -}}
{{- end -}}

{{/*
Docker image name for enterprise logs
*/}}
{{- define "loki.enterpriseImage" -}}
{{- $dict := dict "service" .Values.enterprise.image "global" .Values.global.image "defaultVersion" .Values.enterprise.version -}}
{{- include "loki.baseImage" $dict -}}
{{/* {{- printf "foo" -}} */}}
{{- end -}}

{{/*
Docker image name
*/}}
{{- define "loki.image" -}}
{{- $registry := coalesce .global.registry .service.registry -}}
{{- $tag := .service.tag | toString -}}
{{- printf "%s/%s:%s" $registry .service.repository (.service.tag | toString) -}}
{{- if .Values.enterprise.enabled -}}{{- include "loki.enterpriseImage" . -}}{{- else -}}{{- include "loki.lokiImage" . -}}{{- end -}}
{{- end -}}

{{/*
Generated storage config for loki common config
*/}}
{{- define "loki.commonStorageConfig" -}}
{{- if .Values.minio.enabled -}}
s3:
endpoint: {{ include "loki.minio" $ }}
bucketnames: {{ $.Values.loki.storage.bucketNames.chunks }}
secret_access_key: supersecret
access_key_id: enterprise-logs
s3forcepathstyle: true
insecure: true
{{- else if eq .Values.loki.storage.type "s3" -}}
{{- with .Values.loki.storage.s3 }}
s3:
s3: {{ .s3 }}
endpoint: {{ .endpoint }}
bucketnames: {{ $.Values.loki.storage.bucketNames.chunks }}
secret_access_key: {{ .secretAccessKey }}
access_key_id: {{ .accessKeyId }}
s3forcepathstyle: {{ .s3ForcePathStyle }}
insecure: {{ .insecure }}
{{- end -}}
{{- else if eq .Values.loki.storage.type "gcs" -}}
{{- with .Values.loki.storage.gcs }}
gcs:
bucket_name: {{ $.Values.loki.storage.bucketNames.chunks }}
chunk_buffer_size: {{ .chunkBufferSize }}
request_timeout: {{ .requestTimeout }}
enable_http2: {{ .enableHttp2}}
{{- end -}}
{{- else -}}
{{- with .Values.loki.storage.local }}
filesystem:
chunks_directory: {{ .chunksDirectory }}
rules_directory: {{ .rulesDirectory }}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Expand Down Expand Up @@ -141,3 +197,12 @@ Return if ingress supports pathType.
{{- define "loki.ingress.supportsPathType" -}}
{{- or (eq (include "loki.ingress.isStable" .) "true") (and (eq (include "loki.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}}
{{- end -}}

{{/*
Create the service endpoint including port for MinIO.
*/}}
{{- define "loki.minio" -}}
{{- if .Values.minio.enabled -}}
{{- printf "%s-%s.%s.svc:%s" .Release.Name "minio" .Release.Namespace (.Values.minio.service.port | toString) -}}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ gateway Docker image
*/}}
{{- define "loki.gatewayImage" -}}
{{- $dict := dict "service" .Values.gateway.image "global" .Values.global.image -}}
{{- include "loki.image" $dict -}}
{{- include "loki.baseImage" $dict -}}
{{- end }}

{{/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ metadata:
{{- include "loki.gatewayLabels" . | nindent 4 }}
data:
nginx.conf: |
{{- tpl .Values.gateway.nginxConfig.file . | nindent 4 }}
{{- tpl (ternary .Values.enterprise.nginxConfig.file .Values.gateway.nginxConfig.file .Values.enterprise.enabled) . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ spec:
labels:
{{- include "loki.gatewaySelectorLabels" . | nindent 8 }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
serviceAccountName: {{ include "loki.serviceAccountName" . -}}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.gatewayPriorityClassName" . | nindent 6 }}
{{- end -}}
{{- include "loki.gatewayPriorityClassName" . | nindent 6 -}}
securityContext:
{{- toYaml .Values.gateway.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.gateway.terminationGracePeriodSeconds }}
Expand Down
8 changes: 0 additions & 8 deletions charts/loki-simple-scalable/templates/read/_helpers-read.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ read selector labels
app.kubernetes.io/component: read
{{- end }}

{{/*
read image
*/}}
{{- define "loki.readImage" -}}
{{- $dict := dict "loki" .Values.loki.image "service" .Values.read.image "global" .Values.global.image "defaultVersion" .Chart.AppVersion -}}
{{- include "loki.lokiImage" $dict -}}
{{- end }}

{{/*
read priority class name
*/}}
Expand Down
15 changes: 14 additions & 1 deletion charts/loki-simple-scalable/templates/read/statefulset-read.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
terminationGracePeriodSeconds: {{ .Values.read.terminationGracePeriodSeconds }}
containers:
- name: loki
image: {{ include "loki.readImage" . }}
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
args:
- -config.file=/etc/loki/config/config.yaml
Expand Down Expand Up @@ -78,6 +78,10 @@ spec:
mountPath: /tmp
- name: data
mountPath: /var/loki
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end}}
{{- with .Values.read.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -106,6 +110,15 @@ spec:
configMap:
name: {{ include "loki.fullname" . }}
{{- end }}
{{- if .Values.enterprise.enabled }}
- name: license
secret:
{{- if .Values.useExternalLicense }}
secretName: {{ .Values.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
{{- with .Values.read.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down
10 changes: 10 additions & 0 deletions charts/loki-simple-scalable/templates/secret-license.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if and (not .Values.useExternalLicense) .Values.enterprise.enabled -}}
apiVersion: v1
kind: Secret
metadata:
name: enterprise-logs-license
labels:
{{- include "loki.labels" . | nindent 4 }}
data:
license.jwt: {{ .Values.enterprise.license.contents | b64enc }}
{{- end }}
22 changes: 22 additions & 0 deletions charts/loki-simple-scalable/templates/tokengen/_helpers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{/*
tokengen fullname
*/}}
{{- define "enterprise-logs.tokengenFullname" -}}
{{ include "loki.fullname" . }}-tokengen
{{- end }}

{{/*
tokengen common labels
*/}}
{{- define "enterprise-logs.tokengenLabels" -}}
{{ include "loki.labels" . }}
app.kubernetes.io/component: tokengen
{{- end }}

{{/*
tokengen selector labels
*/}}
{{- define "enterprise-logs.tokengenSelectorLabels" -}}
{{ include "loki.selectorLabels" . }}
app.kubernetes.io/component: tokengen
{{- end }}
Loading

0 comments on commit 86b5a9f

Please sign in to comment.