Skip to content

Commit

Permalink
chart: add osrdyne support
Browse files Browse the repository at this point in the history
  • Loading branch information
ElysaSrc committed Jul 12, 2024
1 parent 667b602 commit 1022f25
Show file tree
Hide file tree
Showing 12 changed files with 226 additions and 489 deletions.
14 changes: 7 additions & 7 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ Create chart name and version as used by the chart label.
{{- end }}

{{/*
Common labels Core
Common labels Osrdyne
*/}}
{{- define "osrd.labels.core" -}}
{{- define "osrd.labels.osrdyne" -}}
helm.sh/chart: {{ include "osrd.chart" . }}
{{ include "osrd.selectorLabels.core" . }}
{{ include "osrd.selectorLabels.osrdyne" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels Core
Selector labels Osrdyne
*/}}
{{- define "osrd.selectorLabels.core" -}}
app.kubernetes.io/name: {{ include "osrd.name" . }}-core
app.kubernetes.io/instance: {{ .Release.Name }}-core
{{- define "osrd.selectorLabels.osrdyne" -}}
app.kubernetes.io/name: {{ include "osrd.name" . }}-osrdyne
app.kubernetes.io/instance: {{ .Release.Name }}-osrdyne
{{- end }}

{{/*
Expand Down
87 changes: 0 additions & 87 deletions templates/core_deployment.yaml

This file was deleted.

19 changes: 0 additions & 19 deletions templates/core_service.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions templates/editoast_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ spec:
value: "{{ .Values.editoast.service.targetPort }}"
- name: OSRD_BACKEND_URL
value: {{ .Values.core.internalUrl }}
- name: OSRD_MQ_URL
value: {{ .Values.osrdyne.config.amqp_uri }}
resources:
{{- toYaml .Values.editoast.resources | nindent 12 }}
{{- with .Values.editoast.nodeSelector }}
Expand Down
1 change: 0 additions & 1 deletion templates/editoast_init_script.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ data:
{{- with .Values.editoast.init.extend }}
{{ . }}
{{- end }}
export DATABASE_URL="postgres://${PSQL_USERNAME}:${PSQL_PASSWORD}@${PSQL_HOST}:${PSQL_PORT}/${PSQL_DATABASE}"
diesel migration run
{{- end }}
68 changes: 68 additions & 0 deletions templates/osrdyne_configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{{- if .Values.osrdyne.enabled -}}

apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "osrd.fullname" . }}-osrdyne-config
data:
osrdyne.yml: |
amqp_uri: "{{ .Values.osrdyne.config.amqp_uri }}"
management_port: {{ .Values.osrdyne.config.management_port }}
{{- if .Values.osrdyne.config.management_host }}
management_host: "{{ .Values.osrdyne.config.management_host }}"
{{- end }}
{{- if .Values.osrdyne.config.pool_id }}
pool_id: "{{ .Values.osrdyne.config.pool_id }}"
{{- end }}
{{- if .Values.osrdyne.config.default_message_ttl }}
default_message_ttl: "{{ .Values.osrdyne.config.default_message_ttl }}"
{{- end }}
{{- if .Values.osrdyne.config.max_length }}
max_length: "{{ .Values.osrdyne.config.max_length }}"
{{- end }}
{{- if .Values.osrdyne.config.max_length_bytes }}
max_length_bytes: "{{ .Values.osrdyne.config.max_length_bytes }}"
{{- end }}
api_address: "0.0.0.0:80"
worker_driver:
type: "KubernetesDriver"
core_image: "{{ .Values.core.image }}"
deployment_prefix: "{{ include "osrd.fullname" . }}"
namespace: "{{ .Release.Namespace }}"
editoast_url: "{{ .Values.editoast.internalUrl }}"
{{- with .Values.core.autoscaling }}
autoscaling:
{{- toYaml . | nindent 6 }}
{{- end }}
kube_deployment_options:
default_env:
{{- with .Values.core.env }}
{{- toYaml . | nindent 10 }}
{{- end }}
- name: CORE_EDITOAST_URL
value: {{ .Values.editoast.internalUrl }}
- name: CORE_MONITOR_TYPE
value: "{{ .Values.core.config.telemetry }}"
- name: JAVA_TOOL_OPTIONS
value: {{ if eq .Values.core.config.telemetry "opentelemetry" -}}
"-javaagent:/app/opentelemetry-javaagent.jar"
{{- else if eq .Values.core.config.telemetry "datadog" -}}
"-javaagent:/app/dd-java-agent.jar"
{{- end -}}
{{- with .Values.core.resources }}
resources:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.core.nodeSelector }}
node_selector:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.core.affinity }}
affinity:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.core.tolerations }}
tolerations:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- end }}
88 changes: 88 additions & 0 deletions templates/osrdyne_deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{{- if .Values.osrdyne.enabled -}}

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "osrd.fullname" . }}-osrdyne
labels:
{{- include "osrd.labels.osrdyne" . | nindent 4 }}
{{- with .Values.osrdyne.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
{{- include "osrd.selectorLabels.osrdyne" . | nindent 6 }}
template:
metadata:
annotations:
rollme: {{ randAlphaNum 5 | quote }}
{{- with .Values.osrdyne.annotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "osrd.labels.osrdyne" . | nindent 8 }}
{{- with .Values.osrdyne.labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "osrd.fullname" . }}-osrdyne-sa
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ include "osrd.name" . }}-osrdyne
image: "{{ .Values.osrdyne.image }}"
imagePullPolicy: {{ .Values.osrdyne.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.osrdyne.service.port }}
protocol: TCP
volumeMounts:
- name: config
mountPath: /osrdyne.yml
subPath: osrdyne.yml
{{- with .Values.osrdyne.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
livenessProbe:
httpGet:
path: /health
port: http
readinessProbe:
httpGet:
path: /health
port: http
env:
{{- with .Values.osrdyne.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
- name: osrdyne_PORT
value: "{{ .Values.osrdyne.service.port }}"
resources:
{{- toYaml .Values.osrdyne.resources | nindent 12 }}
volumes:
- name: config
configMap:
name: {{ include "osrd.fullname" . }}-osrdyne-config
{{- with .Values.osrdyne.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.osrdyne.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.osrdyne.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.osrdyne.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
12 changes: 12 additions & 0 deletions templates/osrdyne_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "osrd.fullname" . }}-osrdyne-role
namespace: {{ .Release.Namespace }}
rules:
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["get", "create", "update", "delete", "list"]
- apiGroups: ["autoscaling"]
resources: ["horizontalpodautoscalers"]
verbs: ["get", "create", "update", "delete", "list"]
13 changes: 13 additions & 0 deletions templates/osrdyne_rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "osrd.fullname" . }}-osrdyne-rolebinding
namespace: {{ .Release.Namespace }}
subjects:
- kind: ServiceAccount
name: {{ include "osrd.fullname" . }}-osrdyne-sa
namespace: {{ .Release.Namespace }}
roleRef:
kind: Role
name: {{ include "osrd.fullname" . }}-osrdyne-role
apiGroup: rbac.authorization.k8s.io
9 changes: 9 additions & 0 deletions templates/osrdyne_service_account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "osrd.fullname" . }}-osrdyne-sa
labels:
app.kubernetes.io/name: {{ include "osrd.name" . }}
helm.sh/chart: {{ include "osrd.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
Loading

0 comments on commit 1022f25

Please sign in to comment.