This is an automated email from the ASF dual-hosted git repository.

chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new a9a476677 [KYUUBI #4698] [K8S][HELM] Centralize Kyuubi labels 
definition
a9a476677 is described below

commit a9a4766778d6894561efb32cdb1c3e73d6714b87
Author: pengqli <[email protected]>
AuthorDate: Mon Apr 17 23:03:49 2023 +0800

    [KYUUBI #4698] [K8S][HELM] Centralize Kyuubi labels definition
    
    ### _Why are the changes needed?_
    
    It's a default implementation created by helm create chart_name. Label info 
is relatively fixed and is frequently used in templates, reducing code 
redundancy. Define common tags that make yaml cleaner and easy to read.
    
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including 
negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [x] [Run 
test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests)
 locally before make a pull request
    
    Closes #4698 from dev-lpq/helm_define_lables.
    
    Closes #4698
    
    7f60391c5 [pengqli] change the labels comment
    5b246dd94 [pengqli] Merge branch 'master' into helm_define_lables
    f480772f0 [pengqli] change the kyuubi labels name
    e98d1d9a5 [pengqli] define Kyuubi labels template
    
    Authored-by: pengqli <[email protected]>
    Signed-off-by: Cheng Pan <[email protected]>
---
 charts/kyuubi/templates/_helpers.tpl               | 18 ++++++++++++++++++
 charts/kyuubi/templates/kyuubi-configmap.yaml      |  6 +-----
 charts/kyuubi/templates/kyuubi-deployment.yaml     | 12 +++---------
 charts/kyuubi/templates/kyuubi-role.yaml           |  6 +-----
 charts/kyuubi/templates/kyuubi-rolebinding.yaml    |  6 +-----
 charts/kyuubi/templates/kyuubi-service.yaml        |  9 ++-------
 charts/kyuubi/templates/kyuubi-serviceaccount.yaml |  6 +-----
 7 files changed, 27 insertions(+), 36 deletions(-)

diff --git a/charts/kyuubi/templates/_helpers.tpl 
b/charts/kyuubi/templates/_helpers.tpl
index 07e66d5f1..4c9da32b9 100644
--- a/charts/kyuubi/templates/_helpers.tpl
+++ b/charts/kyuubi/templates/_helpers.tpl
@@ -31,3 +31,21 @@ For details, see 'kyuubi.frontend.protocols': 
https://kyuubi.readthedocs.io/en/m
   {{- end }}
   {{- $protocols |  join "," }}
 {{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "kyuubi.selectorLabels" -}}
+app.kubernetes.io/name: {{ .Chart.Name }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end -}}
+
+{{/*
+Common labels
+*/}}
+{{- define "kyuubi.labels" -}}
+helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
+{{ include "kyuubi.selectorLabels" . }}
+app.kubernetes.io/version: {{ .Values.image.tag | default .Chart.AppVersion | 
quote }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end -}}
diff --git a/charts/kyuubi/templates/kyuubi-configmap.yaml 
b/charts/kyuubi/templates/kyuubi-configmap.yaml
index 22d6562b8..3e7281083 100644
--- a/charts/kyuubi/templates/kyuubi-configmap.yaml
+++ b/charts/kyuubi/templates/kyuubi-configmap.yaml
@@ -20,11 +20,7 @@ kind: ConfigMap
 metadata:
   name: {{ .Release.Name }}
   labels:
-    helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
-    app.kubernetes.io/name: {{ .Chart.Name }}
-    app.kubernetes.io/instance: {{ .Release.Name }}
-    app.kubernetes.io/version: {{ .Values.image.tag | default 
.Chart.AppVersion | quote }}
-    app.kubernetes.io/managed-by: {{ .Release.Service }}
+    {{- include "kyuubi.labels" . | nindent 4 }}
 data:
   {{- with .Values.kyuubiConf.kyuubiEnv }}
   kyuubi-env.sh: |
diff --git a/charts/kyuubi/templates/kyuubi-deployment.yaml 
b/charts/kyuubi/templates/kyuubi-deployment.yaml
index b30913dd0..beca0998a 100644
--- a/charts/kyuubi/templates/kyuubi-deployment.yaml
+++ b/charts/kyuubi/templates/kyuubi-deployment.yaml
@@ -20,22 +20,16 @@ kind: Deployment
 metadata:
   name: {{ .Release.Name }}
   labels:
-    helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
-    app.kubernetes.io/name: {{ .Chart.Name }}
-    app.kubernetes.io/instance: {{ .Release.Name }}
-    app.kubernetes.io/version: {{ .Values.image.tag | default 
.Chart.AppVersion | quote }}
-    app.kubernetes.io/managed-by: {{ .Release.Service }}
+    {{- include "kyuubi.labels" . | nindent 4 }}
 spec:
   replicas: {{ .Values.replicaCount }}
   selector:
     matchLabels:
-      app.kubernetes.io/name: {{ .Chart.Name }}
-      app.kubernetes.io/instance: {{ .Release.Name }}
+      {{- include "kyuubi.selectorLabels" . | nindent 6 }}
   template:
     metadata:
       labels:
