diff --git a/local/redis/dumps/dump.rdb b/local/redis/dumps/dump.rdb index 2e6c474..c74fcb8 100644 Binary files a/local/redis/dumps/dump.rdb and b/local/redis/dumps/dump.rdb differ diff --git a/opensource/templates/_helpers.tpl b/opensource/templates/_helpers.tpl new file mode 100644 index 0000000..92cf196 --- /dev/null +++ b/opensource/templates/_helpers.tpl @@ -0,0 +1,11 @@ +{{- define "minioService" -}} +{{ .Release.Name }}-minio +{{- end -}} + +{{- define "redisService" -}} +{{ .Release.Name }}-redis-service +{{- end -}} + +{{- define "mediaService" -}} +http://{{ .Release.Name }}-media-service +{{- end -}} \ No newline at end of file diff --git a/opensource/templates/backup-and-clean-job.yaml b/opensource/templates/backup-and-clean-job.yaml index 47bd2b1..2e3a143 100644 --- a/opensource/templates/backup-and-clean-job.yaml +++ b/opensource/templates/backup-and-clean-job.yaml @@ -3,7 +3,7 @@ apiVersion: batch/v1 kind: CronJob metadata: - name: backup-and-clean-cronjob-{{ .Values.version }} + name: {{ .Release.Name }}-backup-and-clean-cronjob-{{ .Values.version }} spec: schedule: '0 0 * * *' jobTemplate: diff --git a/opensource/templates/deployment.yaml b/opensource/templates/deployment.yaml index 5ce6738..b6d44cc 100644 --- a/opensource/templates/deployment.yaml +++ b/opensource/templates/deployment.yaml @@ -1,21 +1,21 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: media + name: {{ .Release.Name }}-media labels: - app: media + app: {{ .Release.Name }}-media spec: replicas: {{ .Values.hpa.replicaCountMin }} selector: matchLabels: - app: media + app: {{ .Release.Name }}-media template: metadata: labels: - app: media + app: {{ .Release.Name }}-media spec: containers: - - name: media-api + - name: {{ .Release.Name }}-media-api image: "{{ .Values.mediaProvider.imageName }}:{{ .Values.mediaProvider.imageVersion }}" resources: requests: @@ -76,7 +76,7 @@ spec: - name: NGINX_INGRESS value: '{{.Values.protocol}}://{{.Values.env}}{{.Values.domain}}' - name: IMAGE_SERVICE - value: "{{ default "http://media-service" .Values.mediaProvider.service }}" + value: "{{ include "mediaService" . }}" - name: API_PREFIX value: "{{ default "/palpatine" .Values.mediaProvider.apiPrefix }}" - name: USE_STRIPMETADATA @@ -104,11 +104,11 @@ spec: value: "{{ default "true" .Values.dev }}" - name: REDIS_SERVICE - value: "{{ default "redis-service" .Values.redis.service }}" + value: "{{ include "redisService" . }}" - name: DELEGATED_STORAGE_METHOD value: "{{ default "DISTANT_BACKEND" .Values.delegatedStorage.storageMethod }}" - name: DELEGATED_STORAGE_HOST - value: "{{ default "http://minio:9000" .Values.delegatedStorage.host }}" + value: "http://{{ include "minioService" . }}:{{ .Values.s3.port}}" - name: DELEGATED_STORAGE_READINESS_CHECK value: "{{ default "/minio/health/live" .Values.delegatedStorage.routes.readinessCheck }}" {{- if and (eq .Values.delegatedStorage.connect true) (eq .Values.delegatedStorage.storageMethod "DISTANT_BACKEND") }} @@ -126,7 +126,7 @@ spec: {{- if and (eq .Values.delegatedStorage.connect true) (eq .Values.delegatedStorage.storageMethod "S3") }} - name: S3_ENDPOINT - value: "{{ default "minio" .Values.s3.endpoint }}" + value: {{ include "minioService" . }} - name: S3_PORT value: "{{ default "9000" .Values.s3.port }}" - name: S3_ACCESS_KEY @@ -139,6 +139,6 @@ spec: volumes: - name: redis-storage persistentVolumeClaim: - claimName: redis-pv + claimName: {{ .Release.Name }}-redis-pv - name: logs emptyDir: { } \ No newline at end of file diff --git a/opensource/templates/media-ingress.yaml b/opensource/templates/media-ingress.yaml index 94dd93a..0a81aae 100644 --- a/opensource/templates/media-ingress.yaml +++ b/opensource/templates/media-ingress.yaml @@ -1,13 +1,19 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: api-ingress + name: {{ .Release.Name }}-api-ingress annotations: - nginx.ingress.kubernetes.io/default-backend: ingress-nginx-controller - nginx.ingress.kubernetes.io/use-regex: 'true' - nginx.ingress.kubernetes.io/proxy-body-size: '50m' + {{- range $key, $value := .Values.ingress.api.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} spec: - ingressClassName: nginx + ingressClassName: {{ .Values.ingress.api.className }} + {{- if .Values.ingress.api.tls }} + tls: + - hosts: + - {{ .Values.env }}.api{{ .Values.domain }} + secretName: {{ .Release.Name }}-api-tls-certificate + {{- end }} rules: - host: '{{.Values.env}}.api{{.Values.domain}}' http: @@ -16,6 +22,6 @@ spec: pathType: ImplementationSpecific backend: service: - name: media-service + name: {{ .Release.Name }}-media-service port: number: 80 diff --git a/opensource/templates/minio-dev.yaml b/opensource/templates/minio-dev.yaml index 3144fe7..a87408e 100644 --- a/opensource/templates/minio-dev.yaml +++ b/opensource/templates/minio-dev.yaml @@ -2,21 +2,21 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: minio-deployment + name: {{ .Release.Name }}-minio-deployment labels: - app: minio + app: {{ .Release.Name }}-minio spec: replicas: 1 selector: matchLabels: - app: minio + app: {{ .Release.Name }}-minio template: metadata: labels: - app: minio + app: {{ .Release.Name }}-minio spec: containers: - - name: minio + - name: {{ .Release.Name }}-minio image: minio/minio ports: - containerPort: 9000 @@ -34,13 +34,13 @@ spec: volumes: - name: minio-storage persistentVolumeClaim: - claimName: minio-pv-claim + claimName: {{ .Release.Name }}-minio-pv-claim --- apiVersion: v1 kind: Service metadata: - name: minio + name: {{ .Release.Name }}-minio spec: type: NodePort ports: @@ -53,13 +53,13 @@ spec: protocol: TCP name: console selector: - app: minio + app: {{ .Release.Name }}-minio --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: minio-ingress + name: {{ .Release.Name }}-minio-ingress annotations: kubernetes.io/ingress.class: nginx spec: @@ -72,16 +72,16 @@ spec: pathType: Prefix backend: service: - name: minio + name: {{ .Release.Name }}-minio port: name: console --- apiVersion: v1 kind: PersistentVolume metadata: - name: local-pv-minio + name: {{ .Release.Name }}-local-pv-minio labels: - type: minio + type: {{ .Release.Name }}-minio spec: capacity: storage: 5G @@ -105,7 +105,7 @@ spec: apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: minio-pv-claim + name: {{ .Release.Name }}-minio-pv-claim spec: accessModes: - ReadWriteMany @@ -115,5 +115,5 @@ spec: storageClassName: "{{.Values.mediaProvider.storage.storageClassName}}" selector: matchLabels: - type: minio + type: {{ .Release.Name }}-minio {{- end }} \ No newline at end of file diff --git a/opensource/templates/nginx/nginx-configmap.yaml b/opensource/templates/nginx/nginx-configmap.yaml index d00b9e8..4bd0b08 100644 --- a/opensource/templates/nginx/nginx-configmap.yaml +++ b/opensource/templates/nginx/nginx-configmap.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: nginx-configmap + name: {{ .Release.Name }}-nginx-configmap data: proxy-body-size: 10m nginx.conf: | @@ -26,7 +26,7 @@ data: proxy_cache_path /opt/bitnami/nginx/cache levels=1:2 keys_zone=zone1:10m max_size=1g inactive=24h use_temp_path=off; server { listen 8080; - server_name nginx; + server_name {{ .Release.Name }}-nginx; proxy_cache zone1; proxy_cache_valid any 1m; @@ -51,7 +51,7 @@ data: deny all; } add_header X-Cache-Status $upstream_cache_status; - proxy_pass http://nginx-purge-service; + proxy_pass http://{{ .Release.Name }}-nginx-purge-service; } location ~ ^{{ if hasKey .Values.mediaProvider "apiPrefix" }}{{ .Values.mediaProvider.apiPrefix }}{{ .Values.mediaProvider.routes.files.get }}{{ else }}{{ .Values.mediaProvider.routes.files.get }}{{ end }} { @@ -59,7 +59,7 @@ data: deny all; } add_header X-Cache-Status $upstream_cache_status; - proxy_pass http://nginx-purge-service; + proxy_pass http://{{ .Release.Name }}-nginx-purge-service; } location ~ /purge(/.*) { limit_except GET { @@ -68,7 +68,7 @@ data: proxy_cache_valid 200 302 0s; proxy_no_cache 1; proxy_cache_bypass 1; - proxy_pass http://nginx-purge-service; + proxy_pass http://{{ .Release.Name }}-nginx-purge-service; } location / { return 200; diff --git a/opensource/templates/nginx/nginx-deployment.yaml b/opensource/templates/nginx/nginx-deployment.yaml index 6cf5216..8482f85 100644 --- a/opensource/templates/nginx/nginx-deployment.yaml +++ b/opensource/templates/nginx/nginx-deployment.yaml @@ -1,21 +1,21 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: nginx + name: {{ .Release.Name }}-nginx labels: - app: nginx + app: {{ .Release.Name }}-nginx spec: replicas: 1 selector: matchLabels: - app: nginx + app: {{ .Release.Name }}-nginx template: metadata: labels: - app: nginx + app: {{ .Release.Name }}-nginx spec: containers: - - name: nginx + - name: {{ .Release.Name }}-nginx image: bitnami/nginx:latest ports: - containerPort: 8080 @@ -37,7 +37,7 @@ spec: emptyDir: {} - name: nginx-config-volume configMap: - name: nginx-configmap + name: {{ .Release.Name }}-nginx-configmap items: - key: nginx.conf path: nginx.conf diff --git a/opensource/templates/nginx/nginx-ingress.yaml b/opensource/templates/nginx/nginx-ingress.yaml index 949b1f8..da01dd6 100644 --- a/opensource/templates/nginx/nginx-ingress.yaml +++ b/opensource/templates/nginx/nginx-ingress.yaml @@ -1,34 +1,34 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: nginx-ingress + name: {{ .Release.Name }}-nginx-ingress annotations: - {{- range $key, $value := .Values.ingress.annotations }} + {{- range $key, $value := .Values.ingress.nginx.annotations }} {{ $key }}: {{ $value | quote }} {{- end }} spec: - ingressClassName: {{ .Values.ingress.className }} - {{- if .Values.ingress.tls }} + ingressClassName: {{ .Values.ingress.nginx.className }} + {{- if .Values.ingress.nginx.tls }} tls: - hosts: - {{ .Values.env }}{{ .Values.domain }} secretName: {{ .Release.Name }}-tls-certificate {{- end }} rules: - - host: '{{ .Values.env }}{{ .Values.domain }}' - http: - paths: - - path: {{ if hasKey .Values.mediaProvider "apiPrefix" }}{{ .Values.mediaProvider.apiPrefix }}/assets/media{{ else }}/assets/media{{ end }} - pathType: ImplementationSpecific - backend: - service: - name: nginx - port: - number: 80 - - path: {{ if hasKey .Values.mediaProvider "apiPrefix" }}{{ .Values.mediaProvider.apiPrefix }}/catalog{{ else }}/catalog{{ end }} - pathType: ImplementationSpecific - backend: - service: - name: nginx - port: - number: 80 + - host: '{{ .Values.env }}{{ .Values.domain }}' + http: + paths: + - path: {{ if hasKey .Values.mediaProvider "apiPrefix" }}{{ .Values.mediaProvider.apiPrefix }}/assets/media{{ else }}/assets/media{{ end }} + pathType: ImplementationSpecific + backend: + service: + name: nginx + port: + number: 80 + - path: {{ if hasKey .Values.mediaProvider "apiPrefix" }}{{ .Values.mediaProvider.apiPrefix }}/catalog{{ else }}/catalog{{ end }} + pathType: ImplementationSpecific + backend: + service: + name: nginx + port: + number: 80 diff --git a/opensource/templates/nginx/nginx-purge-configmap.yaml b/opensource/templates/nginx/nginx-purge-configmap.yaml index 52f52c1..3deeed6 100644 --- a/opensource/templates/nginx/nginx-purge-configmap.yaml +++ b/opensource/templates/nginx/nginx-purge-configmap.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: nginx-purge-configmap + name: {{ .Release.Name }}-nginx-purge-configmap data: proxy-body-size: 10m nginx.conf: | @@ -26,7 +26,7 @@ data: proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=zone2:10m max_size=1g inactive=24h use_temp_path=off; server { listen 8081; - server_name nginx-purge; + server_name {{ .Release.Name }}-nginx-purge; proxy_cache zone2; proxy_cache_key $request_uri; @@ -55,7 +55,7 @@ data: proxy_no_cache 1; proxy_cache_bypass 1; add_header X-Cache-Status $upstream_cache_status; - proxy_pass {{ .Values.mediaProvider.service }}; + proxy_pass {{ include "mediaService" . }}; } location ~ ^{{ if hasKey .Values.mediaProvider "apiPrefix" }}{{ .Values.mediaProvider.apiPrefix }}{{ .Values.mediaProvider.routes.files.get }}{{ else }}{{ .Values.mediaProvider.routes.files.get }}{{ end }} { @@ -63,7 +63,7 @@ data: deny all; } add_header X-Cache-Status $upstream_cache_status; - proxy_pass {{ .Values.mediaProvider.service }}; + proxy_pass {{ include "mediaService" . }}; } location ~ /purge(/.*) { limit_except GET { diff --git a/opensource/templates/nginx/nginx-purge-deployment.yaml b/opensource/templates/nginx/nginx-purge-deployment.yaml index be983c4..68a7987 100644 --- a/opensource/templates/nginx/nginx-purge-deployment.yaml +++ b/opensource/templates/nginx/nginx-purge-deployment.yaml @@ -1,21 +1,21 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: nginx-purge + name: {{ .Release.Name }}-nginx-purge labels: - app: nginx-purge + app: {{ .Release.Name }}-nginx-purge spec: replicas: 1 selector: matchLabels: - app: nginx-purge + app: {{ .Release.Name }}-nginx-purge template: metadata: labels: - app: nginx-purge + app: {{ .Release.Name }}-nginx-purge spec: containers: - - name: nginx-purge + - name: {{ .Release.Name }}-nginx-purge image: emcniece/nginx-cache-purge:1.13-alpine ports: - containerPort: 8081 @@ -41,7 +41,7 @@ spec: emptyDir: {} - name: nginx-config-volume configMap: - name: nginx-purge-configmap + name: "{{ .Release.Name }}-nginx-purge-configmap" items: - key: nginx.conf path: nginx.conf diff --git a/opensource/templates/nginx/nginx-purge-service.yaml b/opensource/templates/nginx/nginx-purge-service.yaml index 1462707..ce38326 100644 --- a/opensource/templates/nginx/nginx-purge-service.yaml +++ b/opensource/templates/nginx/nginx-purge-service.yaml @@ -1,9 +1,9 @@ apiVersion: v1 kind: Service metadata: - name: nginx-purge-service + name: {{ .Release.Name }}-nginx-purge-service labels: - app: nginx-purge + app: {{ .Release.Name }}-nginx-purge spec: type: NodePort ports: @@ -12,4 +12,4 @@ spec: targetPort: 8081 port: 80 selector: - app: nginx-purge + app: {{ .Release.Name }}-nginx-purge diff --git a/opensource/templates/nginx/nginx-service.yaml b/opensource/templates/nginx/nginx-service.yaml index 60bddb5..91b594b 100644 --- a/opensource/templates/nginx/nginx-service.yaml +++ b/opensource/templates/nginx/nginx-service.yaml @@ -1,9 +1,9 @@ apiVersion: v1 kind: Service metadata: - name: nginx + name: {{ .Release.Name }}-nginx labels: - app: nginx + app: {{ .Release.Name }}-nginx spec: type: NodePort ports: @@ -12,4 +12,4 @@ spec: targetPort: 8080 port: 80 selector: - app: nginx + app: {{ .Release.Name }}-nginx diff --git a/opensource/templates/pv-redis.yaml b/opensource/templates/pv-redis.yaml index b0f663f..e5b468e 100644 --- a/opensource/templates/pv-redis.yaml +++ b/opensource/templates/pv-redis.yaml @@ -2,9 +2,9 @@ apiVersion: v1 kind: PersistentVolume metadata: - name: local-pv-redis + name: {{ .Release.Name }}-local-pv-redis labels: - type: redis + type: {{ .Release.Name }}-redis spec: capacity: storage: 5G @@ -28,7 +28,7 @@ spec: apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: redis-pv + name: {{ .Release.Name }}-redis-pv annotations: volume-expander-operator.redhat-cop.io/autoexpand: "true" volume-expander-operator.redhat-cop.io/polling-frequency: "1m" diff --git a/opensource/templates/redis-deployment.yaml b/opensource/templates/redis-deployment.yaml index 7974979..0462e3c 100644 --- a/opensource/templates/redis-deployment.yaml +++ b/opensource/templates/redis-deployment.yaml @@ -1,19 +1,19 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: redis-deployment + name: {{ .Release.Name }}-redis-deployment spec: replicas: 1 selector: matchLabels: - app: redis + app: {{ .Release.Name }}-redis template: metadata: labels: - app: redis + app: {{ .Release.Name }}-redis spec: containers: - - name: redis + - name: {{ .Release.Name }}-redis image: bitnami/redis:7.0.15-debian-12-r20 command: - 'redis-server' @@ -36,4 +36,4 @@ spec: volumes: - name: redis-storage persistentVolumeClaim: - claimName: redis-pv + claimName: {{ .Release.Name }}-redis-pv diff --git a/opensource/templates/redis-service.yaml b/opensource/templates/redis-service.yaml index abf9b71..13b19fa 100644 --- a/opensource/templates/redis-service.yaml +++ b/opensource/templates/redis-service.yaml @@ -1,10 +1,10 @@ apiVersion: v1 kind: Service metadata: - name: redis-service + name: {{ .Release.Name }}-redis-service spec: selector: - app: redis + app: {{ .Release.Name }}-redis ports: - protocol: TCP port: 6379 diff --git a/opensource/templates/redisinsight-deployment-service.yaml b/opensource/templates/redisinsight-deployment-service.yaml index 1279e45..105f2bc 100644 --- a/opensource/templates/redisinsight-deployment-service.yaml +++ b/opensource/templates/redisinsight-deployment-service.yaml @@ -2,19 +2,19 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: redisinsight-deployment + name: {{ .Release.Name }}-redisinsight-deployment spec: replicas: 1 selector: matchLabels: - app: redisinsight + app: {{ .Release.Name }}-redisinsight template: metadata: labels: - app: redisinsight + app: {{ .Release.Name }}-redisinsight spec: containers: - - name: redisinsight + - name: {{ .Release.Name }}-redisinsight image: redis/redisinsight:latest ports: - containerPort: 5540 @@ -22,10 +22,10 @@ spec: apiVersion: v1 kind: Service metadata: - name: redisinsight-service + name: {{ .Release.Name }}-redisinsight-service spec: selector: - app: redisinsight + app: {{ .Release.Name }}-redisinsight ports: - protocol: TCP port: 5540 diff --git a/opensource/templates/service.yaml b/opensource/templates/service.yaml index 564610d..504c9a6 100644 --- a/opensource/templates/service.yaml +++ b/opensource/templates/service.yaml @@ -1,9 +1,9 @@ apiVersion: v1 kind: Service metadata: - name: media-service + name: {{ .Release.Name }}-media-service labels: - app: media + app: {{ .Release.Name }}-media spec: type: NodePort ports: @@ -12,4 +12,4 @@ spec: targetPort: 3001 port: 80 selector: - app: media + app: {{ .Release.Name }}-media diff --git a/opensource/values.yaml b/opensource/values.yaml index eafebe4..7946ddc 100644 --- a/opensource/values.yaml +++ b/opensource/values.yaml @@ -1,8 +1,12 @@ ingress: - className: nginx - annotations: - kubernetes.io/ingress.class: nginx - + nginx: + className: nginx + annotations: + kubernetes.io/ingress.class: nginx + api: + className: nginx + annotations: + kubernetes.io/ingress.class: nginx redis: service: redis-service dumpFolderPath: '/dumps' @@ -93,5 +97,4 @@ hpa: protocol: 'http' env: 'media-service' domain: '.media' -NAMESPACES_ALLOWED: 'DEV' -version: '1.0.6' +NAMESPACES_ALLOWED: 'DEV' \ No newline at end of file diff --git a/src/api/server.ts b/src/api/server.ts index 4ee76b5..a8dd08e 100644 --- a/src/api/server.ts +++ b/src/api/server.ts @@ -11,6 +11,7 @@ const port = parseInt(process.env.PORT, 10) || 3001; const standalone = process.env.DELEGATED_STORAGE_METHOD === 'STANDALONE'; const checkAccessToBackup = async () => { + console.log('CHECK ACCESS BACKUP :::', process.env.DELEGATED_STORAGE_HOST) const backupUrl = `${process.env.DELEGATED_STORAGE_HOST}${process.env.DELEGATED_STORAGE_READINESS_CHECK}`; const checkBackup = await fetch(backupUrl); if (checkBackup.status !== 200) {