diff --git a/HelmChart/Public/oneuptime/templates/ingestor.yaml b/HelmChart/Public/oneuptime/templates/ingestor.yaml index 08b6b5cb53..55c634ff69 100644 --- a/HelmChart/Public/oneuptime/templates/ingestor.yaml +++ b/HelmChart/Public/oneuptime/templates/ingestor.yaml @@ -1,8 +1,81 @@ # OneUptime ingestor Deployment -{{- $ingestorPorts := dict "port" $.Values.port.ingestor -}} -{{- $ingestorEnv := dict "PORT" $.Values.port.ingestor -}} -{{- $ingestorDeploymentArgs :=dict "IsServer" true "ServiceName" "ingestor" "Ports" $ingestorPorts "Release" $.Release "Values" $.Values "Env" $ingestorEnv -}} -{{- include "oneuptime.deployment" $ingestorDeploymentArgs }} + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ printf "%s-%s" $.Release.Name "ingestor" }} + namespace: {{ $.Release.Namespace }} + labels: + app: {{ printf "%s-%s" $.Release.Name "ingestor" }} + app.kubernetes.io/part-of: oneuptime + app.kubernetes.io/managed-by: Helm + appname: oneuptime + date: "{{ now | unixEpoch }}" +spec: + selector: + matchLabels: + app: {{ printf "%s-%s" $.Release.Name "ingestor" }} + replicas: {{ $.Values.deployment.replicaCount }} + template: + metadata: + labels: + app: {{ printf "%s-%s" $.Release.Name "ingestor" }} + date: "{{ now | unixEpoch }}" + appname: oneuptime + spec: + volumes: + - name: greenlockrc + emptyDir: + sizeLimit: "1Gi" + {{- if $.Values.podSecurityContext }} + securityContext: {{- $.Values.podSecurityContext | toYaml | nindent 8 }} + {{- end }} + {{- if $.Values.affinity }} + affinity: {{- $.Values.affinity | toYaml | nindent 8 }} + {{- end }} + {{- if $.Values.tolerations }} + tolerations: {{- $.Values.tolerations | toYaml | nindent 8 }} + {{- end }} + {{- if $.Values.nodeSelector }} + nodeSelector: {{- $.Values.nodeSelector | toYaml | nindent 8 }} + {{- end }} + containers: + - image: {{ printf "%s/%s/%s:%s" $.Values.image.registry $.Values.image.repository "ingestor" $.Values.image.tag }} + name: {{ printf "%s-%s" $.Release.Name "ingestor" }} + # Liveness probe + livenessProbe: + httpGet: + path: /status/live + port: {{ $.Values.port.ingestor }} + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 30 + # Readyness Probe + readinessProbe: + httpGet: + path: /status/ready + port: {{ $.Values.port.ingestor }} + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 30 + {{- if $.Values.containerSecurityContext }} + securityContext: {{- $.Values.containerSecurityContext | toYaml | nindent 12 }} + {{- end }} + imagePullPolicy: {{ $.Values.image.pullPolicy }} + env: + {{- include "oneuptime.env.common" . | nindent 12 }} + {{- include "oneuptime.env.commonServer" . | nindent 12 }} + {{- include "oneuptime.env.oneuptimeSecret" . | nindent 12 }} + - name: OPENTELEMETRY_EXPORTER_OTLP_HEADERS + value: {{ $.Values.openTelemetryExporter.headers.ingestor }} + - name: PORT + value: {{ $.Values.port.ingestor | quote }} + ports: + - containerPort: {{ $.Values.port.ingestor }} + protocol: TCP + name: http + restartPolicy: {{ $.Values.image.restartPolicy }} + --- # OneUptime ingestor Service diff --git a/HelmChart/Public/oneuptime/templates/nginx.yaml b/HelmChart/Public/oneuptime/templates/nginx.yaml index ffe15fd55b..54695a5213 100644 --- a/HelmChart/Public/oneuptime/templates/nginx.yaml +++ b/HelmChart/Public/oneuptime/templates/nginx.yaml @@ -1,13 +1,102 @@ # OneUptime nginx Deployment -{{- $runDir := dict "SizeLimit" "1Gi" "MountPath" "/var/run" -}} -{{- $confDir := dict "SizeLimit" "1Gi" "MountPath" "/etc/nginx/conf.d" -}} -{{- $cacheDir := dict "SizeLimit" "1Gi" "MountPath" "/var/cache/nginx" -}} -{{- $statusPageCertsDir := dict "SizeLimit" "1Gi" "MountPath" "/etc/nginx/certs/StatusPageCerts" -}} -{{- $nginxVolumes := dict "status-page-certs" $statusPageCertsDir "cache" $cacheDir "conf" $confDir "run" $runDir -}} -{{- $nginxPorts := dict "http" "7849" "https" "7850" -}} -{{- $nginxDeploymentArgs :=dict "IsServer" true "Ports" $nginxPorts "ServiceName" "nginx" "Release" $.Release "Values" $.Values "Volumes" $nginxVolumes -}} -{{- include "oneuptime.deployment" $nginxDeploymentArgs }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ printf "%s-%s" $.Release.Name "nginx" }} + namespace: {{ $.Release.Namespace }} + labels: + app: {{ printf "%s-%s" $.Release.Name "nginx" }} + app.kubernetes.io/part-of: oneuptime + app.kubernetes.io/managed-by: Helm + appname: oneuptime + date: "{{ now | unixEpoch }}" +spec: + selector: + matchLabels: + app: {{ printf "%s-%s" $.Release.Name "nginx" }} + replicas: {{ $.Values.deployment.replicaCount }} + template: + metadata: + labels: + app: {{ printf "%s-%s" $.Release.Name "nginx" }} + date: "{{ now | unixEpoch }}" + appname: oneuptime + spec: + volumes: + - name: status-page-certs + emptyDir: + sizeLimit: "1Gi" + - name: cache + emptyDir: + sizeLimit: "1Gi" + - name: conf + emptyDir: + sizeLimit: "1Gi" + - name: run + emptyDir: + sizeLimit: "1Gi" + {{- if $.Values.podSecurityContext }} + securityContext: {{- $.Values.podSecurityContext | toYaml | nindent 8 }} + {{- end }} + {{- if $.Values.affinity }} + affinity: {{- $.Values.affinity | toYaml | nindent 8 }} + {{- end }} + {{- if $.Values.tolerations }} + tolerations: {{- $.Values.tolerations | toYaml | nindent 8 }} + {{- end }} + {{- if $.Values.nodeSelector }} + nodeSelector: {{- $.Values.nodeSelector | toYaml | nindent 8 }} + {{- end }} + containers: + - image: {{ printf "%s/%s/%s:%s" $.Values.image.registry $.Values.image.repository "nginx" $.Values.image.tag }} + name: {{ printf "%s-%s" $.Release.Name "nginx" }} + # Liveness probe + livenessProbe: + httpGet: + path: /status/live + port: 7851 + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 30 + # Readyness Probe + readinessProbe: + httpGet: + path: /status/ready + port: 7851 + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 30 + volumeMounts: + - name: status-page-certs + mountPath: /etc/nginx/certs/StatusPageCerts + - name: cache + mountPath: /var/cache/nginx + - name: conf + mountPath: /etc/nginx/conf.d + - name: run + mountPath: /var/run + {{- if $.Values.containerSecurityContext }} + securityContext: {{- $.Values.containerSecurityContext | toYaml | nindent 12 }} + {{- end }} + imagePullPolicy: {{ $.Values.image.pullPolicy }} + env: + {{- include "oneuptime.env.common" . | nindent 12 }} + {{- include "oneuptime.env.commonServer" . | nindent 12 }} + {{- include "oneuptime.env.oneuptimeSecret" . | nindent 12 }} + - name: OPENTELEMETRY_EXPORTER_OTLP_HEADERS + value: {{ $.Values.openTelemetryExporter.headers.ingress }} + - name: PORT + value: "7851" # Port for the nodejs server for live and ready status + ports: + - containerPort: 7849 + protocol: TCP + name: http + - containerPort: 7850 + protocol: TCP + name: https + restartPolicy: {{ $.Values.image.restartPolicy }} + --- apiVersion: v1 diff --git a/HelmChart/Public/oneuptime/values.yaml b/HelmChart/Public/oneuptime/values.yaml index 88b083ad12..0a69828461 100644 --- a/HelmChart/Public/oneuptime/values.yaml +++ b/HelmChart/Public/oneuptime/values.yaml @@ -178,6 +178,8 @@ openTelemetryExporter: statusPage: probe: adminDashboard: + ingestor: + ingress: containerSecurityContext: podSecurityContext: diff --git a/Nginx/Index.ts b/Nginx/Index.ts index 3d81ee4a75..2f0618fb92 100644 --- a/Nginx/Index.ts +++ b/Nginx/Index.ts @@ -1,21 +1,33 @@ +process.env['SERVICE_NAME'] = 'ingress'; + import logger from 'CommonServer/Utils/Logger'; import App from 'CommonServer/Utils/StartServer'; import { PostgresAppInstance } from 'CommonServer/Infrastructure/PostgresDatabase'; import FetchCertificateJobs from './Jobs/FetchCertificates'; import { PromiseVoidFunction } from 'Common/Types/FunctionTypes'; +import InfrastructureStatus from 'CommonServer/Infrastructure/Status'; -const APP_NAME: string = 'ingress'; +const APP_NAME: string = process.env['SERVICE_NAME']; const init: PromiseVoidFunction = async (): Promise => { try { + + const statusCheck: PromiseVoidFunction = async (): Promise => { + return await InfrastructureStatus.checkStatus({ + checkClickhouseStatus: false, + checkPostgresStatus: true, + checkRedisStatus: false, + }); + }; + // init the app await App.init({ appName: APP_NAME, port: undefined, isFrontendApp: false, statusOptions: { - liveCheck: async () => {}, - readyCheck: async () => {}, + liveCheck: statusCheck, + readyCheck: statusCheck, }, });