From b0e5d8e3e2b2ca2e5ccd15cb638307f919d05e64 Mon Sep 17 00:00:00 2001 From: ricolin Date: Thu, 2 Nov 2023 14:58:41 +0800 Subject: [PATCH] Octavia: Support uWSGI for API server Currently Octavia API server still using eventlet-based HTTP servers, it is generally considered more performant and flexible to run them using a generic HTTP server that supports WSGI. Change-Id: I75cfca8b660e0ea949527182e10b463972b3c0fb --- octavia/Chart.yaml | 2 +- octavia/templates/bin/_octavia-api.sh.tpl | 3 +-- octavia/templates/configmap-etc.yaml | 7 +++++++ octavia/templates/deployment-api.yaml | 4 ++++ octavia/values.yaml | 17 +++++++++++++++++ releasenotes/notes/octavia.yaml | 1 + 6 files changed, 31 insertions(+), 3 deletions(-) diff --git a/octavia/Chart.yaml b/octavia/Chart.yaml index 10ad88ce44..54ed0bb928 100644 --- a/octavia/Chart.yaml +++ b/octavia/Chart.yaml @@ -16,7 +16,7 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Octavia name: octavia -version: 0.2.10 +version: 0.2.11 home: https://docs.openstack.org/octavia/latest/ icon: https://www.openstack.org/themes/openstack/images/project-mascots/Octavia/OpenStack_Project_Octavia_vertical.png sources: diff --git a/octavia/templates/bin/_octavia-api.sh.tpl b/octavia/templates/bin/_octavia-api.sh.tpl index 9e322689cc..b045acb318 100644 --- a/octavia/templates/bin/_octavia-api.sh.tpl +++ b/octavia/templates/bin/_octavia-api.sh.tpl @@ -20,8 +20,7 @@ set -ex COMMAND="${@:-start}" function start () { - exec octavia-api \ - --config-file /etc/octavia/octavia.conf + exec uwsgi --ini /etc/octavia/octavia-api-uwsgi.ini } function stop () { diff --git a/octavia/templates/configmap-etc.yaml b/octavia/templates/configmap-etc.yaml index 8d3a653084..b8005a58a2 100644 --- a/octavia/templates/configmap-etc.yaml +++ b/octavia/templates/configmap-etc.yaml @@ -88,6 +88,12 @@ limitations under the License. {{- $_ := tuple "oslo_messaging" "internal" "octavia" "amqp" . | include "helm-toolkit.endpoints.authenticated_transport_endpoint_uri_lookup" | set .Values.conf.octavia.DEFAULT "transport_url" -}} {{- end -}} +{{- if empty (index .Values.conf.octavia_api_uwsgi.uwsgi "http-socket") -}} +{{- $http_socket_port := tuple "load_balancer" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | toString }} +{{- $http_socket := printf "0.0.0.0:%s" $http_socket_port }} +{{- $_ := set .Values.conf.octavia_api_uwsgi.uwsgi "http-socket" $http_socket -}} +{{- end -}} + {{- if and (empty .Values.conf.logging.handler_fluent) (has "fluent" .Values.conf.logging.handlers.keys) -}} {{- $fluentd_host := tuple "fluentd" "internal" $envAll | include "helm-toolkit.endpoints.hostname_namespaced_endpoint_lookup" }} {{- $fluentd_port := tuple "fluentd" "internal" "service" $envAll | include "helm-toolkit.endpoints.endpoint_port_lookup" }} @@ -108,6 +114,7 @@ metadata: type: Opaque data: octavia.conf: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.octavia | b64enc }} + octavia-api-uwsgi.ini: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.octavia_api_uwsgi | b64enc }} logging.conf: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.logging | b64enc }} {{- end }} {{- end }} diff --git a/octavia/templates/deployment-api.yaml b/octavia/templates/deployment-api.yaml index 2b4a498f4a..da15972429 100644 --- a/octavia/templates/deployment-api.yaml +++ b/octavia/templates/deployment-api.yaml @@ -87,6 +87,10 @@ spec: mountPath: /etc/octavia/octavia.conf subPath: octavia.conf readOnly: true + - name: octavia-etc + mountPath: /etc/octavia/octavia-api-uwsgi.ini + subPath: octavia-api-uwsgi.ini + readOnly: true {{- if .Values.conf.octavia.DEFAULT.log_config_append }} - name: octavia-etc mountPath: {{ .Values.conf.octavia.DEFAULT.log_config_append }} diff --git a/octavia/values.yaml b/octavia/values.yaml index 0f0ea75d3c..699aa05df7 100644 --- a/octavia/values.yaml +++ b/octavia/values.yaml @@ -331,6 +331,23 @@ conf: priority: 0 apply-to: all pattern: '(notifications)\.' + octavia_api_uwsgi: + uwsgi: + processes: 4 + add-header: "Connection: close" + buffer-size: 65535 + die-on-term: true + enable-threads: true + exit-on-reload: false + hook-master-start: unix_signal:15 gracefully_kill_them_all + lazy-apps: true + log-x-forwarded-for: true + master: true + procname-prefix-spaced: "octavia-api:" + route-user-agent: '^kube-probe.* donotlog:' + thunder-lock: true + worker-reload-mercy: 80 + wsgi-file: /var/lib/openstack/bin/octavia-wsgi secrets: identity: diff --git a/releasenotes/notes/octavia.yaml b/releasenotes/notes/octavia.yaml index c612294dd3..2449ffeaa4 100644 --- a/releasenotes/notes/octavia.yaml +++ b/releasenotes/notes/octavia.yaml @@ -14,4 +14,5 @@ octavia: - 0.2.8 Define service_type in keystone_authtoken to support application credentials with access rules - 0.2.9 Use default timeout and retry configs for haproxy_amphora - 0.2.10 Fix generating health_manager Role and RoleBinding + - 0.2.11 Uses uWSGI for API service ...