From 467a5afefe4051e9c033b2819edb838ce6900086 Mon Sep 17 00:00:00 2001 From: Y-Rookie Date: Mon, 21 Oct 2024 12:06:49 +0800 Subject: [PATCH 1/3] remove unuse code --- addons/loki/templates/_helpers.tpl | 23 ----------------------- addons/loki/templates/cmpd-backend.yaml | 19 ++++++++++--------- addons/loki/templates/cmpd-gateway.yaml | 11 ++++++----- addons/loki/templates/cmpd-read.yaml | 19 ++++++++++--------- addons/loki/templates/cmpd-write.yaml | 19 ++++++++++--------- 5 files changed, 36 insertions(+), 55 deletions(-) diff --git a/addons/loki/templates/_helpers.tpl b/addons/loki/templates/_helpers.tpl index c113b4066..1f38f5677 100644 --- a/addons/loki/templates/_helpers.tpl +++ b/addons/loki/templates/_helpers.tpl @@ -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. */}} @@ -63,17 +51,6 @@ app.kubernetes.io/name: {{ include "loki.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} -{{/* -Create the name of the service account to use -*/}} -{{- define "loki.serviceAccountName" -}} -{{- if .Values.serviceAccount.create -}} - {{ default (include "loki.name" .) .Values.serviceAccount.name }} -{{- else -}} - {{ default "default" .Values.serviceAccount.name }} -{{- end -}} -{{- end -}} - {{/* Base template for building docker image reference */}} diff --git a/addons/loki/templates/cmpd-backend.yaml b/addons/loki/templates/cmpd-backend.yaml index 2523ed740..e3c8d4808 100644 --- a/addons/loki/templates/cmpd-backend.yaml +++ b/addons/loki/templates/cmpd-backend.yaml @@ -23,6 +23,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 @@ -97,12 +107,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 }} diff --git a/addons/loki/templates/cmpd-gateway.yaml b/addons/loki/templates/cmpd-gateway.yaml index 30744d8c3..79f380688 100644 --- a/addons/loki/templates/cmpd-gateway.yaml +++ b/addons/loki/templates/cmpd-gateway.yaml @@ -17,6 +17,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 @@ -56,8 +62,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 }} diff --git a/addons/loki/templates/cmpd-read.yaml b/addons/loki/templates/cmpd-read.yaml index 79ff4fcca..f1e0753a8 100644 --- a/addons/loki/templates/cmpd-read.yaml +++ b/addons/loki/templates/cmpd-read.yaml @@ -23,6 +23,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 @@ -76,12 +86,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 }} diff --git a/addons/loki/templates/cmpd-write.yaml b/addons/loki/templates/cmpd-write.yaml index 109394afb..6be6aca33 100644 --- a/addons/loki/templates/cmpd-write.yaml +++ b/addons/loki/templates/cmpd-write.yaml @@ -23,6 +23,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 @@ -73,12 +83,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 }} From 1f7d2b79e730f9dc4fe96b5ad40e5781fdad9233 Mon Sep 17 00:00:00 2001 From: Y-Rookie Date: Mon, 21 Oct 2024 12:12:10 +0800 Subject: [PATCH 2/3] remove unuse code --- addons/loki/templates/_helpers.tpl | 7 +++++++ addons/loki/templates/cmpd-backend.yaml | 2 ++ addons/loki/templates/cmpd-gateway.yaml | 2 ++ addons/loki/templates/cmpd-read.yaml | 2 ++ addons/loki/templates/cmpd-write.yaml | 2 ++ 5 files changed, 15 insertions(+) diff --git a/addons/loki/templates/_helpers.tpl b/addons/loki/templates/_helpers.tpl index 1f38f5677..79c498571 100644 --- a/addons/loki/templates/_helpers.tpl +++ b/addons/loki/templates/_helpers.tpl @@ -51,6 +51,13 @@ app.kubernetes.io/name: {{ include "loki.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} +{{/* +Common annotations +*/}} +{{- define "loki.annotations" -}} +helm.sh/resource-policy: keep +{{- end }} + {{/* Base template for building docker image reference */}} diff --git a/addons/loki/templates/cmpd-backend.yaml b/addons/loki/templates/cmpd-backend.yaml index e3c8d4808..24cb85b75 100644 --- a/addons/loki/templates/cmpd-backend.yaml +++ b/addons/loki/templates/cmpd-backend.yaml @@ -4,6 +4,8 @@ metadata: name: loki-backend labels: {{- include "loki.labels" . | nindent 4 }} + annotations: + {{- include "loki.annotations" . | nindent 4 }} spec: provider: kubeblocks description: A Loki component definition for Kubernetes diff --git a/addons/loki/templates/cmpd-gateway.yaml b/addons/loki/templates/cmpd-gateway.yaml index 79f380688..ecd78126b 100644 --- a/addons/loki/templates/cmpd-gateway.yaml +++ b/addons/loki/templates/cmpd-gateway.yaml @@ -4,6 +4,8 @@ metadata: name: loki-gateway labels: {{- include "loki.labels" . | nindent 4 }} + annotations: + {{- include "loki.annotations" . | nindent 4 }} spec: provider: kubeblocks description: A Loki component definition for Kubernetes diff --git a/addons/loki/templates/cmpd-read.yaml b/addons/loki/templates/cmpd-read.yaml index f1e0753a8..b2713f497 100644 --- a/addons/loki/templates/cmpd-read.yaml +++ b/addons/loki/templates/cmpd-read.yaml @@ -4,6 +4,8 @@ metadata: name: loki-read labels: {{- include "loki.labels" . | nindent 4 }} + annotations: + {{- include "loki.annotations" . | nindent 4 }} spec: provider: kubeblocks description: A Loki component definition for Kubernetes diff --git a/addons/loki/templates/cmpd-write.yaml b/addons/loki/templates/cmpd-write.yaml index 6be6aca33..6538bec88 100644 --- a/addons/loki/templates/cmpd-write.yaml +++ b/addons/loki/templates/cmpd-write.yaml @@ -4,6 +4,8 @@ metadata: name: loki-write labels: {{- include "loki.labels" . | nindent 4 }} + annotations: + {{- include "loki.annotations" . | nindent 4 }} spec: provider: kubeblocks description: A Loki component definition for Kubernetes From 0e55e1438e950809f995b927aa80f6a9bc8983f3 Mon Sep 17 00:00:00 2001 From: Y-Rookie Date: Mon, 21 Oct 2024 14:14:34 +0800 Subject: [PATCH 3/3] add cmpd regex match --- addons/loki/Chart.yaml | 2 +- addons/loki/templates/_helpers.tpl | 59 +++++++++++++++++++- addons/loki/templates/clusterdefinition.yaml | 8 +-- addons/loki/templates/cmpd-backend.yaml | 2 +- addons/loki/templates/cmpd-gateway.yaml | 2 +- addons/loki/templates/cmpd-read.yaml | 2 +- addons/loki/templates/cmpd-write.yaml | 2 +- addons/loki/templates/cmpv.yaml | 8 +-- addons/loki/values.yaml | 6 -- 9 files changed, 71 insertions(+), 20 deletions(-) diff --git a/addons/loki/Chart.yaml b/addons/loki/Chart.yaml index 96d99302d..8474ee3da 100644 --- a/addons/loki/Chart.yaml +++ b/addons/loki/Chart.yaml @@ -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" diff --git a/addons/loki/templates/_helpers.tpl b/addons/loki/templates/_helpers.tpl index 79c498571..729bdc8ed 100644 --- a/addons/loki/templates/_helpers.tpl +++ b/addons/loki/templates/_helpers.tpl @@ -505,4 +505,61 @@ query-scheduler fullname */}} {{- define "loki.querySchedulerFullname" -}} {{ include "loki.fullname" . }}-query-scheduler -{{- end }} \ No newline at end of file +{{- 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 -}} diff --git a/addons/loki/templates/clusterdefinition.yaml b/addons/loki/templates/clusterdefinition.yaml index 0c59f879b..53c64e223 100644 --- a/addons/loki/templates/clusterdefinition.yaml +++ b/addons/loki/templates/clusterdefinition.yaml @@ -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 diff --git a/addons/loki/templates/cmpd-backend.yaml b/addons/loki/templates/cmpd-backend.yaml index 24cb85b75..db379b2bc 100644 --- a/addons/loki/templates/cmpd-backend.yaml +++ b/addons/loki/templates/cmpd-backend.yaml @@ -1,7 +1,7 @@ apiVersion: apps.kubeblocks.io/v1 kind: ComponentDefinition metadata: - name: loki-backend + name: {{ include "loki.backendCmpdName" . }} labels: {{- include "loki.labels" . | nindent 4 }} annotations: diff --git a/addons/loki/templates/cmpd-gateway.yaml b/addons/loki/templates/cmpd-gateway.yaml index ecd78126b..b341fe0f6 100644 --- a/addons/loki/templates/cmpd-gateway.yaml +++ b/addons/loki/templates/cmpd-gateway.yaml @@ -1,7 +1,7 @@ apiVersion: apps.kubeblocks.io/v1 kind: ComponentDefinition metadata: - name: loki-gateway + name: {{ include "loki.gatewayCmpdName" . }} labels: {{- include "loki.labels" . | nindent 4 }} annotations: diff --git a/addons/loki/templates/cmpd-read.yaml b/addons/loki/templates/cmpd-read.yaml index b2713f497..3c75d1ad5 100644 --- a/addons/loki/templates/cmpd-read.yaml +++ b/addons/loki/templates/cmpd-read.yaml @@ -1,7 +1,7 @@ apiVersion: apps.kubeblocks.io/v1 kind: ComponentDefinition metadata: - name: loki-read + name: {{ include "loki.readCmpdName" . }} labels: {{- include "loki.labels" . | nindent 4 }} annotations: diff --git a/addons/loki/templates/cmpd-write.yaml b/addons/loki/templates/cmpd-write.yaml index 6538bec88..18f0e3e79 100644 --- a/addons/loki/templates/cmpd-write.yaml +++ b/addons/loki/templates/cmpd-write.yaml @@ -1,7 +1,7 @@ apiVersion: apps.kubeblocks.io/v1 kind: ComponentDefinition metadata: - name: loki-write + name: {{ include "loki.writeCmpdName" . }} labels: {{- include "loki.labels" . | nindent 4 }} annotations: diff --git a/addons/loki/templates/cmpv.yaml b/addons/loki/templates/cmpv.yaml index 9290a3034..ef75440c9 100644 --- a/addons/loki/templates/cmpv.yaml +++ b/addons/loki/templates/cmpv.yaml @@ -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 diff --git a/addons/loki/values.yaml b/addons/loki/values.yaml index 7b7f2c6d5..1242e5cf7 100644 --- a/addons/loki/values.yaml +++ b/addons/loki/values.yaml @@ -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"