Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: common labels for all resources #842

Merged
merged 2 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions traefik/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ app.kubernetes.io/instance: {{ template "traefik.instance-name" . }}
{{ include "traefik.labelselector" . }}
helm.sh/chart: {{ template "traefik.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if .Values.commonLabels }}
{{ toYaml .Values.commonLabels }}
{{- end }}
{{- end }}

{{/*
Expand Down
2 changes: 2 additions & 0 deletions traefik/templates/gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ kind: Gateway
metadata:
name: traefik-gateway
namespace: {{ default (include "traefik.namespace" .) .Values.experimental.kubernetesGateway.namespace }}
labels:
{{- include "traefik.labels" . | nindent 4 }}
{{- with .Values.experimental.kubernetesGateway.gateway.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
2 changes: 2 additions & 0 deletions traefik/templates/gatewayclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ apiVersion: gateway.networking.k8s.io/v1alpha2
kind: GatewayClass
metadata:
name: traefik
labels:
{{- include "traefik.labels" . | nindent 4 }}
spec:
controllerName: traefik.io/gateway-controller
{{- end }}
62 changes: 62 additions & 0 deletions traefik/tests/common-metadata_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
suite: Resources contains metadata
templates:
- dashboard-ingressroute.yaml
- deployment.yaml
- gatewayclass.yaml
- gateway.yaml
- hpa.yaml
- ingressclass.yaml
- poddisruptionbudget.yaml
- prometheusrules.yaml
- pvc.yaml
- service-hub.yaml
- service-internal.yaml
- servicemonitor.yaml
- service.yaml
- tlsoption.yaml
- tlsstore.yaml
- rbac/clusterrole.yaml
- rbac/clusterrolebinding.yaml
- rbac/podsecuritypolicy.yaml
- rbac/role.yaml
- rbac/rolebinding.yaml
- rbac/serviceaccount.yaml

tests:
- it: "should contains labels metadata"
set:
experimental.kubernetesGateway.enabled: true
experimental.kubernetesGateway.gateway.enabled: true
autoscaling.enabled: true
autoscaling.maxReplicas: 10
podDisruptionBudget.enabled: true
metrics.prometheus.prometheusRule.namespace: test
metrics.prometheus.serviceMonitor.namespace: test
metrics.prometheus.service.enabled: true
service.internal.a: {}
persistence.enabled: true
hub.enabled: enabled
tlsStore.a: {}
tlsOptions.a: {}
podSecurityPolicy.enabled: true
rbac.enabled: true
rbac.namespaced: true
commonLabels:
globalLabel: isConfigured
capabilities:
majorVersion: 1
minorVersion: 16
apiVersions:
- monitoring.coreos.com/v1
- autoscaling/v2beta1
asserts:
- isNotEmpty:
path: metadata.labels
- isSubset:
path: metadata.labels
content:
app.kubernetes.io/managed-by: Helm
- isSubset:
path: metadata.labels
content:
globalLabel: isConfigured
4 changes: 4 additions & 0 deletions traefik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ image:
tag: ""
pullPolicy: IfNotPresent

# Add additional label to all resources
# commonLabels:
# key: value

#
# Configure integration with Traefik Hub
#
Expand Down