From 85304001f5e5710eb3384be72a14c80a6fee24c7 Mon Sep 17 00:00:00 2001 From: Prasath Sivasubramaniyan Date: Thu, 14 Sep 2023 10:13:37 +0530 Subject: [PATCH 1/6] changes for onest --- .../helm_charts/core/bpp-search /Chart.yaml | 5 ++ .../bpp-search /templates/deployment.yaml | 78 +++++++++++++++++++ .../core/bpp-search /templates/hpa.yaml | 27 +++++++ .../helm_charts/core/bpp-search /values.j2 | 35 +++++++++ .../core/nginx-public-ingress/values.j2 | 60 ++++++++++++++ 5 files changed, 205 insertions(+) create mode 100644 kubernetes/helm_charts/core/bpp-search /Chart.yaml create mode 100644 kubernetes/helm_charts/core/bpp-search /templates/deployment.yaml create mode 100644 kubernetes/helm_charts/core/bpp-search /templates/hpa.yaml create mode 100644 kubernetes/helm_charts/core/bpp-search /values.j2 diff --git a/kubernetes/helm_charts/core/bpp-search /Chart.yaml b/kubernetes/helm_charts/core/bpp-search /Chart.yaml new file mode 100644 index 0000000000..9f553e9066 --- /dev/null +++ b/kubernetes/helm_charts/core/bpp-search /Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: bpp-search +version: 0.1.0 diff --git a/kubernetes/helm_charts/core/bpp-search /templates/deployment.yaml b/kubernetes/helm_charts/core/bpp-search /templates/deployment.yaml new file mode 100644 index 0000000000..a41ce6cada --- /dev/null +++ b/kubernetes/helm_charts/core/bpp-search /templates/deployment.yaml @@ -0,0 +1,78 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + namespace: {{ .Values.namespace }} + annotations: + reloader.stakater.com/auto: "true" +spec: + replicas: {{ .Values.replicaCount }} + strategy: + rollingUpdate: + maxSurge: {{ .Values.strategy.maxsurge }} + maxUnavailable: {{ .Values.strategy.maxunavailable }} + selector: + matchLabels: + app: {{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Chart.Name }} + spec: +{{- if .Values.imagepullsecrets }} + imagePullSecrets: + - name: {{ .Values.imagepullsecrets }} +{{- end }} + volumes: + - name: {{ .Chart.Name }}-config + configMap: + name: {{ .Chart.Name }}-config + - name: {{ .Chart.Name }}-xml-config + configMap: + name: {{ .Chart.Name }}-xml-config + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.dockerhub }}/{{ .Values.repository }}:{{ .Values.image_tag }}" + imagePullPolicy: Always + env: + - name: JAVA_OPTIONS + value: {{ .Values.env.javaoptions | quote }} + - name: _JAVA_OPTIONS + value: -Dlog4j2.formatMsgNoLookups=true + envFrom: + - configMapRef: + name: {{ .Chart.Name }}-config + resources: +{{ toYaml .Values.resources | indent 10 }} + ports: + - containerPort: {{ .Values.network.port }} + {{- if .Values.healthcheck }} + livenessProbe: +{{ toYaml .Values.livenessProbe | indent 10 }} + readinessProbe: +{{ toYaml .Values.readinessProbe | indent 10 }} + {{- end }} + volumeMounts: + - name: {{ .Chart.Name }}-config + mountPath: /home/sunbird/search-service-1.0-SNAPSHOT/config/application.conf + subPath: search-service_application.conf + - name: {{ .Chart.Name }}-xml-config + mountPath: /home/sunbird/search-service-1.0-SNAPSHOT/config/logback.xml + subPath: search-service_logback.xml + +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }}-service + namespace: {{ .Values.namespace }} + labels: + app: {{ .Chart.Name }} +spec: + ports: + - name: http-{{ .Chart.Name }} + protocol: TCP + port: {{ .Values.network.targetport }} + selector: + app: {{ .Chart.Name }} diff --git a/kubernetes/helm_charts/core/bpp-search /templates/hpa.yaml b/kubernetes/helm_charts/core/bpp-search /templates/hpa.yaml new file mode 100644 index 0000000000..1ba4f89a8b --- /dev/null +++ b/kubernetes/helm_charts/core/bpp-search /templates/hpa.yaml @@ -0,0 +1,27 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Chart.Name }} + namespace: {{ .Values.namespace }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Chart.Name }} + 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 }} \ No newline at end of file diff --git a/kubernetes/helm_charts/core/bpp-search /values.j2 b/kubernetes/helm_charts/core/bpp-search /values.j2 new file mode 100644 index 0000000000..c21c7cb57c --- /dev/null +++ b/kubernetes/helm_charts/core/bpp-search /values.j2 @@ -0,0 +1,35 @@ +### Default variable file for search-service ### + +namespace: {{ namespace }} +imagepullsecrets: {{ imagepullsecrets }} +dockerhub: {{ dockerhub }} + +env: + javaoptions: {{search_java_mem_limit|default('-Xmx600m')}} + +replicaCount: {{search_replicacount|default(1)}} +repository: {{search_repository|default('search-service')}} +image_tag: {{ image_tag }} +resources: + requests: + cpu: {{search_cpu_req|default('100m')}} + memory: {{search_mem_req|default('100Mi')}} + limits: + cpu: {{search_cpu_limit|default('1')}} + memory: {{search_mem_limit|default('1024Mi')}} +network: + port: 9004 + targetport: 9000 +strategy: + type: RollingUpdate + maxsurge: {{ search_maxsurge|default('25%') }} + maxunavailable: {{ search_maxunavailable|default('25%') }} + +{{ search_liveness_readiness | to_nice_yaml }} + +autoscaling: + enabled: {{ search_autoscaling_enabled | default('false') }} + minReplicas: {{ search_autoscaling_minReplicas|default(1) }} + maxReplicas: {{ search_autoscaling_maxReplicas|default(2) }} + targetCPUUtilizationPercentage: {{ search_autoscaling_targetCPUUtilizationPercentage|default(60) }} + targetMemoryUtilizationPercentage: {{ search_autoscaling_targetMemoryUtilizationPercentage|default('') }} diff --git a/kubernetes/helm_charts/core/nginx-public-ingress/values.j2 b/kubernetes/helm_charts/core/nginx-public-ingress/values.j2 index e325f5d339..6e7ae98315 100644 --- a/kubernetes/helm_charts/core/nginx-public-ingress/values.j2 +++ b/kubernetes/helm_charts/core/nginx-public-ingress/values.j2 @@ -1010,6 +1010,66 @@ proxyconfig: |- proxy_set_header X-Request-ID $sb_request_id; proxy_pass http://$dial_upstream_host; } + # This is Caching mechanism for BPP search + location ~ /onest/bpp { + # Enabling compression + include /etc/nginx/defaults.d/compression.conf; + # Enabling caching + # caching include Accept-Encoding header also, to provide gziped or plain content as per request + proxy_cache_key "$http_accept_encoding|$request_uri|$request_body"; + proxy_cache {{proxy_cache_path.large_cache.keys_zone.split(':') | first}}; + add_header X-Proxy-Cache $upstream_cache_status; + add_header X-Proxy-Cache-Date $upstream_http_date; + proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; + proxy_cache_methods GET HEAD POST; + proxy_cache_revalidate on; + proxy_cache_background_update on; + proxy_cache_lock on; + proxy_cache_valid 200 {{proxy_cache_valid.medium_validity}}; + # Increasing the proxy buffer size + proxy_buffer_size 16k; + proxy_busy_buffers_size 16k; + rewrite ^/api/(.*) /$1 break; + proxy_set_header Connection ""; + proxy_set_header Host $host; + proxy_set_header X-Scheme $scheme; + proxy_set_header X-Real-IP {{ nginx_client_public_ip_header | d('$remote_addr') }}; + proxy_connect_timeout 5; + proxy_send_timeout 60; + proxy_read_timeout 70; + proxy_http_version 1.1; + proxy_pass http://bpp-search.service.staging.svc.cluster.local; + } + # This is Caching mechanism for BPP search + location ~ /onest/bap { + # Enabling compression + include /etc/nginx/defaults.d/compression.conf; + # Enabling caching + # caching include Accept-Encoding header also, to provide gziped or plain content as per request + proxy_cache_key "$http_accept_encoding|$request_uri|$request_body"; + proxy_cache {{proxy_cache_path.large_cache.keys_zone.split(':') | first}}; + add_header X-Proxy-Cache $upstream_cache_status; + add_header X-Proxy-Cache-Date $upstream_http_date; + proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; + proxy_cache_methods GET HEAD POST; + proxy_cache_revalidate on; + proxy_cache_background_update on; + proxy_cache_lock on; + proxy_cache_valid 200 {{proxy_cache_valid.medium_validity}}; + # Increasing the proxy buffer size + proxy_buffer_size 16k; + proxy_busy_buffers_size 16k; + rewrite ^/api/(.*) /$1 break; + proxy_set_header Connection ""; + proxy_set_header Host $host; + proxy_set_header X-Scheme $scheme; + proxy_set_header X-Real-IP {{ nginx_client_public_ip_header | d('$remote_addr') }}; + proxy_connect_timeout 5; + proxy_send_timeout 60; + proxy_read_timeout 70; + proxy_http_version 1.1; + proxy_pass http://PUBLIC-IP; + } {% if apple_app_site_association is defined %} location /apple-app-site-association { alias /var/www/html/; From 3b1f3078cbbe333c99bbede56f2890e55b074029 Mon Sep 17 00:00:00 2001 From: Prasath Sivasubramaniyan Date: Thu, 14 Sep 2023 11:19:25 +0530 Subject: [PATCH 2/6] changed for onest (#3897) --- .../helm_charts/core/{bpp-search => bpp-search}/Chart.yaml | 0 .../core/{bpp-search => bpp-search}/templates/deployment.yaml | 0 .../core/{bpp-search => bpp-search}/templates/hpa.yaml | 0 kubernetes/helm_charts/core/{bpp-search => bpp-search}/values.j2 | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename kubernetes/helm_charts/core/{bpp-search => bpp-search}/Chart.yaml (100%) rename kubernetes/helm_charts/core/{bpp-search => bpp-search}/templates/deployment.yaml (100%) rename kubernetes/helm_charts/core/{bpp-search => bpp-search}/templates/hpa.yaml (100%) rename kubernetes/helm_charts/core/{bpp-search => bpp-search}/values.j2 (100%) diff --git a/kubernetes/helm_charts/core/bpp-search /Chart.yaml b/kubernetes/helm_charts/core/bpp-search/Chart.yaml similarity index 100% rename from kubernetes/helm_charts/core/bpp-search /Chart.yaml rename to kubernetes/helm_charts/core/bpp-search/Chart.yaml diff --git a/kubernetes/helm_charts/core/bpp-search /templates/deployment.yaml b/kubernetes/helm_charts/core/bpp-search/templates/deployment.yaml similarity index 100% rename from kubernetes/helm_charts/core/bpp-search /templates/deployment.yaml rename to kubernetes/helm_charts/core/bpp-search/templates/deployment.yaml diff --git a/kubernetes/helm_charts/core/bpp-search /templates/hpa.yaml b/kubernetes/helm_charts/core/bpp-search/templates/hpa.yaml similarity index 100% rename from kubernetes/helm_charts/core/bpp-search /templates/hpa.yaml rename to kubernetes/helm_charts/core/bpp-search/templates/hpa.yaml diff --git a/kubernetes/helm_charts/core/bpp-search /values.j2 b/kubernetes/helm_charts/core/bpp-search/values.j2 similarity index 100% rename from kubernetes/helm_charts/core/bpp-search /values.j2 rename to kubernetes/helm_charts/core/bpp-search/values.j2 From 823af01e85228294305d71c8ca9be93b7d6be813 Mon Sep 17 00:00:00 2001 From: Prasath Sivasubramaniyan Date: Thu, 14 Sep 2023 12:47:46 +0530 Subject: [PATCH 3/6] ED-2874: updated private IP (#3898) * changed for onest * ED-874 updated private IP --- kubernetes/helm_charts/core/nginx-public-ingress/values.j2 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kubernetes/helm_charts/core/nginx-public-ingress/values.j2 b/kubernetes/helm_charts/core/nginx-public-ingress/values.j2 index 6e7ae98315..53384f0c03 100644 --- a/kubernetes/helm_charts/core/nginx-public-ingress/values.j2 +++ b/kubernetes/helm_charts/core/nginx-public-ingress/values.j2 @@ -1029,7 +1029,6 @@ proxyconfig: |- # Increasing the proxy buffer size proxy_buffer_size 16k; proxy_busy_buffers_size 16k; - rewrite ^/api/(.*) /$1 break; proxy_set_header Connection ""; proxy_set_header Host $host; proxy_set_header X-Scheme $scheme; @@ -1059,7 +1058,6 @@ proxyconfig: |- # Increasing the proxy buffer size proxy_buffer_size 16k; proxy_busy_buffers_size 16k; - rewrite ^/api/(.*) /$1 break; proxy_set_header Connection ""; proxy_set_header Host $host; proxy_set_header X-Scheme $scheme; @@ -1068,7 +1066,7 @@ proxyconfig: |- proxy_send_timeout 60; proxy_read_timeout 70; proxy_http_version 1.1; - proxy_pass http://PUBLIC-IP; + proxy_pass http://11.3.0.6; } {% if apple_app_site_association is defined %} location /apple-app-site-association { From 859c6aec7475cb1f321fbff01ba9aa0a9902d91d Mon Sep 17 00:00:00 2001 From: Prasath Sivasubramaniyan Date: Thu, 14 Sep 2023 14:27:06 +0530 Subject: [PATCH 4/6] Update main.yml --- ansible/roles/stack-sunbird/defaults/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ansible/roles/stack-sunbird/defaults/main.yml b/ansible/roles/stack-sunbird/defaults/main.yml index 581f28458b..13f8fae963 100644 --- a/ansible/roles/stack-sunbird/defaults/main.yml +++ b/ansible/roles/stack-sunbird/defaults/main.yml @@ -253,6 +253,9 @@ service_env: search: - ../../../../ansible/roles/stack-sunbird/templates/search-service_application.conf - ../../../../ansible/roles/stack-sunbird/templates/search-service_logback.xml + bpp-search: + - ../../../../ansible/roles/stack-sunbird/templates/search-service_application.conf + - ../../../../ansible/roles/stack-sunbird/templates/search-service_logback.xml taxonomy: - ../../../../ansible/roles/stack-sunbird/templates/taxonomy-service_application.conf - ../../../../ansible/roles/stack-sunbird/templates/taxonomy-service_logback.xml From f0275de494b94bb82997a281737b837dd6424b9b Mon Sep 17 00:00:00 2001 From: Prasath Sivasubramaniyan Date: Thu, 14 Sep 2023 14:36:55 +0530 Subject: [PATCH 5/6] Update values.j2 --- kubernetes/helm_charts/core/nginx-public-ingress/values.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kubernetes/helm_charts/core/nginx-public-ingress/values.j2 b/kubernetes/helm_charts/core/nginx-public-ingress/values.j2 index 53384f0c03..4114684cdd 100644 --- a/kubernetes/helm_charts/core/nginx-public-ingress/values.j2 +++ b/kubernetes/helm_charts/core/nginx-public-ingress/values.j2 @@ -1037,7 +1037,7 @@ proxyconfig: |- proxy_send_timeout 60; proxy_read_timeout 70; proxy_http_version 1.1; - proxy_pass http://bpp-search.service.staging.svc.cluster.local; + proxy_pass http://bpp-search-service.staging.svc.cluster.local:9000; } # This is Caching mechanism for BPP search location ~ /onest/bap { From 66e06c2da3ce6467879b3867b2b2edce06fe2443 Mon Sep 17 00:00:00 2001 From: Prasath Sivasubramaniyan Date: Thu, 14 Sep 2023 16:30:23 +0530 Subject: [PATCH 6/6] ED-2874 update nginx for bap and bpp --- .../helm_charts/core/nginx-public-ingress/values.j2 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kubernetes/helm_charts/core/nginx-public-ingress/values.j2 b/kubernetes/helm_charts/core/nginx-public-ingress/values.j2 index 4114684cdd..535129bf0f 100644 --- a/kubernetes/helm_charts/core/nginx-public-ingress/values.j2 +++ b/kubernetes/helm_charts/core/nginx-public-ingress/values.j2 @@ -1011,7 +1011,8 @@ proxyconfig: |- proxy_pass http://$dial_upstream_host; } # This is Caching mechanism for BPP search - location ~ /onest/bpp { + location ~ /onest/bpp/ { + rewrite ^/onest/bpp/(.*) /$1 break; # Enabling compression include /etc/nginx/defaults.d/compression.conf; # Enabling caching @@ -1039,8 +1040,9 @@ proxyconfig: |- proxy_http_version 1.1; proxy_pass http://bpp-search-service.staging.svc.cluster.local:9000; } - # This is Caching mechanism for BPP search - location ~ /onest/bap { + # This is Caching mechanism for BAP + location ~ /onest/bap/ { + rewrite ^/onest/bap/(.*) /$1 break; # Enabling compression include /etc/nginx/defaults.d/compression.conf; # Enabling caching @@ -1066,7 +1068,7 @@ proxyconfig: |- proxy_send_timeout 60; proxy_read_timeout 70; proxy_http_version 1.1; - proxy_pass http://11.3.0.6; + proxy_pass http://11.3.0.6:3004; } {% if apple_app_site_association is defined %} location /apple-app-site-association {