-        app.kubernetes.io/name: {{ .Chart.Name }}
-        app.kubernetes.io/instance: {{ .Release.Name }}
+        {{- include "kyuubi.selectorLabels" . | nindent 8 }}
       annotations:
         checksum/conf: {{ include (print $.Template.BasePath 
"/kyuubi-configmap.yaml") . | sha256sum }}
     spec:
diff --git a/charts/kyuubi/templates/kyuubi-role.yaml 
b/charts/kyuubi/templates/kyuubi-role.yaml
index 7e0a810a1..5ee8c1dff 100644
--- a/charts/kyuubi/templates/kyuubi-role.yaml
+++ b/charts/kyuubi/templates/kyuubi-role.yaml
@@ -21,10 +21,6 @@ kind: Role
 metadata:
   name: {{ .Release.Name }}
   labels:
-    helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
-    app.kubernetes.io/name: {{ .Chart.Name }}
-    app.kubernetes.io/instance: {{ .Release.Name }}
-    app.kubernetes.io/version: {{ .Values.image.tag | default 
.Chart.AppVersion | quote }}
-    app.kubernetes.io/managed-by: {{ .Release.Service }}
+    {{- include "kyuubi.labels" . | nindent 4 }}
 rules: {{- toYaml .Values.rbac.rules | nindent 2 }}
 {{- end }}
diff --git a/charts/kyuubi/templates/kyuubi-rolebinding.yaml 
b/charts/kyuubi/templates/kyuubi-rolebinding.yaml
index e7dd0d64b..0f9dbd049 100644
--- a/charts/kyuubi/templates/kyuubi-rolebinding.yaml
+++ b/charts/kyuubi/templates/kyuubi-rolebinding.yaml
@@ -21,11 +21,7 @@ kind: RoleBinding
 metadata:
   name: {{ .Release.Name }}
   labels:
-    helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
-    app.kubernetes.io/name: {{ .Chart.Name }}
-    app.kubernetes.io/instance: {{ .Release.Name }}
-    app.kubernetes.io/version: {{ .Values.image.tag | default 
.Chart.AppVersion | quote }}
-    app.kubernetes.io/managed-by: {{ .Release.Service }}
+    {{- include "kyuubi.labels" . | nindent 4 }}
 subjects:
   - kind: ServiceAccount
     name: {{ .Values.serviceAccount.name | default .Release.Name }}
diff --git a/charts/kyuubi/templates/kyuubi-service.yaml 
b/charts/kyuubi/templates/kyuubi-service.yaml
index ddc2e230f..64c8b06ac 100644
--- a/charts/kyuubi/templates/kyuubi-service.yaml
+++ b/charts/kyuubi/templates/kyuubi-service.yaml
@@ -22,11 +22,7 @@ kind: Service
 metadata:
   name: {{ $.Release.Name }}-{{ $name | kebabcase }}
   labels:
-    helm.sh/chart: {{ $.Chart.Name }}-{{ $.Chart.Version }}
-    app.kubernetes.io/name: {{ $.Chart.Name }}
-    app.kubernetes.io/instance: {{ $.Release.Name }}
-    app.kubernetes.io/version: {{ $.Values.image.tag | default 
$.Chart.AppVersion | quote }}
-    app.kubernetes.io/managed-by: {{ $.Release.Service }}
+    {{- include "kyuubi.labels" $ | nindent 4 }}
   {{- with $frontend.service.annotations }}
   annotations: {{- toYaml . | nindent 4 }}
   {{- end }}
@@ -40,8 +36,7 @@ spec:
       nodePort: {{ $frontend.service.nodePort }}
       {{- end }}
   selector:
-    app.kubernetes.io/name: {{ $.Chart.Name }}
-    app.kubernetes.io/instance: {{ $.Release.Name }}
+    {{- include "kyuubi.selectorLabels" $ | nindent 4 }}
 ---
 {{- end }}
 {{- end }}
diff --git a/charts/kyuubi/templates/kyuubi-serviceaccount.yaml 
b/charts/kyuubi/templates/kyuubi-serviceaccount.yaml
index bbfa22e35..a8e282a1f 100644
--- a/charts/kyuubi/templates/kyuubi-serviceaccount.yaml
+++ b/charts/kyuubi/templates/kyuubi-serviceaccount.yaml
@@ -21,9 +21,5 @@ kind: ServiceAccount
 metadata:
   name: {{ .Values.serviceAccount.name | default .Release.Name }}
   labels:
-    helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
-    app.kubernetes.io/name: {{ .Chart.Name }}
-    app.kubernetes.io/instance: {{ .Release.Name }}
-    app.kubernetes.io/version: {{ .Values.image.tag | default 
.Chart.AppVersion | quote }}
-    app.kubernetes.io/managed-by: {{ .Release.Service }}
+    {{- include "kyuubi.labels" . | nindent 4 }}
 {{- end }}

Reply via email to