From 320d09f2319d688ee9a9df012e091a20568f0705 Mon Sep 17 00:00:00 2001 From: ElysaSrc <101974839+ElysaSrc@users.noreply.github.com> Date: Fri, 12 Jul 2024 19:21:25 +0200 Subject: [PATCH] chart: add osrdyne support --- templates/_helpers.tpl | 14 +- templates/core_deployment.yaml | 87 ------ templates/core_service.yaml | 19 -- templates/editoast_deployment.yaml | 2 + templates/editoast_init_script.yaml | 1 - templates/osrdyne_configmap.yaml | 68 +++++ templates/osrdyne_deployment.yaml | 86 ++++++ templates/osrdyne_role.yaml | 12 + templates/osrdyne_rolebinding.yaml | 13 + templates/osrdyne_service_account.yaml | 9 + values.schema.json | 368 ------------------------- values.yaml | 33 ++- 12 files changed, 224 insertions(+), 488 deletions(-) delete mode 100644 templates/core_deployment.yaml delete mode 100644 templates/core_service.yaml create mode 100644 templates/osrdyne_configmap.yaml create mode 100644 templates/osrdyne_deployment.yaml create mode 100644 templates/osrdyne_role.yaml create mode 100644 templates/osrdyne_rolebinding.yaml create mode 100644 templates/osrdyne_service_account.yaml delete mode 100644 values.schema.json diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 2cd4ec9..f6e1dd9 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -31,11 +31,11 @@ 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 }} @@ -43,11 +43,11 @@ 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 }} {{/* diff --git a/templates/core_deployment.yaml b/templates/core_deployment.yaml deleted file mode 100644 index 3e59f77..0000000 --- a/templates/core_deployment.yaml +++ /dev/null @@ -1,87 +0,0 @@ -{{- if .Values.core.enabled -}} - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "osrd.fullname" . }}-core - labels: - {{- include "osrd.labels.core" . | nindent 4 }} - {{- with .Values.core.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - replicas: {{ .Values.core.replicaCount }} - selector: - matchLabels: - {{- include "osrd.selectorLabels.core" . | nindent 6 }} - template: - metadata: - annotations: - rollme: {{ randAlphaNum 5 | quote }} - {{- with .Values.core.annotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "osrd.labels.core" . | nindent 8 }} - {{- with .Values.core.labels }} - {{- toYaml . | nindent 8 }} - {{- end }} - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - containers: - - name: {{ include "osrd.name" . }}-core - image: "{{ .Values.core.image }}" - imagePullPolicy: {{ .Values.core.pullPolicy }} - ports: - - name: http - containerPort: {{ .Values.core.service.port }} - protocol: TCP - livenessProbe: - httpGet: - path: /health - port: http - initialDelaySeconds: {{ .Values.core.livenessProbe.initialDelaySeconds }} - periodSeconds: {{ .Values.core.livenessProbe.periodSeconds }} - timeoutSeconds: {{ .Values.core.livenessProbe.timeoutSeconds }} - readinessProbe: - httpGet: - path: /health - port: http - env: - {{- with .Values.core.env }} - {{- toYaml . | nindent 12 }} - {{- end }} - - name: CORE_EDITOAST_URL - value: {{ .Values.editoast.internalUrl }} - - name: CORE_PORT - value: "{{ .Values.core.service.targetPort }}" - {{- if .Values.core.config.telemetry }} - - 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 -}} - {{- end }} - resources: - {{- toYaml .Values.core.resources | nindent 12 }} - {{- with .Values.core.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.core.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.core.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} - -{{- end }} diff --git a/templates/core_service.yaml b/templates/core_service.yaml deleted file mode 100644 index 6687c36..0000000 --- a/templates/core_service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -{{- if .Values.core.enabled -}} - -apiVersion: v1 -kind: Service -metadata: - name: {{ include "osrd.fullname" . }}-core - labels: - {{- include "osrd.labels.core" . | nindent 4 }} -spec: - type: {{ .Values.core.service.type }} - ports: - - port: {{ .Values.core.service.port }} - targetPort: {{ .Values.core.service.targetPort }} - protocol: TCP - name: http - selector: - {{- include "osrd.selectorLabels.core" . | nindent 4 }} - -{{- end }} \ No newline at end of file diff --git a/templates/editoast_deployment.yaml b/templates/editoast_deployment.yaml index b3fe1d3..d449e47 100644 --- a/templates/editoast_deployment.yaml +++ b/templates/editoast_deployment.yaml @@ -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 }} diff --git a/templates/editoast_init_script.yaml b/templates/editoast_init_script.yaml index 81046d8..8214cbe 100644 --- a/templates/editoast_init_script.yaml +++ b/templates/editoast_init_script.yaml @@ -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 }} diff --git a/templates/osrdyne_configmap.yaml b/templates/osrdyne_configmap.yaml new file mode 100644 index 0000000..c84aead --- /dev/null +++ b/templates/osrdyne_configmap.yaml @@ -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 }} diff --git a/templates/osrdyne_deployment.yaml b/templates/osrdyne_deployment.yaml new file mode 100644 index 0000000..4867b6b --- /dev/null +++ b/templates/osrdyne_deployment.yaml @@ -0,0 +1,86 @@ +{{- 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: {{ .Values.osrdyne.replicaCount }} + 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 }} diff --git a/templates/osrdyne_role.yaml b/templates/osrdyne_role.yaml new file mode 100644 index 0000000..dc24880 --- /dev/null +++ b/templates/osrdyne_role.yaml @@ -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"] diff --git a/templates/osrdyne_rolebinding.yaml b/templates/osrdyne_rolebinding.yaml new file mode 100644 index 0000000..20f8f34 --- /dev/null +++ b/templates/osrdyne_rolebinding.yaml @@ -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 diff --git a/templates/osrdyne_service_account.yaml b/templates/osrdyne_service_account.yaml new file mode 100644 index 0000000..8ba6298 --- /dev/null +++ b/templates/osrdyne_service_account.yaml @@ -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 }} diff --git a/values.schema.json b/values.schema.json deleted file mode 100644 index 1866b93..0000000 --- a/values.schema.json +++ /dev/null @@ -1,368 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$defs": { - "commonOsrdService": { - "type": "object", - "description": "Core deployment values", - "properties": { - "enabled": { - "type": "boolean", - "description": "Enable or disable the service" - }, - "image": { - "type": "string", - "description": "Image to use for the service" - }, - "pullPolicy": { - "type": "string", - "description": "Image pull policy" - }, - "replicaCount": { - "type": "integer", - "description": "Default number of replicas" - }, - "service": { - "type": "object", - "description": "Kubernetes Service configuration", - "properties": { - "type": { - "type": "string", - "description": "Service type (ClusterIP, NodePort, LoadBalancer, ...)" - }, - "port": { - "type": "integer", - "description": "Service port" - }, - "targetPort": { - "type": "integer", - "description": "Service target port" - } - }, - "required": [ - "type", - "port" - ] - }, - "livenessProbe": { - "type": "object", - "description": "Liveness probe configuration", - "properties": { - "initialDelaySeconds": { - "type": "integer", - "description": "Number of seconds after the container has started before liveness probes are initiated" - }, - "periodSeconds": { - "type": "integer", - "description": "How often (in seconds) to perform the probe" - }, - "timeoutSeconds": { - "type": "integer", - "description": "Number of seconds after which the probe times out" - } - }, - "required": [] - }, - "annotations": { - "type": "object", - "description": "Annotations to add to the service", - "additionalProperties": { - "type": "string" - } - }, - "labels": { - "type": "object", - "description": "Labels to add to the service", - "additionalProperties": { - "type": "string" - } - }, - "nodeSelector": { - "type": "object", - "description": "Node selector to apply to the service", - "additionalProperties": { - "type": "string" - } - }, - "tolerations": { - "type": "array", - "description": "Tolerations to apply to the service", - "items": { - "type": "object" - } - }, - "affinity": { - "type": "object", - "description": "Affinity to apply to the service" - }, - "resources": { - "type": "object", - "description": "Resources to ive to the service" - }, - "env": { - "type": "array", - "description": "Environment variables to set", - "items": { - "type": "object" - } - } - }, - "required": [ - "enabled", - "image", - "pullPolicy", - "replicaCount", - "service" - ] - } - }, - "title": "Values", - "type": "object", - "properties": { - "nameOverride": { - "type": "string", - "description": "String to partially override common.names.fullname template with a string (will prepend the release name)" - }, - "fullnameOverride": { - "type": "string", - "description": "String to fully override common.names.fullname template with a string" - }, - "imagePullSecrets": { - "type": "array", - "description": "Image pull secrets", - "items": { - "type": "object" - } - }, - "core": { - "type": "object", - "description": "Core deployment values", - "allOf": [ - { - "$ref": "#/$defs/commonOsrdService" - }, - { - "properties": { - "internalUrl": { - "type": "string", - "description": "Internal URL for the service" - }, - "config": { - "type": "object", - "properties": { - "telemetry": { - "type": ["string", "null"], - "description": "Activate the telemtry by specifying the backend to use with Core" - } - } - } - }, - "required": [ - "internalUrl" - ] - } - ] - }, - "editoast": { - "allOf": [ - { - "$ref": "#/$defs/commonOsrdService" - }, - { - "properties": { - "init": { - "properties": { - "enabled": { - "type": "boolean", - "description": "Enable or disable the initialization" - }, - "extend": { - "type": "string", - "description": "Extend the initialization with custom shell script" - }, - "internalUrl": { - "type": "string", - "description": "Internal URL for the service" - } - } - } - } - } - ] - }, - "tileServer": { - "allOf": [ - { - "$ref": "#/properties/editoast" - }, - { - "properties": { - "hpa": { - "type": "object", - "properties": { - "enabled": { - "type": "boolean" - }, - "minReplicas": { - "type": "integer" - }, - "maxReplicas": { - "type": "integer" - }, - "targetCPUUtilizationPercentage": { - "type": "integer" - } - }, - "required": [ - "enabled", - "minReplicas", - "maxReplicas", - "targetCPUUtilizationPercentage" - ] - } - } - } - ] - }, - "gateway": { - "allOf": [ - { - "$ref": "#/$defs/commonOsrdService" - }, - { - "properties": { - "ingress": { - "type": "object", - "description": "Ingress configuration", - "properties": { - "enabled": { - "type": "boolean", - "description": "Enable or disable the ingress" - }, - "className": { - "type": "string", - "description": "Ingress class name" - }, - "domains": { - "type": "array", - "description": "Domains to use for the ingress", - "items": { - "type": "string" - } - }, - "secretName": { - "type": "string", - "description": "Secret name to use for the TLS configuration of the ingress" - }, - "annotations": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "Annotations to add to the ingress" - }, - "tls": { - "type": "array", - "description": "TLS configuration for the ingress", - "items": { - "type": "object" - } - } - }, - "required": [ - "enabled" - ] - }, - "volumes": { - "type": "array", - "description": "Volumes to mount", - "items": { - "type": "object" - } - }, - "volumeMounts": { - "type": "array", - "description": "Volume mounts to apply", - "items": { - "type": "object" - } - }, - "config": { - "type": "object", - "description": "Gateway configuration", - "properties": { - "auth": { - "type": "object", - "description": "Authentication configuration", - "properties": { - "providers": { - "type": "array", - "items": { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "provider_id": { - "type": "string" - }, - "username": { - "type": "string" - }, - "require_login": { - "type": "boolean" - } - }, - "required": [ - "type", - "provider_id" - ] - } - } - } - }, - "tracing": { - "type": "object", - "description": "Tracing configuration", - "properties": { - "enabled": { - "type": "boolean", - "description": "Enable or disable the tracing" - }, - "type": { - "type": "string", - "description": "Tracing type (jaeger, zipkin, ...)" - }, - "config": { - "type": "object", - "description": "Tracing configuration" - } - }, - "required": [ - "enabled" - ] - }, - "trusted_proxies": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "required": [ - "auth", - "tracing", - "trusted_proxies" - ] - } - } - } - ] - } - }, - "required": [ - "core", - "editoast", - "gateway", - "tileServer" - ] -} diff --git a/values.yaml b/values.yaml index 195c396..9d91f53 100644 --- a/values.yaml +++ b/values.yaml @@ -3,10 +3,11 @@ fullnameOverride: "" imagePullSecrets: [] -core: - internalUrl: http://osrd-core.osrd.svc.cluster.local +osrdyne: + enabled: true + internalUrl: http://osrdyne.osrd.svc.cluster.local enabled: true - image: osrd/core + image: ghcr.io/openrailassociation/osrd-edge/osrd-orsdyne:dev pullPolicy: IfNotPresent replicaCount: 1 service: @@ -24,13 +25,33 @@ core: affinity: {} resources: {} env: [] + config: + amqp_uri: "amqp://osrd:password@rabbitmq:5672/%2f" + management_port: 15672 + management_host: + pool_id: "core" + default_message_ttl: + max_length: + max_length_bytes: + api_address: "0.0.0.0:80" + +core: + image: ghcr.io/openrailassociation/osrd-edge/osrd-core:dev + pullPolicy: IfNotPresent + annotations: {} + labels: {} + nodeSelector: {} + tolerations: [] + affinity: {} + resources: {} + enn: [] config: telemetry: null editoast: internalUrl: http://osrd-editoast.osrd.svc.cluster.local enabled: true - image: osrd/editoast + image: ghcr.io/openrailassociation/osrd-edge/osrd-editoast:dev pullPolicy: IfNotPresent replicaCount: 1 service: @@ -55,7 +76,7 @@ editoast: tileServer: internalUrl: http://osrd-tile-server.osrd.svc.cluster.local enabled: false - image: osrd/editoast + image: ghcr.io/openrailassociation/osrd-edge/osrd-editoast:dev pullPolicy: IfNotPresent replicaCount: 2 service: @@ -77,7 +98,7 @@ tileServer: gateway: enabled: true - image: osrd/gateway + image: ghcr.io/openrailassociation/osrd-edge/osrd-gateway:dev-front pullPolicy: IfNotPresent replicaCount: 1 service: