Skip to content

Commit

Permalink
Use standard labels on all resources
Browse files Browse the repository at this point in the history
Use standard Helm labels, following
https://helm.sh/docs/chart_best_practices/labels/#standard-labels.
Use labels on all resources, so the chart can be uninstall correctly.
  • Loading branch information
nineinchnick committed May 31, 2024
1 parent fbb5413 commit 4f75b60
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 93 deletions.
2 changes: 1 addition & 1 deletion charts/trino/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Get the application URL by running these commands:
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "trino.name" . }},release={{ .Release.Name }},component=coordinator" -o jsonpath="{.items[0].metadata.name}")
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} --selector "app.kubernetes.io/name={{ template "trino.name" . }},app.kubernetes.io/instance={{ .Release.Name }},app.kubernetes.io/component=coordinator" --output name)
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:8080
{{- end }}
3 changes: 3 additions & 0 deletions charts/trino/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ helm.sh/chart: {{ include "trino.chart" . }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if .Values.commonLabels }}
{{ tpl (toYaml .Values.commonLabels) . }}
{{- end }}
{{- end }}

{{/*
Expand Down
4 changes: 1 addition & 3 deletions charts/trino/templates/autoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ kind: HorizontalPodAutoscaler
metadata:
name: {{ template "trino.worker" . }}
namespace: {{ .Release.Namespace }}
{{- if .Values.commonLabels }}
labels:
{{- tpl (toYaml .Values.commonLabels) . | nindent 4 }}
{{- end }}
{{- include "trino.labels" . | nindent 4 }}
spec:
maxReplicas: {{ .Values.server.autoscaling.maxReplicas }}
minReplicas: {{ .Values.server.workers }}
Expand Down
10 changes: 2 additions & 8 deletions charts/trino/templates/configmap-catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@ metadata:
name: {{ template "trino.catalog" . }}
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "trino.name" . }}
chart: {{ template "trino.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: catalogs
{{- if .Values.commonLabels }}
{{- tpl (toYaml .Values.commonLabels) . | nindent 4 }}
{{- end }}
{{- include "trino.labels" . | nindent 4 }}
app.kubernetes.io/component: catalogs
data:
tpch.properties: |
connector.name=tpch
Expand Down
10 changes: 2 additions & 8 deletions charts/trino/templates/configmap-coordinator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@ metadata:
name: {{ template "trino.coordinator" . }}
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "trino.name" . }}
chart: {{ template "trino.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: coordinator
{{- if .Values.commonLabels }}
{{- tpl (toYaml .Values.commonLabels) . | nindent 4 }}
{{- end }}
{{- include "trino.labels" . | nindent 4 }}
app.kubernetes.io/component: coordinator
data:
node.properties: |
node.environment={{ .Values.server.node.environment }}
Expand Down
12 changes: 2 additions & 10 deletions charts/trino/templates/configmap-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ metadata:
name: {{ template "trino.worker" . }}
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "trino.name" . }}
chart: {{ template "trino.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: worker
{{- if .Values.commonLabels }}
{{- tpl (toYaml .Values.commonLabels) . | nindent 4 }}
{{- end }}
{{- include "trino.labels" . | nindent 4 }}
app.kubernetes.io/component: worker
data:
node.properties: |
node.environment={{ .Values.server.node.environment }}
Expand Down Expand Up @@ -85,9 +79,7 @@ data:
{{ $fileName }}: |
{{- $fileContent | nindent 4 }}
{{- end }}

---

apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
24 changes: 8 additions & 16 deletions charts/trino/templates/deployment-coordinator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@ metadata:
name: {{ template "trino.coordinator" . }}
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "trino.name" . }}
chart: {{ template "trino.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: coordinator
{{- if .Values.commonLabels }}
{{- tpl (toYaml .Values.commonLabels) . | nindent 4 }}
{{- include "trino.labels" . | nindent 4 }}
app.kubernetes.io/component: coordinator
{{- if .Values.coordinator.labels }}
{{- tpl (toYaml .Values.coordinator.labels) . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "trino.name" . }}
release: {{ .Release.Name }}
component: coordinator
{{- include "trino.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: coordinator
template:
metadata:
annotations:
Expand All @@ -28,15 +24,11 @@ spec:
{{- end }}

labels:
app: {{ template "trino.name" . }}
release: {{ .Release.Name }}
component: coordinator
{{- include "trino.labels" . | nindent 8 }}
app.kubernetes.io/component: coordinator
{{- if .Values.coordinator.labels }}
{{- tpl (toYaml .Values.coordinator.labels) . | nindent 8 }}
{{- end }}
{{- if .Values.commonLabels }}
{{- tpl (toYaml .Values.commonLabels) . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "trino.serviceAccountName" . }}
{{- with .Values.securityContext }}
Expand Down
24 changes: 8 additions & 16 deletions charts/trino/templates/deployment-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@ metadata:
name: {{ template "trino.worker" . }}
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "trino.name" . }}
chart: {{ template "trino.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: worker
{{- if .Values.commonLabels }}
{{- tpl (toYaml .Values.commonLabels) . | nindent 4 }}
{{- include "trino.labels" . | nindent 4 }}
app.kubernetes.io/component: worker
{{- if .Values.worker.labels }}
{{- tpl (toYaml .Values.worker.labels) . | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.server.autoscaling.enabled }}
replicas: {{ .Values.server.workers }}
{{- end }}
selector:
matchLabels:
app: {{ template "trino.name" . }}
release: {{ .Release.Name }}
component: worker
{{- include "trino.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: worker
template:
metadata:
annotations:
Expand All @@ -30,15 +26,11 @@ spec:
{{- tpl (toYaml .Values.worker.annotations) . | nindent 8 }}
{{- end }}
labels:
app: {{ template "trino.name" . }}
release: {{ .Release.Name }}
component: worker
{{- include "trino.labels" . | nindent 8 }}
app.kubernetes.io/component: worker
{{- if .Values.worker.labels }}
{{- tpl (toYaml .Values.worker.labels) . | nindent 8 }}
{{- end }}
{{- if .Values.commonLabels }}
{{- tpl (toYaml .Values.commonLabels) . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "trino.serviceAccountName" . }}
{{- with .Values.securityContext }}
Expand Down
13 changes: 3 additions & 10 deletions charts/trino/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "trino.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ template "trino.coordinator" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "trino.labels" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- tpl (toYaml .Values.commonLabels) . | nindent 4 }}
{{- end }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- toYaml .Values.ingress.annotations | nindent 4 }}
spec:
ingressClassName: {{ .Values.ingress.className }}
{{- if .Values.ingress.tls }}
Expand All @@ -37,9 +30,9 @@ spec:
pathType: {{ .pathType }}
backend:
service:
name: {{ $fullName }}
name: {{ include "trino.fullname" . }}
port:
number: {{ $svcPort }}
number: {{ .Values.service.port }}
{{- end }}
{{- end }}
{{- end }}
3 changes: 0 additions & 3 deletions charts/trino/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "trino.labels" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- tpl (toYaml .Values.commonLabels) . | nindent 4 }}
{{- end }}
data:
{{- if .Values.auth.passwordAuth }}
password.db: {{ .Values.auth.passwordAuth | b64enc }}
Expand Down
13 changes: 3 additions & 10 deletions charts/trino/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ metadata:
name: {{ template "trino.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "trino.name" . }}
chart: {{ template "trino.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.commonLabels }}
{{- tpl (toYaml .Values.commonLabels) . | nindent 4 }}
{{- end }}
{{- include "trino.labels" . | nindent 4 }}
annotations:
{{- toYaml .Values.service.annotations | nindent 4 }}
spec:
Expand All @@ -27,6 +21,5 @@ spec:
protocol: {{ $value.protocol }}
{{- end }}
selector:
app: {{ template "trino.name" . }}
release: {{ .Release.Name }}
component: coordinator
{{- include "trino.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: coordinator
11 changes: 3 additions & 8 deletions charts/trino/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "trino.fullname" . }}-test-connection"
name: {{ include "trino.fullname" . }}-test-connection
labels:
app: {{ template "trino.name" . }}
chart: {{ template "trino.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.commonLabels }}
{{- tpl (toYaml .Values.commonLabels) . | nindent 4 }}
{{- end }}
{{- include "trino.labels" . | nindent 4 }}
app.kubernetes.io/component: test
annotations:
"helm.sh/hook": test-success
spec:
Expand Down

0 comments on commit 4f75b60

Please sign in to comment.