diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl index 7f923538..eb9eb8f6 100644 --- a/chart/templates/_helpers.tpl +++ b/chart/templates/_helpers.tpl @@ -5,6 +5,31 @@ Create kyoo ingress name {{- printf "%s-%s" (include "kyoo.fullname" .) "ingress" | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{/* +Create kyoo api name +*/}} +{{- define "kyoo.api.fullname" -}} +{{- printf "%s-%s" (include "kyoo.fullname" .) .Values.api.name | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create the name of the api service account to use +*/}} +{{- define "kyoo.api.serviceAccountName" -}} +{{- if .Values.api.serviceAccount.create -}} + {{ default (include "kyoo.api.fullname" .) .Values.api.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.api.serviceAccount.name }} +{{- end -}} +{{- end -}} + +{{/* +Create kyoo api-metadata name +*/}} +{{- define "kyoo.apimetadata.fullname" -}} +{{- printf "%s-%s%s" (include "kyoo.fullname" .) .Values.api.name "metadata" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + {{/* Create kyoo auth name */}} @@ -23,31 +48,6 @@ Create the name of the auth service account to use {{- end -}} {{- end -}} -{{/* -Create kyoo back name -*/}} -{{- define "kyoo.back.fullname" -}} -{{- printf "%s-%s" (include "kyoo.fullname" .) .Values.back.name | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create the name of the back service account to use -*/}} -{{- define "kyoo.back.serviceAccountName" -}} -{{- if .Values.back.serviceAccount.create -}} - {{ default (include "kyoo.back.fullname" .) .Values.back.serviceAccount.name }} -{{- else -}} - {{ default "default" .Values.back.serviceAccount.name }} -{{- end -}} -{{- end -}} - -{{/* -Create kyoo back-metadata name -*/}} -{{- define "kyoo.backmetadata.fullname" -}} -{{- printf "%s-%s%s" (include "kyoo.fullname" .) .Values.back.name "metadata" | trunc 63 | trimSuffix "-" -}} -{{- end -}} - {{/* Create kyoo front name diff --git a/chart/templates/back/deployment.yaml b/chart/templates/api/deployment.yaml similarity index 67% rename from chart/templates/back/deployment.yaml rename to chart/templates/api/deployment.yaml index 06a551d0..8faf4231 100644 --- a/chart/templates/back/deployment.yaml +++ b/chart/templates/api/deployment.yaml @@ -1,39 +1,39 @@ apiVersion: apps/v1 kind: Deployment metadata: - {{- with (mergeOverwrite (deepCopy .Values.global.deploymentAnnotations) .Values.back.deploymentAnnotations) }} + {{- with (mergeOverwrite (deepCopy .Values.global.deploymentAnnotations) .Values.api.deploymentAnnotations) }} annotations: {{- range $key, $value := . }} {{ $key }}: {{ $value | quote }} {{- end }} {{- end }} - name: {{ include "kyoo.back.fullname" . }} + name: {{ include "kyoo.api.fullname" . }} labels: - {{- include "kyoo.labels" (dict "context" . "component" .Values.back.name "name" .Values.back.name) | nindent 4 }} + {{- include "kyoo.labels" (dict "context" . "component" .Values.api.name "name" .Values.api.name) | nindent 4 }} spec: - replicas: {{ .Values.back.replicaCount }} - {{- with .Values.back.updateStrategy }} + replicas: {{ .Values.api.replicaCount }} + {{- with .Values.api.updateStrategy }} strategy: {{- toYaml . | nindent 4 }} {{- end }} selector: matchLabels: - {{- include "kyoo.selectorLabels" (dict "context" . "name" .Values.back.name) | nindent 6 }} + {{- include "kyoo.selectorLabels" (dict "context" . "name" .Values.api.name) | nindent 6 }} template: metadata: - {{- with (mergeOverwrite (deepCopy .Values.global.podAnnotations) .Values.back.podAnnotations) }} + {{- with (mergeOverwrite (deepCopy .Values.global.podAnnotations) .Values.api.podAnnotations) }} annotations: {{- range $key, $value := . }} {{ $key }}: {{ $value | quote }} {{- end }} {{- end }} labels: - {{- include "kyoo.labels" (dict "context" . "component" .Values.back.name "name" .Values.back.name) | nindent 8 }} - {{- with (mergeOverwrite (deepCopy .Values.global.podLabels) .Values.back.podLabels) }} + {{- include "kyoo.labels" (dict "context" . "component" .Values.api.name "name" .Values.api.name) | nindent 8 }} + {{- with (mergeOverwrite (deepCopy .Values.global.podLabels) .Values.api.podLabels) }} {{- toYaml . | nindent 8 }} {{- end }} spec: - {{- with .Values.back.imagePullSecrets | default .Values.global.imagePullSecrets }} + {{- with .Values.api.imagePullSecrets | default .Values.global.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} @@ -41,17 +41,17 @@ spec: securityContext: {{- toYaml . | nindent 8 }} {{- end }} - serviceAccountName: {{ include "kyoo.back.serviceAccountName" . }} + serviceAccountName: {{ include "kyoo.api.serviceAccountName" . }} initContainers: - {{- with .Values.back.extraInitContainers }} + {{- with .Values.api.extraInitContainers }} {{- tpl (toYaml .) $ | nindent 6 }} {{- end }} containers: - name: main - image: {{ .Values.back.kyoo_back.image.repository | default (printf "%s/kyoo_back" .Values.global.image.repositoryBase) }}:{{ default (include "kyoo.defaultTag" .) .Values.back.kyoo_back.image.tag }} + image: {{ .Values.api.kyoo_api.image.repository | default (printf "%s/kyoo_api" .Values.global.image.repositoryBase) }}:{{ default (include "kyoo.defaultTag" .) .Values.api.kyoo_api.image.tag }} imagePullPolicy: {{ default .Values.global.image.imagePullPolicy }} args: - {{- with .Values.back.kyoo_back.extraArgs }} + {{- with .Values.api.kyoo_api.extraArgs }} {{- toYaml . | nindent 12 }} {{- end }} env: @@ -75,19 +75,19 @@ spec: - name: POSTGRES_USER valueFrom: secretKeyRef: - key: {{ .Values.global.postgres.kyoo_back.kyoo_back.userKey }} - name: {{ .Values.global.postgres.kyoo_back.kyoo_back.existingSecret }} + key: {{ .Values.global.postgres.kyoo_api.kyoo_api.userKey }} + name: {{ .Values.global.postgres.kyoo_api.kyoo_api.existingSecret }} - name: POSTGRES_PASSWORD valueFrom: secretKeyRef: - key: {{ .Values.global.postgres.kyoo_back.kyoo_back.passwordKey }} - name: {{ .Values.global.postgres.kyoo_back.kyoo_back.existingSecret }} + key: {{ .Values.global.postgres.kyoo_api.kyoo_api.passwordKey }} + name: {{ .Values.global.postgres.kyoo_api.kyoo_api.existingSecret }} - name: POSTGRES_DB - value: {{ .Values.global.postgres.kyoo_back.database }} + value: {{ .Values.global.postgres.kyoo_api.database }} - name: POSTGRES_SERVER - value: {{ .Values.global.postgres.kyoo_back.host | quote }} + value: {{ .Values.global.postgres.kyoo_api.host | quote }} - name: POSTGRES_PORT - value: {{ .Values.global.postgres.kyoo_back.port | quote }} + value: {{ .Values.global.postgres.kyoo_api.port | quote }} {{- range $index, $provider := .Values.kyoo.oidc_providers }} - name: OIDC_{{ $provider.name | upper }}_NAME value: {{ $provider.name | quote }} @@ -114,58 +114,58 @@ spec: - name: OIDC_{{ $provider.name | upper }}_AUTHMETHOD value: {{ $provider.authMethod | default "ClientSecretBasic" | quote }} {{- end }} - {{- with (concat .Values.global.extraEnv .Values.back.kyoo_back.extraEnv) }} + {{- with (concat .Values.global.extraEnv .Values.api.kyoo_api.extraEnv) }} {{- toYaml . | nindent 12 }} {{- end }} ports: - name: main containerPort: 5000 protocol: TCP - {{- with .Values.back.kyoo_back.livenessProbe }} + {{- with .Values.api.kyoo_api.livenessProbe }} livenessProbe: {{- toYaml . | nindent 12 }} {{- end }} - {{- with .Values.back.kyoo_back.readinessProbe }} + {{- with .Values.api.kyoo_api.readinessProbe }} readinessProbe: {{- toYaml . | nindent 12 }} {{- end }} - {{- with .Values.back.kyoo_back.resources }} + {{- with .Values.api.kyoo_api.resources }} resources: {{- toYaml . | nindent 12 }} {{- end }} - {{- with .Values.back.kyoo_back.containerSecurityContext }} + {{- with .Values.api.kyoo_api.containerSecurityContext }} securityContext: {{- toYaml . | nindent 12 }} {{- end }} volumeMounts: - {{- if .Values.back.persistence.enabled }} - - name: backmetadata + {{- if .Values.api.persistence.enabled }} + - name: apimetadata mountPath: /metadata {{- end }} - {{- with .Values.back.kyoo_back.volumeMounts }} + {{- with .Values.api.kyoo_api.volumeMounts }} {{- toYaml . | nindent 12 }} {{- end }} - {{- with .Values.back.kyoo_back.extraVolumeMounts }} + {{- with .Values.api.kyoo_api.extraVolumeMounts }} {{- toYaml . | nindent 12 }} {{- end }} - {{- with .Values.back.extraContainers }} + {{- with .Values.api.extraContainers }} {{- tpl (toYaml .) $ | nindent 8 }} {{- end }} volumes: - {{- if .Values.back.persistence.enabled }} - {{- if .Values.back.persistence.existingClaim }} - - name: backmetadata + {{- if .Values.api.persistence.enabled }} + {{- if .Values.api.persistence.existingClaim }} + - name: apimetadata persistentVolumeClaim: - claimName: {{ .Values.back.persistence.existingClaim }} + claimName: {{ .Values.api.persistence.existingClaim }} {{- else }} - - name: backmetadata + - name: apimetadata persistentVolumeClaim: - claimName: {{ include "kyoo.backmetadata.fullname" . }} + claimName: {{ include "kyoo.apimetadata.fullname" . }} {{- end }} {{- end }} - {{- with .Values.back.volumes }} + {{- with .Values.api.volumes }} {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.back.extraVolumes }} + {{- with .Values.api.extraVolumes }} {{- toYaml . | nindent 8 }} {{- end }} diff --git a/chart/templates/api/pvc.yaml b/chart/templates/api/pvc.yaml new file mode 100644 index 00000000..17da1824 --- /dev/null +++ b/chart/templates/api/pvc.yaml @@ -0,0 +1,25 @@ +{{- if and .Values.api.persistence.enabled (not .Values.api.persistence.existingClaim) }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "kyoo.apimetadata.fullname" . }} + labels: + {{- include "kyoo.labels" (dict "context" . "component" .Values.api.name "name" .Values.api.name) | nindent 4 }} + {{- with (mergeOverwrite (deepCopy .Values.global.persistentVolumeClaimAnnotations) .Values.api.persistence.annotations) }} + annotations: + {{- range $key, $value := . }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- end }} +spec: + accessModes: + {{- range .Values.api.persistence.accessModes }} + - {{ . }} + {{- end }} + resources: + requests: + storage: {{ .Values.api.persistence.size }} + {{- if .Values.api.persistence.storageClass }} + storageClassName: {{ .Values.api.persistence.storageClass }} + {{- end }} +{{- end }} diff --git a/chart/templates/back/service.yaml b/chart/templates/api/service.yaml similarity index 55% rename from chart/templates/back/service.yaml rename to chart/templates/api/service.yaml index e906b326..f55ec842 100644 --- a/chart/templates/back/service.yaml +++ b/chart/templates/api/service.yaml @@ -1,24 +1,24 @@ apiVersion: v1 kind: Service metadata: -{{- if .Values.back.service.annotations }} +{{- if .Values.api.service.annotations }} annotations: - {{- range $key, $value := .Values.back.service.annotations }} + {{- range $key, $value := .Values.api.service.annotations }} {{ $key }}: {{ $value | quote }} {{- end }} {{- end }} - name: {{ include "kyoo.back.fullname" . }} + name: {{ include "kyoo.api.fullname" . }} labels: - {{- include "kyoo.labels" (dict "context" . "component" .Values.back.name "name" .Values.back.name) | nindent 4 }} - {{- with .Values.back.service.labels }} + {{- include "kyoo.labels" (dict "context" . "component" .Values.api.name "name" .Values.api.name) | nindent 4 }} + {{- with .Values.api.service.labels }} {{- toYaml . | nindent 4 }} {{- end }} spec: - type: {{ .Values.back.service.type }} + type: {{ .Values.api.service.type }} ports: - port: 5000 targetPort: 5000 protocol: TCP name: main selector: - {{- include "kyoo.selectorLabels" (dict "context" . "name" .Values.back.name) | nindent 4 }} + {{- include "kyoo.selectorLabels" (dict "context" . "name" .Values.api.name) | nindent 4 }} diff --git a/chart/templates/api/serviceaccount.yaml b/chart/templates/api/serviceaccount.yaml new file mode 100644 index 00000000..0b62d5fe --- /dev/null +++ b/chart/templates/api/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.api.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +automountServiceAccountToken: {{ .Values.api.serviceAccount.automount }} +metadata: + name: {{ include "kyoo.api.serviceAccountName" . }} + labels: + {{- include "kyoo.labels" (dict "context" . "component" .Values.api.name "name" .Values.api.name) | nindent 4 }} + {{- with .Values.api.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/chart/templates/back/pvc.yaml b/chart/templates/back/pvc.yaml deleted file mode 100644 index 191ea726..00000000 --- a/chart/templates/back/pvc.yaml +++ /dev/null @@ -1,25 +0,0 @@ -{{- if and .Values.back.persistence.enabled (not .Values.back.persistence.existingClaim) }} -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: {{ include "kyoo.backmetadata.fullname" . }} - labels: - {{- include "kyoo.labels" (dict "context" . "component" .Values.back.name "name" .Values.back.name) | nindent 4 }} - {{- with (mergeOverwrite (deepCopy .Values.global.persistentVolumeClaimAnnotations) .Values.back.persistence.annotations) }} - annotations: - {{- range $key, $value := . }} - {{ $key }}: {{ $value | quote }} - {{- end }} - {{- end }} -spec: - accessModes: - {{- range .Values.back.persistence.accessModes }} - - {{ . }} - {{- end }} - resources: - requests: - storage: {{ .Values.back.persistence.size }} - {{- if .Values.back.persistence.storageClass }} - storageClassName: {{ .Values.back.persistence.storageClass }} - {{- end }} -{{- end }} diff --git a/chart/templates/back/serviceaccount.yaml b/chart/templates/back/serviceaccount.yaml deleted file mode 100644 index 95e071f0..00000000 --- a/chart/templates/back/serviceaccount.yaml +++ /dev/null @@ -1,13 +0,0 @@ -{{- if .Values.back.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -automountServiceAccountToken: {{ .Values.back.serviceAccount.automount }} -metadata: - name: {{ include "kyoo.back.serviceAccountName" . }} - labels: - {{- include "kyoo.labels" (dict "context" . "component" .Values.back.name "name" .Values.back.name) | nindent 4 }} - {{- with .Values.back.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} diff --git a/chart/templates/front/deployment.yaml b/chart/templates/front/deployment.yaml index d424804b..7b379987 100644 --- a/chart/templates/front/deployment.yaml +++ b/chart/templates/front/deployment.yaml @@ -52,7 +52,7 @@ spec: {{- end }} env: - name: KYOO_URL - value: "http://{{ include "kyoo.back.fullname" . }}:5000/api" + value: "http://{{ include "kyoo.api.fullname" . }}:5000/api" {{- with (concat .Values.global.extraEnv .Values.front.kyoo_front.extraEnv) }} {{- toYaml . | nindent 12 }} {{- end }} diff --git a/chart/templates/scanner/deployment.yaml b/chart/templates/scanner/deployment.yaml index f6e79ba7..264d7dc8 100644 --- a/chart/templates/scanner/deployment.yaml +++ b/chart/templates/scanner/deployment.yaml @@ -61,7 +61,7 @@ spec: key: {{ .Values.kyoo.apikey.apikeyKey }} name: {{ .Values.kyoo.apikey.existingSecret }} - name: KYOO_URL - value: "http://{{ include "kyoo.back.fullname" . }}:5000/api" + value: "http://{{ include "kyoo.api.fullname" . }}:5000/api" - name: LIBRARY_LANGUAGES value: {{ .Values.kyoo.languages | quote }} {{- with (concat .Values.global.extraEnv .Values.scanner.kyoo_scanner.extraEnv) }} diff --git a/chart/templates/traefikproxy/configmap.yaml b/chart/templates/traefikproxy/configmap.yaml index 684aafef..dc590697 100644 --- a/chart/templates/traefikproxy/configmap.yaml +++ b/chart/templates/traefikproxy/configmap.yaml @@ -41,12 +41,12 @@ data: api: entryPoints: - web - service: back + service: api rule: "PathPrefix(`/api/`)" swagger: entryPoints: - web - service: back + service: api rule: "PathPrefix(`/swagger`)" scanner: entryPoints: @@ -63,10 +63,10 @@ data: authResponseHeaders: - Authorization services: - back: + api: loadBalancer: servers: - - url: http://{{ include "kyoo.back.fullname" . }}:5000/ + - url: http://{{ include "kyoo.api.fullname" . }}:5000/ front: loadBalancer: servers: diff --git a/chart/values.yaml b/chart/values.yaml index ffc9be0f..185360c5 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -143,6 +143,54 @@ contentdatabase: pinKey: tvdb_pin existingSecret: bigsecret +# api deployment configuration +api: + name: api + # kyoo_back container configuration + kyoo_api: + livenessProbe: {} + readinessProbe: {} + resources: {} + containerSecurityContext: {} + extraVolumeMounts: [] + extraArgs: [] + extraEnv: [] + image: + repository: ~ + tag: ~ + volumeMounts: [] + volumes: [] + replicaCount: 1 + # default to recreate for better user experience with ReadWriteOnce volumes + updateStrategy: + type: Recreate + podLabels: {} + deploymentAnnotations: {} + podAnnotations: {} + imagePullSecrets: [] + service: + annotations: {} + labels: {} + type: ClusterIP + serviceAccount: + create: true + automount: true + annotations: {} + name: ~ + extraContainers: [] + extraInitContainers: [] + extraVolumes: [] + # apimetadata + # user profile pictures + persistence: + enabled: true + size: 3Gi + annotations: {} + storageClass: "" + accessModes: + - ReadWriteOnce + existingClaim: "" + # auth deployment configuration auth: name: auth @@ -177,54 +225,6 @@ auth: extraInitContainers: [] extraVolumes: [] -# back deployment configuration -back: - name: back - # kyoo_back container configuration - kyoo_back: - livenessProbe: {} - readinessProbe: {} - resources: {} - containerSecurityContext: {} - extraVolumeMounts: [] - extraArgs: [] - extraEnv: [] - image: - repository: ~ - tag: ~ - volumeMounts: [] - volumes: [] - replicaCount: 1 - # default to recreate for better user experience with ReadWriteOnce volumes - updateStrategy: - type: Recreate - podLabels: {} - deploymentAnnotations: {} - podAnnotations: {} - imagePullSecrets: [] - service: - annotations: {} - labels: {} - type: ClusterIP - serviceAccount: - create: true - automount: true - annotations: {} - name: ~ - extraContainers: [] - extraInitContainers: [] - extraVolumes: [] - # backmetadata - # user profile pictures - persistence: - enabled: true - size: 3Gi - annotations: {} - storageClass: "" - accessModes: - - ReadWriteOnce - existingClaim: "" - # front deployment configuration front: name: front