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

zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-helm-chart.git


The following commit(s) were added to refs/heads/master by this push:
     new b561ef9  feat: allow override of default apisix resource labels (#456)
b561ef9 is described below

commit b561ef90cac8eb944bf415407fb8cdc894bac20f
Author: ikatlinsky <[email protected]>
AuthorDate: Tue Feb 7 03:34:29 2023 +0100

    feat: allow override of default apisix resource labels (#456)
---
 charts/apisix-dashboard/README.md                       | 1 +
 charts/apisix-dashboard/templates/_helpers.tpl          | 4 ++++
 charts/apisix-dashboard/values.yaml                     | 5 +++++
 charts/apisix-ingress-controller/README.md              | 1 +
 charts/apisix-ingress-controller/templates/_helpers.tpl | 5 ++++-
 charts/apisix-ingress-controller/values.yaml            | 6 ++++++
 charts/apisix/README.md                                 | 1 +
 charts/apisix/templates/_helpers.tpl                    | 4 ++++
 charts/apisix/values.yaml                               | 6 +++++-
 9 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/charts/apisix-dashboard/README.md 
b/charts/apisix-dashboard/README.md
index f5dab0c..4c93a13 100644
--- a/charts/apisix-dashboard/README.md
+++ b/charts/apisix-dashboard/README.md
@@ -80,6 +80,7 @@ _See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) 
for command documen
 | ingress.enabled | bool | `false` | Set to true to enable ingress record 
generation |
 | ingress.hosts | list | `[{"host":"apisix-dashboard.local","paths":[]}]` | 
The list of hostnams to be covered with this ingress record |
 | ingress.tls | list | `[]` | Create TLS Secret |
+| labelsOverride | object | `{}` | Override default labels assigned to Apache 
APISIX dashboard resource |
 | nameOverride | string | `""` | String to partially override 
apisix-dashboard.fullname template (will maintain the release name) |
 | nodeSelector | object | `{}` | Node labels for pod assignment |
 | podAnnotations | object | `{}` | Apache APISIX Dashboard Pod annotations |
diff --git a/charts/apisix-dashboard/templates/_helpers.tpl 
b/charts/apisix-dashboard/templates/_helpers.tpl
index 1bdd9c3..fc720b0 100644
--- a/charts/apisix-dashboard/templates/_helpers.tpl
+++ b/charts/apisix-dashboard/templates/_helpers.tpl
@@ -62,9 +62,13 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
 Selector labels
 */}}
 {{- define "apisix-dashboard.selectorLabels" -}}
+{{- if .Values.labelsOverride }}
+{{- tpl (.Values.labelsOverride | toYaml) . }}
+{{- else }}
 app.kubernetes.io/name: {{ include "apisix-dashboard.name" . }}
 app.kubernetes.io/instance: {{ .Release.Name }}
 {{- end }}
+{{- end }}
 
 {{/*
 Create the name of the service account to use
diff --git a/charts/apisix-dashboard/values.yaml 
b/charts/apisix-dashboard/values.yaml
index b4867a2..1d8e466 100644
--- a/charts/apisix-dashboard/values.yaml
+++ b/charts/apisix-dashboard/values.yaml
@@ -36,6 +36,11 @@ imagePullSecrets: []
 nameOverride: ""
 # -- String to fully override apisix-dashboard.fullname template
 fullnameOverride: ""
+# -- Override default labels assigned to Apache APISIX dashboard resource
+labelsOverride: {}
+# labelsOverride:
+#   app.kubernetes.io/name: "{{ .Release.Name }}"
+#   app.kubernetes.io/instance: '{{ include "apisix-dashboard.name" . }}'
 
 serviceAccount:
   # -- Specifies whether a service account should be created
diff --git a/charts/apisix-ingress-controller/README.md 
b/charts/apisix-ingress-controller/README.md
index 4c872de..9bb8ea1 100644
--- a/charts/apisix-ingress-controller/README.md
+++ b/charts/apisix-ingress-controller/README.md
@@ -142,6 +142,7 @@ The same for container level, you need to set:
 | imagePullSecrets | list | `[]` |  |
 | initContainer.image | string | `"busybox"` |  |
 | initContainer.tag | float | `1.28` |  |
+| labelsOverride | object | `{}` | Override default labels assigned to Apache 
APISIX ingress controller resource |
 | nameOverride | string | `""` | Default values for apisix-ingress-controller. 
This is a YAML-formatted file. Declare variables to be passed into your 
templates.  |
 | nodeSelector | object | `{}` |  |
 | podAnnotations | object | `{}` |  |
diff --git a/charts/apisix-ingress-controller/templates/_helpers.tpl 
b/charts/apisix-ingress-controller/templates/_helpers.tpl
index 4a4ca01..4426f90 100644
--- a/charts/apisix-ingress-controller/templates/_helpers.tpl
+++ b/charts/apisix-ingress-controller/templates/_helpers.tpl
@@ -63,9 +63,12 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
 Selector labels
 */}}
 {{- define "apisix-ingress-controller.selectorLabels" -}}
