From d2be022999ac40ecf4bde79b33b308f22af70476 Mon Sep 17 00:00:00 2001
From: josebb <jose.bautista.barato@gmail.com>
Date: Thu, 2 Dec 2021 16:28:46 +0200
Subject: [PATCH] Distinguish between port number of internal endpoint and
 binding port number in cinder

Now binding ports of service and pod spec are configured using
internal endpoint values.
To support reverse proxy for internalUrl, need to distinguish
between binding ports and internal endpoint ports.

I added `service` section in endpoint items apart from admin,public
,internal and default.

Change-Id: I40c3fc822e8ea9ef0eca8c15afe0d12b8bc926ff
---
 cinder/Chart.yaml                    | 2 +-
 cinder/templates/configmap-etc.yaml  | 2 +-
 cinder/templates/deployment-api.yaml | 6 +++---
 cinder/templates/service-api.yaml    | 2 +-
 releasenotes/notes/cinder.yaml       | 1 +
 5 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/cinder/Chart.yaml b/cinder/Chart.yaml
index 194f05c7d7..4642bfeebf 100644
--- a/cinder/Chart.yaml
+++ b/cinder/Chart.yaml
@@ -14,7 +14,7 @@ apiVersion: v1
 appVersion: v1.0.0
 description: OpenStack-Helm Cinder
 name: cinder
-version: 0.2.25
+version: 0.2.26
 home: https://docs.openstack.org/cinder/latest/
 icon: https://www.openstack.org/themes/openstack/images/project-mascots/Cinder/OpenStack_Project_Cinder_vertical.png
 sources:
diff --git a/cinder/templates/configmap-etc.yaml b/cinder/templates/configmap-etc.yaml
index a2ad5f22b2..309e8be6d5 100644
--- a/cinder/templates/configmap-etc.yaml
+++ b/cinder/templates/configmap-etc.yaml
@@ -94,7 +94,7 @@ limitations under the License.
 {{- end -}}
 
 {{- if empty .Values.conf.cinder.DEFAULT.osapi_volume_listen_port -}}
-{{- $_ := tuple "volumev3" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | set .Values.conf.cinder.DEFAULT "osapi_volume_listen_port" -}}
+{{- $_ := tuple "volumev3" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | set .Values.conf.cinder.DEFAULT "osapi_volume_listen_port" -}}
 {{- end -}}
 
 {{- if .Values.conf.cinder.service_user.send_service_user_token -}}
diff --git a/cinder/templates/deployment-api.yaml b/cinder/templates/deployment-api.yaml
index 7925c60f23..4eb009553f 100644
--- a/cinder/templates/deployment-api.yaml
+++ b/cinder/templates/deployment-api.yaml
@@ -88,13 +88,13 @@ spec:
                   - stop
           ports:
             - name: c-api
-              containerPort: {{ tuple "volumev3" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
+              containerPort: {{ tuple "volumev3" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
           readinessProbe:
             tcpSocket:
-              port: {{ tuple "volumev3" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
+              port: {{ tuple "volumev3" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
           livenessProbe:
             tcpSocket:
-              port: {{ tuple "volumev3" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
+              port: {{ tuple "volumev3" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
             initialDelaySeconds: 30
             failureThreshold: 3
             periodSeconds: 10
diff --git a/cinder/templates/service-api.yaml b/cinder/templates/service-api.yaml
index 86d6b6fa61..d0530633c0 100644
--- a/cinder/templates/service-api.yaml
+++ b/cinder/templates/service-api.yaml
@@ -22,7 +22,7 @@ metadata:
 spec:
   ports:
     - name: c-api
-      port: {{ tuple "volumev3" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
+      port: {{ tuple "volumev3" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
     {{ if .Values.network.api.node_port.enabled }}
       nodePort: {{ .Values.network.api.node_port.port }}
     {{ end }}
diff --git a/releasenotes/notes/cinder.yaml b/releasenotes/notes/cinder.yaml
index 93b00ff71b..8ef8a58fef 100644
--- a/releasenotes/notes/cinder.yaml
+++ b/releasenotes/notes/cinder.yaml
@@ -42,4 +42,5 @@ cinder:
   - 0.2.23 Added OCI registry authentication
   - 0.2.24 Fix conditional check for cinder.utils.has_ceph_backend template
   - 0.2.25 Remove volumes unrelated with ceph backend from conditional volume list in cinder-volume deployment
+  - 0.2.26 Distinguish between port number of internal endpoint and binding port number
 ...