Skip to content

Commit 352a1a6

Browse files
authored
chore: update loki for kb09 (#1809)
1 parent 9e53b8c commit 352a1a6

24 files changed

+793
-1378
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: A loki cluster Helm chart for KubeBlocks.
44

55
type: application
66

7-
version: 0.9.0
7+
version: 0.9.1
88

99
appVersion: "3.0.0"
1010

File renamed without changes.
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "loki-cluster.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "loki-cluster.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{- define "loki-cluster.memberlist" -}}
27+
{{ include "clustername" . }}-memberlist
28+
{{- end -}}
29+
30+
{{- define "clustername" -}}
31+
{{ include "loki-cluster.fullname" .}}
32+
{{- end}}
33+
34+
{{/*
35+
Create chart name and version as used by the chart label.
36+
*/}}
37+
{{- define "loki-cluster.chart" -}}
38+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
39+
{{- end }}
40+
41+
{{/*
42+
Common labels
43+
*/}}
44+
{{- define "loki-cluster.labels" -}}
45+
helm.sh/chart: {{ include "loki-cluster.chart" . }}
46+
{{ include "loki-cluster.selectorLabels" . }}
47+
{{- if .Chart.AppVersion }}
48+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
49+
{{- end }}
50+
app.kubernetes.io/managed-by: {{ .Release.Service }}
51+
{{- end }}
52+
53+
{{/*
54+
Selector labels
55+
*/}}
56+
{{- define "loki-cluster.selectorLabels" -}}
57+
{{/*app.kubernetes.io/name: {{ include "loki-cluster.name" . }}*/}}
58+
app.kubernetes.io/instance: {{ .Release.Name }}
59+
{{- end }}
60+
61+
{{/*
62+
write fullname
63+
*/}}
64+
{{- define "loki-cluster.writeFullname" -}}
65+
{{ include "loki-cluster.name" . }}-write
66+
{{- end }}
67+
68+
{{/*
69+
read fullname
70+
*/}}
71+
{{- define "loki-cluster.readFullname" -}}
72+
{{ include "loki-cluster.name" . }}-read
73+
{{- end }}
74+
75+
{{/*
76+
backend fullname
77+
*/}}
78+
{{- define "loki-cluster.backendFullname" -}}
79+
{{ include "loki-cluster.name" . }}-backend
80+
{{- end }}
81+
82+
{{/*
83+
gateway fullname
84+
*/}}
85+
{{- define "loki-cluster.gatewayFullname" -}}
86+
{{ include "loki-cluster.fullname" . }}-gateway
87+
{{- end }}
88+
89+
90+
{{/*
91+
gateway selector labels
92+
*/}}
93+
{{- define "loki-cluster.gatewaySelectorLabels" -}}
94+
{{ include "loki-cluster.selectorLabels" . }}
95+
app.kubernetes.io/component: gateway
96+
{{- end }}
97+
98+
{{/*
99+
gateway auth secret name
100+
*/}}
101+
{{- define "loki-cluster.gatewayAuthSecret" -}}
102+
{{ .Values.gateway.basicAuth.existingSecret | default (include "loki-cluster.gatewayFullname" . ) }}
103+
{{- end }}
104+
105+
{{/*
106+
gateway Docker image
107+
*/}}
108+
{{- define "loki-cluster.gatewayImage" -}}
109+
{{- $dict := dict "service" .Values.gateway.image "global" .Values.global.image -}}
110+
{{- include "loki-cluster.baseImage" $dict -}}
111+
{{- end }}
112+
113+
{{/*
114+
gateway priority class name
115+
*/}}
116+
{{- define "loki-cluster.gatewayPriorityClassName" -}}
117+
{{- $pcn := coalesce .Values.global.priorityClassName .Values.gateway.priorityClassName -}}
118+
{{- if $pcn }}
119+
priorityClassName: {{ $pcn }}
120+
{{- end }}
121+
{{- end }}
122+
123+
{{/*
124+
distributor fullname
125+
*/}}
126+
{{- define "loki-cluster.distributorFullname" -}}
127+
{{ include "loki-cluster.fullname" . }}-distributor
128+
{{- end }}
129+
130+
{{/*
131+
ingester fullname
132+
*/}}
133+
{{- define "loki-cluster.ingesterFullname" -}}
134+
{{ include "loki-cluster.fullname" . }}-ingester
135+
{{- end }}
136+
137+
{{/*
138+
query-frontend fullname
139+
*/}}
140+
{{- define "loki-cluster.queryFrontendFullname" -}}
141+
{{ include "loki-cluster.fullname" . }}-query-frontend
142+
{{- end }}
143+
144+
{{/*
145+
index-gateway fullname
146+
*/}}
147+
{{- define "loki-cluster.indexGatewayFullname" -}}
148+
{{ include "loki-cluster.fullname" . }}-index-gateway
149+
{{- end }}
150+
151+
{{/*
152+
ruler fullname
153+
*/}}
154+
{{- define "loki-cluster.rulerFullname" -}}
155+
{{ include "loki-cluster.fullname" . }}-ruler
156+
{{- end }}
157+
158+
{{/*
159+
compactor fullname
160+
*/}}
161+
{{- define "loki-cluster.compactorFullname" -}}
162+
{{ include "loki-cluster.fullname" . }}-compactor
163+
{{- end }}
164+
165+
{{/*
166+
query-scheduler fullname
167+
*/}}
168+
{{- define "loki-cluster.querySchedulerFullname" -}}
169+
{{ include "loki-cluster.fullname" . }}-query-scheduler
170+
{{- end }}
171+
172+
{{/*
173+
gateway common labels
174+
*/}}
175+
{{- define "loki-cluster.gatewayLabels" -}}
176+
{{ include "loki-cluster.labels" . }}
177+
app.kubernetes.io/component: gateway
178+
{{- end }}
179+
180+
{{- define "loki-cluster.s3storage" }}
181+
env:
182+
- name: STORAGE_TYPE
183+
{{- with .Values.s3.storageType }}
184+
value: {{ . }}
185+
{{- else }}
186+
valueFrom:
187+
secretKeyRef:
188+
key: storageType
189+
optional: true
190+
name: {{ .Values.s3.secret }}
191+
{{- end }}
192+
{{- if or ( not .Values.s3.storageType ) ( ne .Values.s3.storageType "local") }}
193+
- name: ENDPOINT
194+
valueFrom:
195+
secretKeyRef:
196+
key: endpoint
197+
name: {{ .Values.s3.secret }}
198+
- name: REGION
199+
valueFrom:
200+
secretKeyRef:
201+
key: region
202+
name: {{ .Values.s3.secret }}
203+
- name: ACCESS_KEY_ID
204+
valueFrom:
205+
secretKeyRef:
206+
key: accessKey
207+
name: {{ .Values.s3.secret }}
208+
- name: SECRET_ACCESS_KEY
209+
valueFrom:
210+
secretKeyRef:
211+
key: secretKey
212+
name: {{ .Values.s3.secret }}
213+
- name: BUCKETNAMES
214+
valueFrom:
215+
secretKeyRef:
216+
key: bucketnames
217+
name: {{ .Values.s3.secret }}
218+
- name: RULER_BUCKETNAMES
219+
valueFrom:
220+
secretKeyRef:
221+
key: rulerBucketnames
222+
name: {{ .Values.s3.secret }}
223+
{{- end }}
224+
{{- end -}}

