Skip to content

Commit

Permalink
chore: upgrade loki to v1.0 API (#1109)
Browse files Browse the repository at this point in the history
  • Loading branch information
Y-Rookie authored Oct 23, 2024
1 parent 4fdc89b commit 4b5acde
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 72 deletions.
2 changes: 1 addition & 1 deletion addons/loki/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ maintainers:
url: https://github.com/apecloud/kubeblocks/

annotations:
addon.kubeblocks.io/kubeblocks-version: ">=0.8.0"
addon.kubeblocks.io/kubeblocks-version: ">=1.0.0"
addon.kubeblocks.io/model: "tsdb"
addon.kubeblocks.io/provider: "community"
83 changes: 62 additions & 21 deletions addons/loki/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@ If release name contains chart name it will be used as a full name.
{{- end }}
{{- end }}

{{/* Create a default storage config that uses filesystem storage
This is required for CI, but Loki will not be queryable with this default
applied, thus it is encouraged that users override this.
*/}}
{{- define "loki.storageConfig" -}}
{{- if .Values.loki.storageConfig -}}
{{- .Values.loki.storageConfig | toYaml | nindent 4 -}}
{{- else }}
{{- .Values.loki.defaultStorageConfig | toYaml | nindent 4 }}
{{- end}}
{{- end}}

{{/*
Create chart name and version as used by the chart label.
*/}}
Expand Down Expand Up @@ -64,15 +52,11 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
Common annotations
*/}}
{{- define "loki.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "loki.name" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{- define "loki.annotations" -}}
helm.sh/resource-policy: keep
{{- end }}

{{/*
Base template for building docker image reference
Expand Down Expand Up @@ -521,4 +505,61 @@ query-scheduler fullname
*/}}
{{- define "loki.querySchedulerFullname" -}}
{{ include "loki.fullname" . }}-query-scheduler
{{- end }}
{{- end }}

{{/*
Define loki backend component definition name
*/}}
{{- define "loki.backendCmpdName" -}}
loki-backend-{{ .Chart.Version }}
{{- end -}}

{{/*
Define loki backend component definition regular expression name prefix
*/}}
{{- define "loki.backendCmpdRegexpPattern" -}}
^loki-backend-
{{- end -}}

{{/*
Define loki gateway component definition name
*/}}
{{- define "loki.gatewayCmpdName" -}}
loki-gateway-{{ .Chart.Version }}
{{- end -}}

{{/*
Define loki backend component definition regular expression name prefix
*/}}
{{- define "loki.gatewayCmpdRegexpPattern" -}}
^loki-gateway-
{{- end -}}

{{/*
Define loki read component definition name
*/}}
{{- define "loki.readCmpdName" -}}
loki-read-{{ .Chart.Version }}
{{- end -}}

{{/*
Define loki read component definition regular expression name prefix
*/}}
{{- define "loki.readCmpdRegexpPattern" -}}
^loki-read-
{{- end -}}


{{/*
Define loki write component definition name
*/}}
{{- define "loki.writeCmpdName" -}}
loki-write-{{ .Chart.Version }}
{{- end -}}

{{/*
Define loki write component definition regular expression name prefix
*/}}
{{- define "loki.writeCmpdRegexpPattern" -}}
^loki-write-
{{- end -}}
8 changes: 4 additions & 4 deletions addons/loki/templates/clusterdefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ spec:
- name: loki-cluster
components:
- name: write
compDef: loki-write
compDef: {{ include "loki.writeCmpdRegexpPattern" . }}
- name: read
compDef: loki-read
compDef: {{ include "loki.readCmpdRegexpPattern" . }}
- name: backend
compDef: loki-backend
compDef: {{ include "loki.backendCmpdRegexpPattern" . }}
- name: gateway
compDef: loki-gateway
compDef: {{ include "loki.gatewayCmpdRegexpPattern" . }}
orders:
provision:
- backend
Expand Down
23 changes: 13 additions & 10 deletions addons/loki/templates/cmpd-backend.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
apiVersion: apps.kubeblocks.io/v1
kind: ComponentDefinition
metadata:
name: loki-backend
name: {{ include "loki.backendCmpdName" . }}
labels:
{{- include "loki.labels" . | nindent 4 }}
annotations:
{{- include "loki.annotations" . | nindent 4 }}
spec:
provider: kubeblocks
description: A Loki component definition for Kubernetes
Expand All @@ -23,6 +25,16 @@ spec:
protocol: TCP
name: grpc
targetPort: grpc
configs:
- name: loki-config
## TODO: this cmpd is currently unavailable. It requires adding configuration templates.
templateRef: loki
volumeName: config
namespace: {{ .Release.Namespace }}
- name: loki-runtime-config
templateRef: loki-runtime
volumeName: runtime-config
namespace: {{ .Release.Namespace }}
updateStrategy: BestEffortParallel
runtime:
automountServiceAccountToken: true
Expand Down Expand Up @@ -97,12 +109,3 @@ spec:
name: data
- mountPath: /rules
name: sc-rules-volume
configs:
- name: loki-config
templateRef: loki
volumeName: config
namespace: {{ .Release.Namespace }}
- name: loki-runtime-config
templateRef: loki-runtime
volumeName: runtime-config
namespace: {{ .Release.Namespace }}
15 changes: 9 additions & 6 deletions addons/loki/templates/cmpd-gateway.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
apiVersion: apps.kubeblocks.io/v1
kind: ComponentDefinition
metadata:
name: loki-gateway
name: {{ include "loki.gatewayCmpdName" . }}
labels:
{{- include "loki.labels" . | nindent 4 }}
annotations:
{{- include "loki.annotations" . | nindent 4 }}
spec:
provider: kubeblocks
description: A Loki component definition for Kubernetes
Expand All @@ -17,6 +19,12 @@ spec:
protocol: TCP
name: http-metrics
targetPort: http-metrics
configs:
- name: config-gateway
## TODO: this cmpd is currently unavailable. It requires adding configuration templates.
templateRef: loki-gateway
volumeName: config
namespace: {{ .Release.Namespace }}
updateStrategy: BestEffortParallel
runtime:
automountServiceAccountToken: true
Expand Down Expand Up @@ -56,8 +64,3 @@ spec:
name: tmp
- mountPath: /docker-entrypoint.d
name: docker-entrypoint-d-override
configs:
- name: config-gateway
templateRef: loki-gateway
volumeName: config
namespace: {{ .Release.Namespace }}
23 changes: 13 additions & 10 deletions addons/loki/templates/cmpd-read.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
apiVersion: apps.kubeblocks.io/v1
kind: ComponentDefinition
metadata:
name: loki-read
name: {{ include "loki.readCmpdName" . }}
labels:
{{- include "loki.labels" . | nindent 4 }}
annotations:
{{- include "loki.annotations" . | nindent 4 }}
spec:
provider: kubeblocks
description: A Loki component definition for Kubernetes
Expand All @@ -23,6 +25,16 @@ spec:
protocol: TCP
name: grpc
targetPort: grpc
configs:
- name: loki-config
## TODO: this cmpd is currently unavailable. It requires adding configuration templates.
templateRef: loki
volumeName: config
namespace: {{ .Release.Namespace }}
- name: loki-runtime-config
templateRef: loki-runtime
volumeName: runtime-config
namespace: {{ .Release.Namespace }}
updateStrategy: BestEffortParallel
runtime:
automountServiceAccountToken: true
Expand Down Expand Up @@ -76,12 +88,3 @@ spec:
name: tmp
- mountPath: /var/loki
name: data
configs:
- name: loki-config
templateRef: loki
volumeName: config
namespace: {{ .Release.Namespace }}
- name: loki-runtime-config
templateRef: loki-runtime
volumeName: runtime-config
namespace: {{ .Release.Namespace }}
23 changes: 13 additions & 10 deletions addons/loki/templates/cmpd-write.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
apiVersion: apps.kubeblocks.io/v1
kind: ComponentDefinition
metadata:
name: loki-write
name: {{ include "loki.writeCmpdName" . }}
labels:
{{- include "loki.labels" . | nindent 4 }}
annotations:
{{- include "loki.annotations" . | nindent 4 }}
spec:
provider: kubeblocks
description: A Loki component definition for Kubernetes
Expand All @@ -23,6 +25,16 @@ spec:
protocol: TCP
name: grpc
targetPort: grpc
configs:
- name: loki-config
## TODO: this cmpd is currently unavailable. It requires adding configuration templates.
templateRef: loki
volumeName: config
namespace: {{ .Release.Namespace }}
- name: loki-runtime-config
templateRef: loki-runtime
volumeName: runtime-config
namespace: {{ .Release.Namespace }}
updateStrategy: BestEffortParallel
runtime:
automountServiceAccountToken: true
Expand Down Expand Up @@ -73,12 +85,3 @@ spec:
name: tmp
- mountPath: /var/loki
name: data
configs:
- name: loki-config
templateRef: loki
volumeName: config
namespace: {{ .Release.Namespace }}
- name: loki-runtime-config
templateRef: loki-runtime
volumeName: runtime-config
namespace: {{ .Release.Namespace }}
8 changes: 4 additions & 4 deletions addons/loki/templates/cmpv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ spec:
- releases:
- write-1.0.0
compDefs:
- loki-write
- {{ include "loki.writeCmpdRegexpPattern" . }}
- releases:
- read-1.0.0
compDefs:
- loki-read
- {{ include "loki.readCmpdRegexpPattern" . }}
- releases:
- backend-1.0.0
compDefs:
- loki-backend
- {{ include "loki.backendCmpdRegexpPattern" . }}
- releases:
- gateway-1.0.0
compDefs:
- loki-gateway
- {{ include "loki.gatewayCmpdRegexpPattern" . }}
releases:
- name: write-1.0.0
serviceVersion: 1.0.0
Expand Down
6 changes: 0 additions & 6 deletions addons/loki/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ nameOverride: ""
fullnameOverride: ""
clusterVersionOverride: ""

## @param resourceNamePrefix Prefix for all resources name created by this chart, that can avoid name conflict
## if you install multiple releases of this chart.
## If specified, the cluster definition will use it as name.
resourceNamePrefix: ""


global:
# -- configures cluster domain ("cluster.local" by default)
clusterDomain: "cluster.local"
Expand Down

0 comments on commit 4b5acde

Please sign in to comment.