Allowing Custom Labels in SVC Templates (#597)
### Description of the change The change allows users of this chart to specify custom labels for the HTTP & SSH Services that get deployed. They are optional and if given are added to the standard list of labels. ### Benefits Certain use cases require labelling services to be able to select them in other places. Specifiying them directly in the helm chart avoids having to label by hand everytime. Concrete Use Case Example: Cilium Layer 2 Announcements require selecting services to announce via labels (see [docs](https://docs.cilium.io/en/stable/network/l2-announcements/#service-selector)). I would like to add a label to the SSH service, but not the HTTP Service (which is handled via an ingress). ### Possible drawbacks I don't see any, using this feature is optional :) ### Checklist - [X] Parameters are documented in the `values.yaml` and added to the `README.md` using [readme-generator-for-helm](https://github.com/bitnami-labs/readme-generator-for-helm) - [X] Breaking changes are documented in the `README.md` - [X] Templating unittests are added Co-authored-by: Remo Geissbühler <git@remogeissbuehler.ch> Co-authored-by: justusbunsi <justusbunsi@noreply.gitea.com> Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/597 Reviewed-by: pat-s <pat-s@noreply.gitea.com> Reviewed-by: justusbunsi <justusbunsi@noreply.gitea.com> Co-authored-by: remogeissbuehler <remogeissbuehler@noreply.gitea.com> Co-committed-by: remogeissbuehler <remogeissbuehler@noreply.gitea.com>
This commit is contained in:
parent
70e5da077a
commit
5dfaca13f2
@ -888,6 +888,7 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo
|
|||||||
| `service.http.ipFamilies` | HTTP service dual-stack familiy selection,for dual-stack parameters see official kubernetes [dual-stack concept documentation](https://kubernetes.io/docs/concepts/services-networking/dual-stack/). | `nil` |
|
| `service.http.ipFamilies` | HTTP service dual-stack familiy selection,for dual-stack parameters see official kubernetes [dual-stack concept documentation](https://kubernetes.io/docs/concepts/services-networking/dual-stack/). | `nil` |
|
||||||
| `service.http.loadBalancerSourceRanges` | Source range filter for http loadbalancer | `[]` |
|
| `service.http.loadBalancerSourceRanges` | Source range filter for http loadbalancer | `[]` |
|
||||||
| `service.http.annotations` | HTTP service annotations | `{}` |
|
| `service.http.annotations` | HTTP service annotations | `{}` |
|
||||||
|
| `service.http.labels` | HTTP service additional labels | `{}` |
|
||||||
| `service.ssh.type` | Kubernetes service type for ssh traffic | `ClusterIP` |
|
| `service.ssh.type` | Kubernetes service type for ssh traffic | `ClusterIP` |
|
||||||
| `service.ssh.port` | Port number for ssh traffic | `22` |
|
| `service.ssh.port` | Port number for ssh traffic | `22` |
|
||||||
| `service.ssh.clusterIP` | ClusterIP setting for ssh autosetup for deployment is None | `None` |
|
| `service.ssh.clusterIP` | ClusterIP setting for ssh autosetup for deployment is None | `None` |
|
||||||
@ -900,6 +901,7 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo
|
|||||||
| `service.ssh.hostPort` | HostPort for ssh service | `nil` |
|
| `service.ssh.hostPort` | HostPort for ssh service | `nil` |
|
||||||
| `service.ssh.loadBalancerSourceRanges` | Source range filter for ssh loadbalancer | `[]` |
|
| `service.ssh.loadBalancerSourceRanges` | Source range filter for ssh loadbalancer | `[]` |
|
||||||
| `service.ssh.annotations` | SSH service annotations | `{}` |
|
| `service.ssh.annotations` | SSH service annotations | `{}` |
|
||||||
|
| `service.ssh.labels` | SSH service additional labels | `{}` |
|
||||||
|
|
||||||
### Ingress
|
### Ingress
|
||||||
|
|
||||||
|
@ -4,6 +4,9 @@ metadata:
|
|||||||
name: {{ include "gitea.fullname" . }}-http
|
name: {{ include "gitea.fullname" . }}-http
|
||||||
labels:
|
labels:
|
||||||
{{- include "gitea.labels" . | nindent 4 }}
|
{{- include "gitea.labels" . | nindent 4 }}
|
||||||
|
{{- if .Values.service.http.labels }}
|
||||||
|
{{- toYaml .Values.service.http.labels | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
annotations:
|
annotations:
|
||||||
{{- toYaml .Values.service.http.annotations | nindent 4 }}
|
{{- toYaml .Values.service.http.annotations | nindent 4 }}
|
||||||
spec:
|
spec:
|
||||||
|
@ -4,6 +4,9 @@ metadata:
|
|||||||
name: {{ include "gitea.fullname" . }}-ssh
|
name: {{ include "gitea.fullname" . }}-ssh
|
||||||
labels:
|
labels:
|
||||||
{{- include "gitea.labels" . | nindent 4 }}
|
{{- include "gitea.labels" . | nindent 4 }}
|
||||||
|
{{- if .Values.service.ssh.labels }}
|
||||||
|
{{- toYaml .Values.service.ssh.labels | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
annotations:
|
annotations:
|
||||||
{{- toYaml .Values.service.ssh.annotations | nindent 4 }}
|
{{- toYaml .Values.service.ssh.annotations | nindent 4 }}
|
||||||
spec:
|
spec:
|
||||||
|
51
unittests/deployment/svc-configuration.yaml
Normal file
51
unittests/deployment/svc-configuration.yaml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
suite: ssh-svc / http-svc template (Services configuration)
|
||||||
|
release:
|
||||||
|
name: gitea-unittests
|
||||||
|
namespace: testing
|
||||||
|
templates:
|
||||||
|
- templates/gitea/ssh-svc.yaml
|
||||||
|
- templates/gitea/http-svc.yaml
|
||||||
|
tests:
|
||||||
|
- it: supports adding custom labels to ssh-svc
|
||||||
|
template: templates/gitea/ssh-svc.yaml
|
||||||
|
set:
|
||||||
|
service:
|
||||||
|
ssh:
|
||||||
|
labels:
|
||||||
|
gitea/testkey: testvalue
|
||||||
|
asserts:
|
||||||
|
- equal:
|
||||||
|
path: metadata.labels["gitea/testkey"]
|
||||||
|
value: "testvalue"
|
||||||
|
|
||||||
|
- it: keeps existing labels (ssh)
|
||||||
|
template: templates/gitea/ssh-svc.yaml
|
||||||
|
set:
|
||||||
|
service:
|
||||||
|
ssh:
|
||||||
|
labels: {}
|
||||||
|
asserts:
|
||||||
|
- exists:
|
||||||
|
path: metadata.labels["app"]
|
||||||
|
|
||||||
|
- it: supports adding custom labels to http-svc
|
||||||
|
template: templates/gitea/http-svc.yaml
|
||||||
|
set:
|
||||||
|
service:
|
||||||
|
http:
|
||||||
|
labels:
|
||||||
|
gitea/testkey: testvalue
|
||||||
|
asserts:
|
||||||
|
- equal:
|
||||||
|
path: metadata.labels["gitea/testkey"]
|
||||||
|
value: "testvalue"
|
||||||
|
|
||||||
|
- it: keeps existing labels (http)
|
||||||
|
template: templates/gitea/http-svc.yaml
|
||||||
|
set:
|
||||||
|
service:
|
||||||
|
http:
|
||||||
|
labels: {}
|
||||||
|
asserts:
|
||||||
|
- exists:
|
||||||
|
path: metadata.labels["app"]
|
@ -106,6 +106,7 @@ service:
|
|||||||
## @param service.http.ipFamilies HTTP service dual-stack familiy selection,for dual-stack parameters see official kubernetes [dual-stack concept documentation](https://kubernetes.io/docs/concepts/services-networking/dual-stack/).
|
## @param service.http.ipFamilies HTTP service dual-stack familiy selection,for dual-stack parameters see official kubernetes [dual-stack concept documentation](https://kubernetes.io/docs/concepts/services-networking/dual-stack/).
|
||||||
## @param service.http.loadBalancerSourceRanges Source range filter for http loadbalancer
|
## @param service.http.loadBalancerSourceRanges Source range filter for http loadbalancer
|
||||||
## @param service.http.annotations HTTP service annotations
|
## @param service.http.annotations HTTP service annotations
|
||||||
|
## @param service.http.labels HTTP service additional labels
|
||||||
http:
|
http:
|
||||||
type: ClusterIP
|
type: ClusterIP
|
||||||
port: 3000
|
port: 3000
|
||||||
@ -118,6 +119,7 @@ service:
|
|||||||
ipFamilies:
|
ipFamilies:
|
||||||
loadBalancerSourceRanges: []
|
loadBalancerSourceRanges: []
|
||||||
annotations: {}
|
annotations: {}
|
||||||
|
labels: {}
|
||||||
## @param service.ssh.type Kubernetes service type for ssh traffic
|
## @param service.ssh.type Kubernetes service type for ssh traffic
|
||||||
## @param service.ssh.port Port number for ssh traffic
|
## @param service.ssh.port Port number for ssh traffic
|
||||||
## @param service.ssh.clusterIP ClusterIP setting for ssh autosetup for deployment is None
|
## @param service.ssh.clusterIP ClusterIP setting for ssh autosetup for deployment is None
|
||||||
@ -130,6 +132,7 @@ service:
|
|||||||
## @param service.ssh.hostPort HostPort for ssh service
|
## @param service.ssh.hostPort HostPort for ssh service
|
||||||
## @param service.ssh.loadBalancerSourceRanges Source range filter for ssh loadbalancer
|
## @param service.ssh.loadBalancerSourceRanges Source range filter for ssh loadbalancer
|
||||||
## @param service.ssh.annotations SSH service annotations
|
## @param service.ssh.annotations SSH service annotations
|
||||||
|
## @param service.ssh.labels SSH service additional labels
|
||||||
ssh:
|
ssh:
|
||||||
type: ClusterIP
|
type: ClusterIP
|
||||||
port: 22
|
port: 22
|
||||||
@ -143,6 +146,7 @@ service:
|
|||||||
hostPort:
|
hostPort:
|
||||||
loadBalancerSourceRanges: []
|
loadBalancerSourceRanges: []
|
||||||
annotations: {}
|
annotations: {}
|
||||||
|
labels: {}
|
||||||
|
|
||||||
## @section Ingress
|
## @section Ingress
|
||||||
## @param ingress.enabled Enable ingress
|
## @param ingress.enabled Enable ingress
|
||||||
|
Loading…
Reference in New Issue
Block a user