From d1cbf263a310ea4ed342e44a21a3ea32431e8ea6 Mon Sep 17 00:00:00 2001 From: Roshan Piyush Date: Thu, 2 May 2024 13:27:49 +0530 Subject: [PATCH] Add mongo dependency for chatbot --- deploy/docker/docker-compose.yml | 3 +++ deploy/helm/templates/chatbot/deployment.yaml | 7 +++++++ services/web/nginx.conf.template | 16 ++++++++-------- services/web/nginx.ssl.conf.template | 16 ++++++++-------- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/deploy/docker/docker-compose.yml b/deploy/docker/docker-compose.yml index a729e730..dbcfacb3 100755 --- a/deploy/docker/docker-compose.yml +++ b/deploy/docker/docker-compose.yml @@ -162,6 +162,9 @@ services: - MONGO_DB_PASSWORD=crapisecretpassword - MONGO_DB_NAME=crapi # - CHATBOT_OPENAI_API_KEY= + depends_on: + mongodb: + condition: service_healthy # ports: # - "${LISTEN_IP:-127.0.0.1}:5002:5002" diff --git a/deploy/helm/templates/chatbot/deployment.yaml b/deploy/helm/templates/chatbot/deployment.yaml index 9f99a23f..799d1e84 100644 --- a/deploy/helm/templates/chatbot/deployment.yaml +++ b/deploy/helm/templates/chatbot/deployment.yaml @@ -20,6 +20,13 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} spec: + initContainers: + - name: wait-for-mongo + image: {{ .Values.waitForK8sResources.image }} + imagePullPolicy: {{ .Values.waitForK8sResources.imagePullPolicy }} + args: + - "service" + - {{ .Values.mongodb.service.name | quote }} containers: - name: {{ .Values.chatbot.name }} image: {{ .Values.chatbot.image }}:{{ .Chart.AppVersion }} diff --git a/services/web/nginx.conf.template b/services/web/nginx.conf.template index 2d266d96..9108e25f 100644 --- a/services/web/nginx.conf.template +++ b/services/web/nginx.conf.template @@ -22,7 +22,7 @@ server { proxy_pass ${HTTP_PROTOCOL}://${COMMUNITY_SERVICE}; proxy_set_header Host ${COMMUNITY_SERVICE}; proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; sub_filter_types application/json text/html; sub_filter "://${COMMUNITY_SERVICE}" "://$http_host"; sub_filter_once off; @@ -40,7 +40,7 @@ server { proxy_pass ${HTTP_PROTOCOL}://${IDENTITY_SERVICE}; proxy_set_header Host ${IDENTITY_SERVICE}; proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /workshop/ { @@ -55,7 +55,7 @@ server { proxy_pass ${HTTP_PROTOCOL}://${WORKSHOP_SERVICE}; proxy_set_header Host ${WORKSHOP_SERVICE}; proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; sub_filter_types application/json text/html; sub_filter "${HTTP_PROTOCOL}://${WORKSHOP_SERVICE}" "$scheme://$http_host"; sub_filter_once off; @@ -73,7 +73,7 @@ server { proxy_pass ${HTTP_PROTOCOL}://${CHATBOT_SERVICE}; proxy_set_header Host ${CHATBOT_SERVICE}; proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; sub_filter_types application/json text/html; sub_filter "://${CHATBOT_SERVICE}" "://$http_host"; sub_filter_once off; @@ -116,7 +116,7 @@ server { proxy_pass ${HTTP_PROTOCOL}://${COMMUNITY_SERVICE}; proxy_set_header Host ${COMMUNITY_SERVICE}; proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; sub_filter_types application/json text/html; sub_filter "://${COMMUNITY_SERVICE}" "://$http_host"; sub_filter_once off; @@ -134,7 +134,7 @@ server { proxy_pass ${HTTP_PROTOCOL}://${IDENTITY_SERVICE}; proxy_set_header Host ${IDENTITY_SERVICE}; proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /workshop/ { @@ -149,7 +149,7 @@ server { proxy_pass ${HTTP_PROTOCOL}://${WORKSHOP_SERVICE}; proxy_set_header Host ${WORKSHOP_SERVICE}; proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; sub_filter_types application/json text/html; sub_filter "${HTTP_PROTOCOL}://${WORKSHOP_SERVICE}" "$scheme://$http_host"; sub_filter_once off; @@ -167,7 +167,7 @@ server { proxy_pass ${HTTP_PROTOCOL}://${CHATBOT_SERVICE}; proxy_set_header Host ${CHATBOT_SERVICE}; proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; sub_filter_types application/json text/html; sub_filter "${HTTP_PROTOCOL}://${CHATBOT_SERVICE}" "$scheme://$http_host"; sub_filter_once off; diff --git a/services/web/nginx.ssl.conf.template b/services/web/nginx.ssl.conf.template index 8cf72670..703d180f 100644 --- a/services/web/nginx.ssl.conf.template +++ b/services/web/nginx.ssl.conf.template @@ -21,7 +21,7 @@ server { proxy_pass ${HTTP_PROTOCOL}://${COMMUNITY_SERVICE}; proxy_set_header Host ${COMMUNITY_SERVICE}; proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; sub_filter_types application/json text/html; sub_filter "${HTTP_PROTOCOL}://${COMMUNITY_SERVICE}" "$scheme://$http_host"; sub_filter_once off; @@ -41,7 +41,7 @@ server { proxy_pass ${HTTP_PROTOCOL}://${IDENTITY_SERVICE}; proxy_set_header Host ${IDENTITY_SERVICE}; proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_ssl_verify off; proxy_ssl_trusted_certificate /app/certs/server.crt; } @@ -58,7 +58,7 @@ server { proxy_pass ${HTTP_PROTOCOL}://${WORKSHOP_SERVICE}; proxy_set_header Host ${WORKSHOP_SERVICE}; proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; sub_filter_types application/json text/html; sub_filter "${HTTP_PROTOCOL}://${WORKSHOP_SERVICE}" "$scheme://$http_host"; sub_filter_once off; @@ -78,7 +78,7 @@ server { proxy_pass ${HTTP_PROTOCOL}://${CHATBOT_SERVICE}; proxy_set_header Host ${CHATBOT_SERVICE}; proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; sub_filter_types application/json text/html; sub_filter "${HTTP_PROTOCOL}://${CHATBOT_SERVICE}" "$scheme://$http_host"; sub_filter_once off; @@ -125,7 +125,7 @@ server { proxy_pass ${HTTP_PROTOCOL}://${COMMUNITY_SERVICE}; proxy_set_header Host ${COMMUNITY_SERVICE}; proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; sub_filter_types application/json text/html; sub_filter "${HTTP_PROTOCOL}://${COMMUNITY_SERVICE}" "$scheme://$http_host"; sub_filter_once off; @@ -143,7 +143,7 @@ server { proxy_pass ${HTTP_PROTOCOL}://${IDENTITY_SERVICE}; proxy_set_header Host ${IDENTITY_SERVICE}; proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /workshop/ { @@ -158,7 +158,7 @@ server { proxy_pass ${HTTP_PROTOCOL}://${WORKSHOP_SERVICE}; proxy_set_header Host ${WORKSHOP_SERVICE}; proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; sub_filter_types application/json text/html; sub_filter "${HTTP_PROTOCOL}://${WORKSHOP_SERVICE}" "$scheme://$http_host"; sub_filter_once off; @@ -176,7 +176,7 @@ server { proxy_pass ${HTTP_PROTOCOL}://${CHATBOT_SERVICE}; proxy_set_header Host ${CHATBOT_SERVICE}; proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; sub_filter_types application/json text/html; sub_filter "://${CHATBOT_SERVICE}" "://$http_host"; sub_filter_once off;