+{{- if .Values.labelsOverride }}
+{{- tpl (.Values.labelsOverride | toYaml) . }}
+{{- else }}
 app.kubernetes.io/name: {{ include "apisix-ingress-controller.name" . }}
 app.kubernetes.io/instance: {{ .Release.Name }}
-
+{{- end }}
 {{- end }}
 
 {{/*
diff --git a/charts/apisix-ingress-controller/values.yaml 
b/charts/apisix-ingress-controller/values.yaml
index e10c94a..58eef8b 100644
--- a/charts/apisix-ingress-controller/values.yaml
+++ b/charts/apisix-ingress-controller/values.yaml
@@ -23,6 +23,12 @@ nameOverride: ""
 
 fullnameOverride: ""
 
+# -- Override default labels assigned to Apache APISIX ingress controller 
resource
+labelsOverride: {}
+# labelsOverride:
+#   app.kubernetes.io/name: "{{ .Release.Name }}"
+#   app.kubernetes.io/instance: '{{ include "apisix-ingress-controller.name" . 
}}'
+
 rbac:
   # -- Specifies whether RBAC resources should be created
   create: true
diff --git a/charts/apisix/README.md b/charts/apisix/README.md
index 1cf8b11..1249619 100644
--- a/charts/apisix/README.md
+++ b/charts/apisix/README.md
@@ -137,6 +137,7 @@ The command removes all the Kubernetes components 
associated with the chart and
 | gateway.http | object | 
`{"containerPort":9080,"enabled":true,"servicePort":80}` | Apache APISIX 
service settings for http |
 | gateway.ingress | object | 
`{"annotations":{},"enabled":false,"hosts":[{"host":"apisix.local","paths":[]}],"tls":[]}`
 | Using ingress access Apache APISIX service |
 | gateway.ingress.annotations | object | `{}` | Ingress annotations |
+| gateway.labelsOverride | object | `{}` | Override default labels assigned to 
Apache APISIX gateway resources |
 | gateway.stream | object | `{"enabled":false,"only":false,"tcp":[],"udp":[]}` 
| Apache APISIX service settings for stream. L4 proxy (TCP/UDP) |
 | gateway.tls | object | 
`{"certCAFilename":"","containerPort":9443,"enabled":false,"existingCASecret":"","http2":{"enabled":true},"servicePort":443,"sslProtocols":"TLSv1.2
 TLSv1.3"}` | Apache APISIX service settings for tls |
 | gateway.tls.certCAFilename | string | `""` | Filename be used in the 
gateway.tls.existingCASecret |
diff --git a/charts/apisix/templates/_helpers.tpl 
b/charts/apisix/templates/_helpers.tpl
index c3c2fb0..2198734 100644
--- a/charts/apisix/templates/_helpers.tpl
+++ b/charts/apisix/templates/_helpers.tpl
@@ -47,9 +47,13 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
 Selector labels
 */}}
 {{- define "apisix.selectorLabels" -}}
+{{- if .Values.gateway.labelsOverride }}
+{{- tpl (.Values.gateway.labelsOverride | toYaml) . }}
+{{- else }}
 app.kubernetes.io/name: {{ include "apisix.name" . }}
 app.kubernetes.io/instance: {{ .Release.Name }}
 {{- end }}
+{{- end }}
 
 {{/*
 Create the name of the service account to use
diff --git a/charts/apisix/values.yaml b/charts/apisix/values.yaml
index 1cf439c..51cb72c 100644
--- a/charts/apisix/values.yaml
+++ b/charts/apisix/values.yaml
@@ -218,7 +218,11 @@ gateway:
   #  - secretName: apisix-tls
   #    hosts:
   #      - chart-example.local
-
+  # -- Override default labels assigned to Apache APISIX gateway resources
+  labelsOverride: {}
+  # labelsOverride:
+  #   app.kubernetes.io/name: "{{ .Release.Name }}"
+  #   app.kubernetes.io/instance: '{{ include "apisix.name" . }}'
 admin:
   # -- Enable Admin API
   enabled: true

Reply via email to