addons-cluster/loki/templates/cluster.yaml renamed to addons-cluster/loki-cluster/templates/cluster.yaml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
1-
apiVersion: apps.kubeblocks.io/v1alpha1
2-
kind: Cluster
3-
metadata:
4-
name: {{ include "clustername" . }}
5-
labels:
6-
{{- include "loki-cluster.labels" . | nindent 4 }}
7-
spec:
1+
{{- include "kblib.clusterCommon" . }}
82
clusterDefinitionRef: loki
93
terminationPolicy: {{ .Values.terminationPolicy }}
104
topology: loki-cluster
5+
services:
6+
- name: default
7+
serviceName: memberlist
8+
spec:
9+
ports:
10+
- name: tcp
11+
port: 7946
12+
targetPort: http-memberlist
13+
protocol: TCP
14+
selector:
15+
{{- include "loki-cluster.selectorLabels" . | nindent 10 }}
16+
app.kubernetes.io/part-of: memberlist
1117
componentSpecs:
1218
- name: backend
1319
{{- include "kblib.componentMonitor" . | indent 6 }}
20+
{{- include "loki-cluster.s3storage" . | indent 6 }}
1421
replicas: {{ .Values.replicas }}
1522
{{- include "kblib.componentResources" . | indent 6 }}
1623
{{- include "kblib.componentStorages" . | indent 6 }}
1724
- name: write
1825
{{- include "kblib.componentMonitor" . | indent 6 }}
1926
replicas: {{ .Values.write.replicas }}
27+
{{- include "loki-cluster.s3storage" . | indent 6 }}
2028
{{- with .Values.write.resources }}
2129
resources:
2230
{{- with .limits }}
@@ -33,6 +41,7 @@ spec:
3341
- name: read
3442
{{- include "kblib.componentMonitor" . | indent 6 }}
3543
replicas: {{ .Values.read.replicas | default 1 }}
44+
{{- include "loki-cluster.s3storage" . | indent 6 }}
3645
{{- with .Values.read.resources }}
3746
resources:
3847
{{- with .limits }}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Default values for loki-cluster.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
global:
5+
# -- configures cluster domain ("cluster.local" by default)
6+
clusterDomain: "cluster.local"
7+
# -- configures DNS service name
8+
dnsService: "kube-dns"
9+
# -- configures DNS service namespace
10+
dnsNamespace: "kube-system"
11+
12+
enterprise:
13+
enabled: false
14+
15+
read:
16+
replicas: 1
17+
httpMetricsPort: 3100
18+
grpcPort: 9095
19+
httpMemberlistPort: 7946
20+
21+
write:
22+
replicas: 1
23+
httpMetricsPort: 3100
24+
grpcPort: 9095
25+
httpMemberlistPort: 7946
26+
27+
backend:
28+
replicas: 1
29+
httpMetricsPort: 3100
30+
grpcPort: 9095
31+
httpMemberlistPort: 7946
32+
33+
gateway:
34+
replicas: 1
35+
basicAuth:
36+
# -- Enables basic authentication for the gateway
37+
enabled: false
38+
nginxConfig:
39+
# -- Which schema to be used when building URLs. Can be 'http' or 'https'.
40+
schema: http
41+
# -- Enable listener for IPv6, disable on IPv4-only systems
42+
enableIPv6: true
43+
# -- NGINX log format
44+
logFormat: |-
45+
main '$remote_addr - $remote_user [$time_local] $status '
46+
'"$request" $body_bytes_sent "$http_referer" '
47+
'"$http_user_agent" "$http_x_forwarded_for"';
48+
# -- Allows appending custom configuration to the server block
49+
serverSnippet: ""
50+
# -- Allows appending custom configuration to the http block, passed through the `tpl` function to allow templating
51+
httpSnippet: >-
52+
{{ if .Values.loki.tenants }}proxy_set_header X-Scope-OrgID $remote_user;{{ end }}
53+
# -- Whether ssl should be appended to the listen directive of the server block or not.
54+
ssl: false
55+
# -- Override Read URL
56+
customReadUrl: null
57+
# -- Override Write URL
58+
customWriteUrl: null
59+
# -- Override Backend URL
60+
customBackendUrl: null
61+
# -- Allows overriding the DNS resolver address nginx will use.
62+
resolver: ""
63+
# -- Config file contents for Nginx. Passed through the `tpl` function to allow templating
64+
# @default -- See values.yaml
65+
file: |
66+
{{- include "loki-cluster.nginxFile" . | indent 2 -}}
67+
httpMetricsContainerPort: 8080
68+
httpMetricsSvcPort: 80
69+
70+
nameOverride: ""
71+
fullnameOverride: ""
72+
minio:
73+
enabled: false
74+
## @param storageClassName, storage class name
75+
##
76+
storageClassName: ""
77+
## @param terminationPolicy, temination policy for loki-cluster
78+
##
79+
terminationPolicy: "Delete"
80+
81+
## @param replicas specify cluster replicas
82+
##
83+
replicas: 1
84+
85+
## @param cpu
86+
##
87+
cpu: 0.5
88+
89+
## @param memory, the unit is Gi
90+
##
91+
memory: 0.5
92+
93+
requests:
94+
# cpu:
95+
# memory:
96+
97+
## @param storage size, the unit is Gi
98+
##
99+
storage: 20
100+
101+
s3:
102+
## "s3", "local" or "oss"
103+
storageType: "local"
104+
secret: ""
105+
106+

0 commit comments

Comments
 (0)