Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for setting appProtocol to service ports #24

Merged
merged 1 commit into from
Nov 29, 2021
Merged

Add support for setting appProtocol to service ports #24

merged 1 commit into from
Nov 29, 2021

Conversation

matrix-root
Copy link
Contributor

@matrix-root matrix-root commented Nov 28, 2021

Fix problem with Istio mentioned in #23

Adds service.setAppProtocol option in values which allows render service ports with additional field.
Allows Istio to correctly identify service protocols as described in docs.

@FZambia
Copy link
Member

FZambia commented Nov 29, 2021

@LvLs9 thanks! What do you think if we make this in a bit different way? Like this:

diff --git a/charts/centrifugo/templates/service-grpc-api.yaml b/charts/centrifugo/templates/service-grpc-api.yaml
index 75bcf63..1709e94 100644
--- a/charts/centrifugo/templates/service-grpc-api.yaml
+++ b/charts/centrifugo/templates/service-grpc-api.yaml
@@ -16,6 +16,9 @@ spec:
     - port: {{ .Values.grpcService.port }}
       targetPort: grpc
       protocol: TCP
+      {{- if .Values.grpcService.appProtocol }}
+      appProtocol: {{ .Values.grpcService.appProtocol }}
+      {{- end }}
       name: grpc
       {{- if (and (eq .Values.grpcService.type "NodePort") (not (empty .Values.grpcService.nodePort))) }}
       nodePort: {{ .Values.grpcService.nodePort }}
diff --git a/charts/centrifugo/templates/service-internal.yaml b/charts/centrifugo/templates/service-internal.yaml
index e469597..22a0a87 100644
--- a/charts/centrifugo/templates/service-internal.yaml
+++ b/charts/centrifugo/templates/service-internal.yaml
@@ -16,6 +16,9 @@ spec:
     - port: {{ .Values.internalService.port }}
       targetPort: internal
       protocol: TCP
+      {{- if .Values.internalService.appProtocol }}
+      appProtocol: {{ .Values.internalService.appProtocol }}
+      {{- end }}
       name: internal
       {{- if (and (eq .Values.internalService.type "NodePort") (not (empty .Values.internalService.nodePort))) }}
       nodePort: {{ .Values.internalService.nodePort }}
diff --git a/charts/centrifugo/templates/service-uni-grpc.yaml b/charts/centrifugo/templates/service-uni-grpc.yaml
index 56716f9..ffc5e15 100644
--- a/charts/centrifugo/templates/service-uni-grpc.yaml
+++ b/charts/centrifugo/templates/service-uni-grpc.yaml
@@ -16,6 +16,9 @@ spec:
     - port: {{ .Values.uniGrpcService.port }}
       targetPort: uni-grpc
       protocol: TCP
+      {{- if .Values.uniGrpcService.appProtocol }}
+      appProtocol: {{ .Values.uniGrpcService.appProtocol }}
+      {{- end }}
       name: uni-grpc
       {{- if (and (eq .Values.uniGrpcService.type "NodePort") (not (empty .Values.uniGrpcService.nodePort))) }}
       nodePort: {{ .Values.uniGrpcService.nodePort }}
diff --git a/charts/centrifugo/templates/service.yaml b/charts/centrifugo/templates/service.yaml
index 5b1d9cb..d6b4a8d 100644
--- a/charts/centrifugo/templates/service.yaml
+++ b/charts/centrifugo/templates/service.yaml
@@ -32,6 +32,9 @@ spec:
     - port: {{ .Values.grpcService.port }}
       targetPort: grpc
       protocol: TCP
+      {{- if .Values.grpcService.appProtocol }}
+      appProtocol: {{ .Values.grpcService.appProtocol }}
+      {{- end }}
       name: grpc
       {{- if (and (eq .Values.grpcService.type "NodePort") (not (empty .Values.grpcService.nodePort))) }}
       nodePort: {{ .Values.grpcService.nodePort }}
diff --git a/charts/centrifugo/values.yaml b/charts/centrifugo/values.yaml
index c0203cd..cd14143 100644
--- a/charts/centrifugo/values.yaml
+++ b/charts/centrifugo/values.yaml
@@ -36,6 +36,9 @@ service:
   ##
   annotations: {}
   ##
+  ## Specify custom appProtocol for a service port.
+  appProtocol: ""
+  ##
   ## Use separate service for internal endpoints. It could be useful for configuring same port number for all services.
   useSeparateInternalService: false
   ## Use separate service for GRPC API endpoints. It could be useful for configuring same port number for all services.
@@ -53,6 +56,8 @@ internalService:
     # prometheus.io/scrape: "true"
     # prometheus.io/path: "/metrics"
     # prometheus.io/port: "9000"
+  ## Specify custom appProtocol for a service port.
+  appProtocol: ""
 
 grpcService:
   port: 10000
@@ -61,6 +66,8 @@ grpcService:
   # Static NodePort, if set.
   # nodePort: 30102
   annotations: {}
+  ## Specify custom appProtocol for a service port.
+  appProtocol: ""
 
 uniGrpcService:
   port: 11000
@@ -69,6 +76,8 @@ uniGrpcService:
   # Static NodePort, if set.
   # nodePort: 30103
   annotations: {}
+  ## Specify custom appProtocol for a service port.
+  appProtocol: ""
 
 ingress:
   enabled: false

This requires more things to configure – but seems to fit better existing service separations in the chart.

Another reason is that I am not fully sure TCP is the best choice for appProtocol everywhere - since Istio users can benefit from defining appProtocol as grpc for grpc services, and I think external port should work fine with http appProtocol (maybe it does not at the moment - but can be an Istio bug?).

So I think having an explicit settings here is the safest thing to do without more deep investigation of Istio behavior.

@matrix-root
Copy link
Contributor Author

Yes, agreed 👍

@FZambia
Copy link
Member

FZambia commented Nov 29, 2021

You also need to bump version https://github.com/centrifugal/helm-charts/blob/master/charts/centrifugo/Chart.yaml#L4 (I think to 7.2.1 is fine for these changes) - otherwise CI will complain.

@FZambia FZambia changed the title Add service.setAppProtocol Add support for setting appProtocol to service ports Nov 29, 2021
@FZambia FZambia merged commit 09289d7 into centrifugal:master Nov 29, 2021
@FZambia
Copy link
Member

FZambia commented Nov 29, 2021

Many thanks, Lev!

@FZambia FZambia mentioned this pull request Nov 29, 2021
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants