adding front to the CI

adding frontend configmaps and envVars

optimizing docker-compose and DockerfIle
This commit is contained in:
Arsham Teymourı
2021-08-10 20:07:07 +03:00
parent ac20d3d845
commit 72311d9b61
12 changed files with 203 additions and 32 deletions
+7
View File
@@ -35,6 +35,13 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.backend.repository }}:{{ .Values.image.backend.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.backend.pullPolicy }}
{{- if .Values.envVars.core }}
env:
{{- range $key, $val := .Values.envVars.core }}
- name: {{ $key }}
value: {{ $val | quote }}
{{- end }}
{{- end }}
command:
- "telemetry_core"
args:
+29
View File
@@ -0,0 +1,29 @@
{{- if .Values.autoscaling.core.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: telemetry-core
labels:
{{- include "substrate-telemetry.labels" . | nindent 4 }}
telemetry-component: core
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: telemetry-core
minReplicas: {{ .Values.autoscaling.core.minReplicas }}
maxReplicas: {{ .Values.autoscaling.core.maxReplicas }}
metrics:
{{- if .Values.autoscaling.core.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.core.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.core.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.core.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
+21
View File
@@ -35,6 +35,13 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.envVars.frontend }}
env:
{{- range $key, $val := .Values.envVars.frontend }}
- name: {{ $key }}
value: {{ $val | quote }}
{{- end }}
{{- end }}
command:
- "telemetry_frontend"
args:
@@ -52,8 +59,22 @@ spec:
httpGet:
path: /health
port: http
volumeMounts:
- name: nginx
mountPath: "/etc/nginx/nginx.conf"
readOnly: true
- name: env-config
mountPath: "/usr/share/nginx/html/env-config.js"
readOnly: true
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: nginx
configMap:
name: frontend-nginx
- name: env-config
configMap:
name: frontend-env-config
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
+10
View File
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: frontend-env-config
data:
env-config.js: |
window.process_env = {
SUBSTRATE_TELEMETRY_URL: "ws://feed.telemetry.parity-stg.parity.io/feed",
SUBSTRATE_TELEMETRY_SAMPLE: "",
}
+29
View File
@@ -0,0 +1,29 @@
{{- if .Values.autoscaling.frontend.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: telemetry-frontend
labels:
{{- include "substrate-telemetry.labels" . | nindent 4 }}
telemetry-component: frontend
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: telemetry-frontend
minReplicas: {{ .Values.autoscaling.frontend.minReplicas }}
maxReplicas: {{ .Values.autoscaling.frontend.maxReplicas }}
metrics:
{{- if .Values.autoscaling.frontend.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.frontend.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.frontend.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.frontend.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
@@ -0,0 +1,37 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: frontend-nginx
data:
nginx.conf: |
user nginx;
worker_processes auto;
worker_rlimit_nofile 30000;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
server {
root /usr/share/nginx/html;
index index.html;
listen 80;
listen [::]:80;
server_name _;
}
events {
worker_connections 8000;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
include /etc/nginx/conf.d/*.conf;
}
+7
View File
@@ -35,6 +35,13 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.backend.repository }}:{{ .Values.image.backend.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.backend.pullPolicy }}
{{- if .Values.envVars.shard }}
env:
{{- range $key, $val := .Values.envVars.shard }}
- name: {{ $key }}
value: {{ $val | quote }}
{{- end }}
{{- end }}
command:
- "telemetry_shard"
args:
+7 -7
View File
@@ -1,4 +1,4 @@
{{- if .Values.autoscaling.enabled }}
{{- if .Values.autoscaling.shard.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
@@ -11,19 +11,19 @@ spec:
apiVersion: apps/v1
kind: Deployment
name: telemetry-shard
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
minReplicas: {{ .Values.autoscaling.shard.minReplicas }}
maxReplicas: {{ .Values.autoscaling.shard.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- if .Values.autoscaling.shard.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
targetAverageUtilization: {{ .Values.autoscaling.shard.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- if .Values.autoscaling.shard.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
targetAverageUtilization: {{ .Values.autoscaling.shard.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
+7
View File
@@ -23,6 +23,13 @@ imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
envVars:
shard: {}
core: {}
frontend:
SUBSTRATE_TELEMETRY_URL: telemetry-core
serviceAccount:
# Specifies whether a service account should be created
create: true