Skip to content

Commit

Permalink
[CINF-2192]add commonLabels value and add labels on all resources (#84)
Browse files Browse the repository at this point in the history
Co-authored-by: skhedim <sebastien.khedim@ext.adeo.com>
  • Loading branch information
skhedim and skhedim authored Nov 29, 2023
1 parent 21a24c0 commit 5cf17ca
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion _infra/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
apiVersion: v1
name: istio-redirector
version: 0.0.7
version: 0.0.8
15 changes: 15 additions & 0 deletions _infra/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,18 @@ Create chart name and version as used by the chart label.
{{- define "istio-redirector.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Labels that should be added on each resource
*/}}
{{- define "labels" -}}
app.kubernetes.io/name: {{ include "istio-redirector.name" . }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
helm.sh/chart: {{ include "istio-redirector.chart" . }}
app: {{ .Release.Name }}
{{- if .Values.commonLabels}}
{{ toYaml .Values.commonLabels }}
{{- end }}
{{- end -}}
2 changes: 1 addition & 1 deletion _infra/templates/cluster-role-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ClusterRoleBinding
metadata:
name: {{ .Release.Name }}
labels:
app: {{ .Release.Name }}
{{- include "labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
2 changes: 1 addition & 1 deletion _infra/templates/cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ .Release.Name }}
labels:
app: {{ .Release.Name }}
{{- include "labels" . | nindent 4 }}
rules:
- apiGroups:
- networking.istio.io
Expand Down
2 changes: 2 additions & 0 deletions _infra/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}
labels:
{{- include "labels" . | nindent 4 }}
data:
config.yaml: |+
{{- tpl (.Files.Get "files/config.yaml") . | nindent 4 }}
12 changes: 2 additions & 10 deletions _infra/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ kind: Deployment
metadata:
name: {{ .Release.Name }}
labels:
app.kubernetes.io/name: {{ include "istio-redirector.name" . }}
helm.sh/chart: {{ include "istio-redirector.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app: {{ .Release.Name }}
{{- with .Values.deployment.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
{{- include "labels" . | nindent 4 }}
spec:
revisionHistoryLimit: 3
replicas: {{ .Values.autoscaling.minReplicas }}
Expand All @@ -27,15 +23,11 @@ spec:
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "istio-redirector.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app: {{ .Release.Name }}
{{- with .Values.pod.labels }}
{{ toYaml . | indent 8 }}
{{- end }}
{{- include "labels" . | nindent 8 }}
annotations:
json_logs: "true"
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
{{- with .Values.pod.annotations }}
{{ toYaml . | indent 8 }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion _infra/templates/destinationrule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: DestinationRule
metadata:
name: {{ .Release.Name }}
labels:
app: {{ .Release.Name }}
{{- include "labels" . | nindent 4 }}
spec:
host: {{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local
{{- if .Values.destinationRule.trafficPolicy }}
Expand Down
2 changes: 1 addition & 1 deletion _infra/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ kind: HorizontalPodAutoscaler
metadata:
name: {{ .Release.Name }}
labels:
app: {{ .Release.Name }}
{{- include "labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
Expand Down
4 changes: 3 additions & 1 deletion _infra/templates/pdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ kind: PodDisruptionBudget
metadata:
name: {{ .Release.Name }}
labels:
app: {{ .Release.Name }}
{{- include "labels" . | nindent 4 }}
spec:
maxUnavailable: {{ .Values.pdb }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "istio-redirector.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app: {{ .Release.Name }}
5 changes: 4 additions & 1 deletion _infra/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Service
metadata:
name: {{ .Release.Name }}
labels:
app: {{ .Release.Name }}
{{- include "labels" . | nindent 4 }}
annotations:
{{- with .Values.service.annotations }}
{{ toYaml . | indent 4 }}
Expand All @@ -15,4 +15,7 @@ spec:
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ include "istio-redirector.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app: {{ .Release.Name }}

2 changes: 1 addition & 1 deletion _infra/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app: {{ .Release.Name }}
{{- include "labels" . | nindent 4 }}
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
automountServiceAccountToken: true
6 changes: 1 addition & 5 deletions _infra/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ kind: ServiceMonitor
metadata:
name: {{ .Release.Name }}
labels:
app.kubernetes.io/name: {{ include "istio-redirector.name" . }}
helm.sh/chart: {{ include "istio-redirector.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app: {{ .Release.Name }}
{{- include "labels" . | nindent 4 }}
spec:
jobLabel: app
endpoints:
Expand Down
2 changes: 1 addition & 1 deletion _infra/templates/virtualservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: VirtualService
metadata:
name: {{ .Release.Name }}
labels:
app: {{ .Release.Name }}
{{- include "labels" . | nindent 4 }}
spec:
hosts:
- {{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local
Expand Down
2 changes: 2 additions & 0 deletions _infra/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ volumeMounts:
subPath: config.yaml
readOnly: true

commonLabels: {}

deployment:
labels: {}

Expand Down

0 comments on commit 5cf17ca

Please sign in to comment.