From 7dcd9c99a63911d17e75cf14835ec100af80baa7 Mon Sep 17 00:00:00 2001 From: Rajesh Rajendran Date: Thu, 23 Jun 2022 15:53:18 +0000 Subject: [PATCH] Move frontend as a separate container (#553) * chore(frontend): build dockerimage for frontend * chore(helm): remove frontend files from minio. Signed-off-by: rjshrjndrn * chore(helm): Adding frontend chart Signed-off-by: rjshrjndrn * chore(helm): remove grafana ingress from community charts Signed-off-by: rjshrjndrn * chore(helm): removing minio-frontend ingress Signed-off-by: rjshrjndrn * fix(helm): ingress rewrite Signed-off-by: rjshrjndrn * chore(build): give priority to env image tag Signed-off-by: rjshrjndrn * chore(frontend): adding nginx.conf for frontend container Signed-off-by: rjshrjndrn * chore(helm): disable minio if not used Signed-off-by: rjshrjndrn --- frontend/.dockerignore | 7 ++ frontend/Dockerfile | 10 ++ frontend/build.sh | 10 +- frontend/nginx.conf | 9 ++ scripts/helmcharts/databases/Chart.yaml | 4 + scripts/helmcharts/databases/values.yaml | 5 +- .../openreplay/charts/frontend/.helmignore | 23 ++++ .../openreplay/charts/frontend/Chart.yaml | 24 ++++ .../charts/frontend/templates/NOTES.txt | 22 ++++ .../charts/frontend/templates/_helpers.tpl | 62 +++++++++++ .../charts/frontend/templates/deployment.yaml | 103 ++++++++++++++++++ .../charts/frontend/templates/hpa.yaml | 28 +++++ .../charts/frontend/templates/ingress.yaml | 38 +++++++ .../charts/frontend/templates/service.yaml | 17 +++ .../frontend/templates/serviceMonitor.yaml | 18 +++ .../frontend/templates/serviceaccount.yaml | 12 ++ .../templates/tests/test-connection.yaml | 15 +++ .../openreplay/charts/frontend/values.yaml | 99 +++++++++++++++++ .../charts/http/templates/ingress.yaml | 61 +---------- scripts/helmcharts/openreplay/files/minio.sh | 4 - scripts/helmcharts/vars.yaml | 6 +- 21 files changed, 506 insertions(+), 71 deletions(-) create mode 100644 frontend/.dockerignore create mode 100644 frontend/Dockerfile create mode 100644 frontend/nginx.conf create mode 100644 scripts/helmcharts/openreplay/charts/frontend/.helmignore create mode 100644 scripts/helmcharts/openreplay/charts/frontend/Chart.yaml create mode 100644 scripts/helmcharts/openreplay/charts/frontend/templates/NOTES.txt create mode 100644 scripts/helmcharts/openreplay/charts/frontend/templates/_helpers.tpl create mode 100644 scripts/helmcharts/openreplay/charts/frontend/templates/deployment.yaml create mode 100644 scripts/helmcharts/openreplay/charts/frontend/templates/hpa.yaml create mode 100644 scripts/helmcharts/openreplay/charts/frontend/templates/ingress.yaml create mode 100644 scripts/helmcharts/openreplay/charts/frontend/templates/service.yaml create mode 100644 scripts/helmcharts/openreplay/charts/frontend/templates/serviceMonitor.yaml create mode 100644 scripts/helmcharts/openreplay/charts/frontend/templates/serviceaccount.yaml create mode 100644 scripts/helmcharts/openreplay/charts/frontend/templates/tests/test-connection.yaml create mode 100644 scripts/helmcharts/openreplay/charts/frontend/values.yaml diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 000000000..8afa1c5f0 --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1,7 @@ +node_modules +npm-debug.log +.git +.cache +**/build.sh +**/build_*.sh +**/*deploy.sh diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 000000000..09f06a787 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,10 @@ +from node:14-stretch-slim AS builder +workdir /work +COPY . . +RUN yarn && yarn build + +FROM nginx:alpine +LABEL maintainer=Rajesh + +COPY --from=builder /work/public /var/www/openreplay +COPY nginx.conf /etc/nginx/conf.d/default.conf diff --git a/frontend/build.sh b/frontend/build.sh index ef07084d5..90b4d0a66 100644 --- a/frontend/build.sh +++ b/frontend/build.sh @@ -5,9 +5,10 @@ # ee: build for enterprise edition. # Default will be OSS build. -# Usage: bash build.sh +# Example +# Usage: IMAGE_TAG=latest DOCKER_REPO=myDockerHubID bash build.sh -git_sha1=$(git rev-parse HEAD) +git_sha1=${IMAGE_TAG:-$(git rev-parse HEAD)} ee="false" check_prereq() { which docker || { @@ -20,7 +21,10 @@ check_prereq() { function build(){ cp .env.sample .env # Run docker as the same user, else we'll run in to permission issues. - docker run --rm -v /etc/passwd:/etc/passwd -u `id -u`:`id -g` -v $(pwd):/home/${USER} -w /home/${USER} --name node_build node:14-stretch-slim /bin/bash -c "yarn && yarn build" + docker build -t ${DOCKER_REPO:-'local'}/frontend:${git_sha1} --platform linux/amd64 --build-arg SERVICE_NAME=$image . + [[ $PUSH_IMAGE -eq 1 ]] && { + docker push ${DOCKER_REPO:-'local'}/frontend:${git_sha1} + } echo "frotend build completed" } diff --git a/frontend/nginx.conf b/frontend/nginx.conf new file mode 100644 index 000000000..499065087 --- /dev/null +++ b/frontend/nginx.conf @@ -0,0 +1,9 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + root /var/www/openreplay; + index index.html; + location / { + try_files $uri $uri/ =404; + } +} diff --git a/scripts/helmcharts/databases/Chart.yaml b/scripts/helmcharts/databases/Chart.yaml index 24472a68f..be146afe5 100644 --- a/scripts/helmcharts/databases/Chart.yaml +++ b/scripts/helmcharts/databases/Chart.yaml @@ -24,6 +24,10 @@ version: 0.1.0 appVersion: "1.16.0" dependencies: + - name: minio + repository: file://charts/minio + version: 3.7.4 + condition: minio.enabled - name: kafka repository: file://charts/kafka version: 11.8.6 diff --git a/scripts/helmcharts/databases/values.yaml b/scripts/helmcharts/databases/values.yaml index 6b106e15a..d2bacfba3 100644 --- a/scripts/helmcharts/databases/values.yaml +++ b/scripts/helmcharts/databases/values.yaml @@ -99,9 +99,6 @@ redis: cpu: 100m memory: 128Mi -minio: - enabled: true - postgresql: # postgresqlPassword: asayerPostgres fullnameOverride: postgresql @@ -121,6 +118,7 @@ minio: # accessKey: "{{ minio_access_key }}" # secretKey: "{{ minio_secret_key }}" fullnameOverride: minio + enabled: true resources: limits: cpu: 256m @@ -142,4 +140,3 @@ clickhouse: postgreql: enabled: true - diff --git a/scripts/helmcharts/openreplay/charts/frontend/.helmignore b/scripts/helmcharts/openreplay/charts/frontend/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/frontend/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/scripts/helmcharts/openreplay/charts/frontend/Chart.yaml b/scripts/helmcharts/openreplay/charts/frontend/Chart.yaml new file mode 100644 index 000000000..163da9579 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/frontend/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: frontend +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (frontends://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +AppVersion: "v1.6.0" diff --git a/scripts/helmcharts/openreplay/charts/frontend/templates/NOTES.txt b/scripts/helmcharts/openreplay/charts/frontend/templates/NOTES.txt new file mode 100644 index 000000000..7bb6ae729 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/frontend/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + frontend{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "frontend.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo frontend://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "frontend.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "frontend.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo frontend://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "frontend.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit frontend://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/scripts/helmcharts/openreplay/charts/frontend/templates/_helpers.tpl b/scripts/helmcharts/openreplay/charts/frontend/templates/_helpers.tpl new file mode 100644 index 000000000..92c6c3b2d --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/frontend/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "frontend.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 "frontend.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 "frontend.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "frontend.labels" -}} +helm.sh/chart: {{ include "frontend.chart" . }} +{{ include "frontend.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "frontend.selectorLabels" -}} +app.kubernetes.io/name: {{ include "frontend.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "frontend.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "frontend.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/scripts/helmcharts/openreplay/charts/frontend/templates/deployment.yaml b/scripts/helmcharts/openreplay/charts/frontend/templates/deployment.yaml new file mode 100644 index 000000000..d4805b398 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/frontend/templates/deployment.yaml @@ -0,0 +1,103 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "frontend.fullname" . }} + labels: + {{- include "frontend.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "frontend.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "frontend.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "frontend.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + {{- if .Values.global.enterpriseEditionLicense }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}-ee" + {{- else }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + {{- end }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if .Values.healthCheck}} + {{- .Values.healthCheck | toYaml | nindent 10}} + {{- end}} + env: + - name: AWS_ACCESS_KEY_ID + value: {{ .Values.global.s3.accessKey }} + - name: AWS_SECRET_ACCESS_KEY + value: {{ .Values.global.s3.secretKey }} + - name: AWS_REGION + value: '{{ .Values.global.s3.region }}' + - name: LICENSE_KEY + value: '{{ .Values.global.enterpriseEditionLicense }}' + - name: REDIS_STRING + value: '{{ .Values.global.redis.redisHost }}:{{ .Values.global.redis.redisPort }}' + - name: KAFKA_SERVERS + value: '{{ .Values.global.kafka.kafkaHost }}:{{ .Values.global.kafka.kafkaPort }}' + - name: KAFKA_USE_SSL + value: '{{ .Values.global.kafka.kafkaUseSsl }}' + - name: POSTGRES_STRING + value: 'postgres://{{ .Values.global.postgresql.postgresqlUser }}:{{ .Values.global.postgresql.postgresqlPassword }}@{{ .Values.global.postgresql.postgresqlHost }}:{{ .Values.global.postgresql.postgresqlPort }}/{{ .Values.global.postgresql.postgresqlDatabase }}' + # We need to check what is the object store endpoint. + # There can be 4 options + # 1. Using minio inside kube clster + # 2. Using minio managed external cluster, like aws minio offering + # 3. Using GCP or other object stores compatible with s3 apis + # 4. Using AWS itself. + # AWS uses bucketname.endpoint/object while others use endpoint/bucketname/object + - name: ASSETS_ORIGIN + {{- if eq .Values.global.s3.endpoint "frontend://minio.db.svc.cluster.local:9000" }} + # Local minio Installation + value: 'frontends://{{ .Values.global.domainName }}/{{.Values.global.s3.assetsBucket}}' + {{- else if contains "amazonaws.com" .Values.global.s3.endpoint }} + # AWS S3 + # Ref: frontends://stackoverflow.com/questions/53634583/go-template-split-string-by-delimiter + # We need frontends://bucketname.s3endpoint + value: {{ (split "://" .Values.global.s3.endpoint)._0 }}://{{.Values.global.s3.assetsBucket}}.{{ (split "://" .Values.global.s3.endpoint)._1 }} + {{- else }} + # S3 compatible storage + value: '{{ .Values.global.s3.endpoint }}/{{.Values.global.s3.assetsBucket}}' + {{- end }} + {{- range $key, $val := .Values.env }} + - name: {{ $key }} + value: '{{ $val }}' + {{- end}} + ports: + {{- range $key, $val := .Values.service.ports }} + - name: {{ $key }} + containerPort: {{ $val }} + protocol: TCP + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/scripts/helmcharts/openreplay/charts/frontend/templates/hpa.yaml b/scripts/helmcharts/openreplay/charts/frontend/templates/hpa.yaml new file mode 100644 index 000000000..f1ffdc14a --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/frontend/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "frontend.fullname" . }} + labels: + {{- include "frontend.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "frontend.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/scripts/helmcharts/openreplay/charts/frontend/templates/ingress.yaml b/scripts/helmcharts/openreplay/charts/frontend/templates/ingress.yaml new file mode 100644 index 000000000..b1d67bb00 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/frontend/templates/ingress.yaml @@ -0,0 +1,38 @@ +{{- if .Values.ingress.enabled }} +{{- $fullName := include "frontend.fullname" . -}} +{{- $svcPort := .Values.service.ports.frontend -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "frontend.labels" . | nindent 4 }} + annotations: + {{- with .Values.ingress.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} + nginx.ingress.kubernetes.io/configuration-snippet: | + index /index.html; + rewrite ^((?!.(js|css|png|svg|jpg|woff|woff2)).)*$ /index.html break; + proxy_intercept_errors on; # see frontend://nginx.org/en/docs/frontend/ngx_frontend_proxy_module.html#proxy_intercept_errors + error_page 404 =200 /index.html; +spec: + ingressClassName: "{{ tpl .Values.ingress.className . }}" + tls: + - hosts: + - {{ .Values.global.domainName }} + {{- if .Values.ingress.tls.secretName}} + secretName: {{ .Values.ingress.tls.secretName }} + {{- end}} + rules: + - host: {{ .Values.global.domainName }} + http: + paths: + - pathType: Prefix + backend: + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + path: /(.*) +{{- end }} diff --git a/scripts/helmcharts/openreplay/charts/frontend/templates/service.yaml b/scripts/helmcharts/openreplay/charts/frontend/templates/service.yaml new file mode 100644 index 000000000..c94d62e2d --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/frontend/templates/service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "frontend.fullname" . }} + labels: + {{- include "frontend.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + {{- range $key, $val := .Values.service.ports }} + - port: {{ $val }} + targetPort: {{ $key }} + protocol: TCP + name: {{ $key }} + {{- end}} + selector: + {{- include "frontend.selectorLabels" . | nindent 4 }} diff --git a/scripts/helmcharts/openreplay/charts/frontend/templates/serviceMonitor.yaml b/scripts/helmcharts/openreplay/charts/frontend/templates/serviceMonitor.yaml new file mode 100644 index 000000000..6b675f811 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/frontend/templates/serviceMonitor.yaml @@ -0,0 +1,18 @@ +{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) ( .Values.serviceMonitor.enabled ) }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "frontend.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "frontend.labels" . | nindent 4 }} + {{- if .Values.serviceMonitor.additionalLabels }} + {{- toYaml .Values.serviceMonitor.additionalLabels | nindent 4 }} + {{- end }} +spec: + endpoints: + {{- .Values.serviceMonitor.scrapeConfigs | toYaml | nindent 4 }} + selector: + matchLabels: + {{- include "frontend.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/scripts/helmcharts/openreplay/charts/frontend/templates/serviceaccount.yaml b/scripts/helmcharts/openreplay/charts/frontend/templates/serviceaccount.yaml new file mode 100644 index 000000000..cc6490911 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/frontend/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "frontend.serviceAccountName" . }} + labels: + {{- include "frontend.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/scripts/helmcharts/openreplay/charts/frontend/templates/tests/test-connection.yaml b/scripts/helmcharts/openreplay/charts/frontend/templates/tests/test-connection.yaml new file mode 100644 index 000000000..372ac5eba --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/frontend/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "frontend.fullname" . }}-test-connection" + labels: + {{- include "frontend.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "frontend.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/scripts/helmcharts/openreplay/charts/frontend/values.yaml b/scripts/helmcharts/openreplay/charts/frontend/values.yaml new file mode 100644 index 000000000..aebacae82 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/frontend/values.yaml @@ -0,0 +1,99 @@ +# Default values for openreplay. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: rg.fr-par.scw.cloud/foss/frontend + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "frontend" +fullnameOverride: "frontend-openreplay" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + ports: + frontend: 80 + +serviceMonitor: + enabled: true + additionalLabels: + release: monitoring + scrapeConfigs: + - port: metrics + honorLabels: true + interval: 15s + path: /metrics + scheme: frontend + scrapeTimeout: 10s + +ingress: + enabled: true + className: "{{ .Values.global.ingress.controller.ingressClassResource.name }}" + annotations: + cert-manager.io/cluster-issuer: "letsencrypt-prod" + nginx.ingress.kubernetes.io/proxy-connect-timeout: "120" + nginx.ingress.kubernetes.io/proxy-send-timeout: "300" + nginx.ingress.kubernetes.io/proxy-read-timeout: "300" + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + tls: + secretName: openreplay-ssl + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 5 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +env: + TOKEN_SECRET: secret_token_string # TODO: generate on buld + S3_BUCKET_IOS_IMAGES: sessions-mobile-assets + CACHE_ASSETS: true + HTTP_PORT: 80 + + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/scripts/helmcharts/openreplay/charts/http/templates/ingress.yaml b/scripts/helmcharts/openreplay/charts/http/templates/ingress.yaml index fa719e5c0..7dc3368b3 100644 --- a/scripts/helmcharts/openreplay/charts/http/templates/ingress.yaml +++ b/scripts/helmcharts/openreplay/charts/http/templates/ingress.yaml @@ -35,6 +35,7 @@ spec: path: /ingest/(.*) {{- end }} +{{- if .Values.global.minio.enabled }} ## TODO: ## Frontend service from minio will be migrated to nginx atomic container. ## This ingress is just a workaround. @@ -60,62 +61,4 @@ spec: tls: - hosts: - {{ .Values.global.domainName }} ---- -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: minio-frontend - namespace: db - annotations: - nginx.ingress.kubernetes.io/rewrite-target: /frontend/$1 - nginx.ingress.kubernetes.io/configuration-snippet: | - index /index.html; - rewrite ^((?!.(js|css|png|svg|jpg|woff|woff2)).)*$ /frontend/index.html break; - proxy_intercept_errors on; # see http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_intercept_errors - error_page 404 =200 /index.html; -spec: - ingressClassName: "{{ tpl .Values.ingress.className . }}" - rules: - - host: {{ .Values.global.domainName }} - http: - paths: - - pathType: Prefix - backend: - service: - name: minio - port: - number: 9000 - path: /(.*) - tls: - - hosts: - - {{ .Values.global.domainName }} - {{- if .Values.ingress.tls.secretName}} - secretName: {{ .Values.ingress.tls.secretName }} - {{- end}} ---- -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: grafana - namespace: monitoring - annotations: - nginx.ingress.kubernetes.io/rewrite-target: /$1 -spec: - ingressClassName: "{{ tpl .Values.ingress.className . }}" - rules: - - host: {{ .Values.global.domainName }} - http: - paths: - - pathType: Prefix - backend: - service: - name: monitoring-grafana - port: - number: 80 - path: /grafana/(.*) - tls: - - hosts: - - {{ .Values.global.domainName }} - {{- if .Values.ingress.tls.secretName}} - secretName: {{ .Values.ingress.tls.secretName }} - {{- end}} +{{- end }} diff --git a/scripts/helmcharts/openreplay/files/minio.sh b/scripts/helmcharts/openreplay/files/minio.sh index 903168b1b..055bfd83e 100644 --- a/scripts/helmcharts/openreplay/files/minio.sh +++ b/scripts/helmcharts/openreplay/files/minio.sh @@ -36,10 +36,6 @@ mc mb minio/frontend || true mc policy set download minio/frontend || true mc policy set download minio/sessions-assets || true mc policy set download minio/static || true - -curl -L https://github.com/openreplay/openreplay/releases/download/v${CHART_APP_VERSION}/frontend.tar.gz -O -tar -xf frontend.tar.gz -mc cp --recursive frontend/ minio/frontend/ } # /bin/bash kafka.sh migrate $migration_versions diff --git a/scripts/helmcharts/vars.yaml b/scripts/helmcharts/vars.yaml index 5bface1cf..531b46fea 100644 --- a/scripts/helmcharts/vars.yaml +++ b/scripts/helmcharts/vars.yaml @@ -47,7 +47,10 @@ redis: &redis redisHost: "redis-master.db.svc.cluster.local" redisPort: "6379" -minio: +minio: &minio + # If you have extrenal s3 storage, like AWS, or GCP + # Disable it. + enabled: true global: minio: # For generating passwords @@ -88,6 +91,7 @@ global: postgresql: *postgres kafka: *kafka redis: *redis + minio: *minio s3: region: "us-east-1" endpoint: "http://minio.db.svc.cluster.local:9000"