Skip to content

Commit

Permalink
chore: add proper labels
Browse files Browse the repository at this point in the history
  • Loading branch information
egabancho committed Dec 3, 2024
1 parent 8ae46ea commit 9bc5009
Show file tree
Hide file tree
Showing 33 changed files with 103 additions and 0 deletions.
50 changes: 50 additions & 0 deletions charts/invenio/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,53 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "invenio.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "invenio.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "invenio.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "invenio.labels" -}}
helm.sh/chart: {{ include "invenio.chart" . }}
{{ include "invenio.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
Selector labels
*/}}
{{- define "invenio.selectorLabels" -}}
app.kubernetes.io/name: {{ include "invenio.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

########################### Invenio hostname ###########################
{{/*
This template renders the hostname for Invenio.
Expand Down
1 change: 1 addition & 0 deletions charts/invenio/templates/datacite-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type: Opaque
metadata:
name: datacite-secrets
labels:
{{- include "invenio.labels" . | nindent 4 }}
app: datacite-secrets
annotations:
helm.sh/resource-policy: keep
Expand Down
1 change: 1 addition & 0 deletions charts/invenio/templates/extra-secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type: Opaque
metadata:
name: {{ $value.secret_name }}
labels:
{{- include "invenio.labels" . | nindent 4 }}
app: {{ $value.secret_name }}
annotations:
helm.sh/resource-policy: keep
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/file-configmaps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $key }}
labels:
{{- include "invenio.labels" . | nindent 4 }}
data:
{{ $value.fileName }}: |
{{- $value.file | nindent 4 }}
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/flower/celery-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: flower-celery-config
labels:
{{- include "invenio.labels" . | nindent 4 }}
data:
celeryconfig.py: |-
# looks like not really working
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/flower/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: flower-management
labels:
{{- include "invenio.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/flower/flower-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: flower-config
labels:
{{- include "invenio.labels" . | nindent 4 }}
data:
flowerconfig.py: |-
# looks like not really working
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/flower/route.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: flower-management
labels:
{{- include "invenio.labels" . | nindent 4 }}
spec:
host: {{ .Values.flower.host }}
to:
Expand Down
1 change: 1 addition & 0 deletions charts/invenio/templates/flower/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type: Opaque
metadata:
name: {{ .Values.flower.secret_name }}
labels:
{{- include "invenio.labels" . | nindent 4 }}
app: {{ .Values.flower.secret_name }}
annotations:
helm.sh/resource-policy: keep
Expand Down
1 change: 1 addition & 0 deletions charts/invenio/templates/flower/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ kind: Service
metadata:
name: flower-management
labels:
{{- include "invenio.labels" . | nindent 4 }}
app: flower-management
spec:
ports:
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/haproxy/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: haproxy-config
labels:
{{- include "invenio.labels" . | nindent 4 }}
data:
haproxy.cfg: |
global
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/haproxy/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: haproxy
labels:
{{- include "invenio.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.haproxy.replicas }}
selector:
Expand Down
1 change: 1 addition & 0 deletions charts/invenio/templates/haproxy/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ kind: Service
metadata:
name: haproxy
labels:
{{- include "invenio.labels" . | nindent 4 }}
app: haproxy
spec:
ports:
Expand Down
1 change: 1 addition & 0 deletions charts/invenio/templates/horizontalpodautoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
labels:
{{- include "invenio.labels" . | nindent 4 }}
app: web
template: invenio-application
name: web
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ metadata:
annotations:
{{- .Values.ingress.annotations | toYaml | nindent 4}}
{{- end }}
labels:
{{- include "invenio.labels" . | nindent 4 }}
spec:
{{- if .Values.ingress.class }}
ingressClassName: {{ .Values.ingress.class }}
Expand Down
1 change: 1 addition & 0 deletions charts/invenio/templates/install-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: Job
metadata:
name: install-init
labels:
{{- include "invenio.labels" . | nindent 4 }}
app: install-init
module: install
annotations:
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/invenio-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: invenio-config
labels:
{{- include "invenio.labels" . | nindent 4 }}
data:
INVENIO_ACCOUNTS_SESSION_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/1'
INVENIO_APP_ALLOWED_HOSTS: '["{{ include "invenio.hostname" $ }}"]'
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/logstash/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: logstash
labels:
{{- include "invenio.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/logstash/filebeat-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: filebeat-config
labels:
{{- include "invenio.labels" . | nindent 4 }}
data:
filebeat.yml: |-
filebeat.inputs:
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/logstash/logstash-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: logstash-configmap
labels:
{{- include "invenio.labels" . | nindent 4 }}
data:
logstash.yml: |
http.host: "0.0.0.0"
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/logstash/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: Service
apiVersion: v1
metadata:
name: logstash
labels:
{{- include "invenio.labels" . | nindent 4 }}
spec:
selector:
app: logstash
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/nginx-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
labels:
{{- include "invenio.labels" . | nindent 4 }}
data:
invenio.conf: |
upstream web {
Expand Down
1 change: 1 addition & 0 deletions charts/invenio/templates/persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ apiVersion: v1
metadata:
name: {{ .Values.persistence.name }}
labels:
{{- include "invenio.labels" . | nindent 4 }}
app: web
annotations:
helm.sh/resource-policy: keep
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/rabbitmq-routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: mq-management
labels:
{{- include "invenio.labels" . | nindent 4 }}
spec:
host: {{ required "Missing .Values.rabbitmq.ingress.hostname" .Values.rabbitmq.ingress.hostname }}
to:
Expand Down
1 change: 1 addition & 0 deletions charts/invenio/templates/remote-apps-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type: Opaque
metadata:
name: {{ .Values.invenio.remote_apps.secret_name }}
labels:
{{- include "invenio.labels" . | nindent 4 }}
app: {{ .Values.invenio.remote_apps.secret_name }}
annotations:
helm.sh/resource-policy: keep
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/route.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ metadata:
{{ . }}
{{- end }}
{{- end }}
labels:
{{- include "invenio.labels" . | nindent 4 }}
spec:
host: {{ include "invenio.hostname" $ }}
to:
Expand Down
1 change: 1 addition & 0 deletions charts/invenio/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ metadata:
name: invenio-secrets
labels:
app: invenio-secrets
{{- include "invenio.labels" . | nindent 4 }}
annotations:
helm.sh/resource-policy: keep
data:
Expand Down
1 change: 1 addition & 0 deletions charts/invenio/templates/sentry-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type: Opaque
metadata:
name: {{ .Values.invenio.sentry.secret_name }}
labels:
{{- include "invenio.labels" . | nindent 4 }}
app: {{ .Values.invenio.sentry.secret_name }}
annotations:
helm.sh/resource-policy: keep
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/uwsgi-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: uwsgi-config
labels:
{{- include "invenio.labels" . | nindent 4 }}
data:
uwsgi.ini: |
[uwsgi]
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/web-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: web
labels:
{{- include "invenio.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.web.replicas }}
selector:
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/web-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ kind: Service
metadata:
name: web
labels:
{{- include "invenio.labels" . | nindent 4 }}
run: web

{{- if .Values.web.annotations }}
annotations: {{- toYaml .Values.web.annotations | nindent 4 }}
{{- end }}
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/worker-beat-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: worker-beat
labels:
{{- include "invenio.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
Expand Down
2 changes: 2 additions & 0 deletions charts/invenio/templates/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: worker
labels:
{{- include "invenio.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.worker.replicas }}
selector:
Expand Down

0 comments on commit 9bc5009

Please sign in to comment.