Skip to content

Commit

Permalink
[sophora-cluster-common] add grpc ingress option (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
philmtd authored Oct 16, 2024
1 parent 3767999 commit 447f4c9
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/sophora-cluster-common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: sophora-cluster-common
description: A Helm chart containing some common resources useful for Sophora cloud setups
type: application
version: 1.1.3
version: 1.2.0
appVersion: "4"
41 changes: 41 additions & 0 deletions charts/sophora-cluster-common/templates/lb/ingress-grpc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{- if and .Values.clusterServerLb.enabled .Values.clusterServerLb.grpcIngress.enabled }}
{{- $fullName := include "sophora-cluster-common.fullname" . -}}
{{- $ingressName := printf "%s-grpc" ($fullName | trunc 58 | trimSuffix "-") }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $ingressName }}
labels:
{{- include "sophora-cluster-common.labels" . | nindent 4 }}
{{- with .Values.clusterServerLb.grpcIngress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.clusterServerLb.grpcIngress.ingressClassName }}
ingressClassName: {{ .Values.clusterServerLb.grpcIngress.ingressClassName }}
{{- end -}}
{{- if .Values.clusterServerLb.grpcIngress.tls }}
tls:
{{- range .Values.clusterServerLb.grpcIngress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.clusterServerLb.grpcIngress.hosts }}
- host: {{ .host | quote }}
http:
paths:
- path: {{ .path }}
pathType: {{ default "ImplementationSpecific" .pathType }}
backend:
service:
name: {{ $.Values.clusterServerLb.name }}
port:
number: {{ $.Values.clusterServerLb.service.httpPort }}
{{- end }}
{{- end }}
9 changes: 9 additions & 0 deletions charts/sophora-cluster-common/test-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ clusterServerLb:
ingressClassName: "nginx"
hosts:
- host: "cms.mysophora.com"
grpcIngress:
enabled: true
ingressClassName: nginx
annotations:
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
hosts:
- host: "cms.mysophora.com"
path: /sophora\.grpc.*

podDisruptionBudget:
enabled: true
Expand Down
19 changes: 19 additions & 0 deletions charts/sophora-cluster-common/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ clusterServerLb:
# - host: ""
# path: /

# This can be used to configure a different ingress for the gRPC service as gRPC may require different settings,
# e.g. nginx needs to be explicitly informed that the backend protocol is gRPC and that the path should be regex-matched.
grpcIngress:
enabled: false
# For Kubernetes >= 1.18 you should specify the ingress-controller via the field ingressClassName
# See https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/#specifying-the-class-of-an-ingress
# ingressClassName: nginx
annotations: {}
# kubernetes.io/tls-acme: "true"
# nginx.ingress.kubernetes.io/use-regex: "true"
# nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
hosts:
# - host: chart-example.local
# path: /sophora\.grpc.*
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

service:
## @param clusterServerLb.service.type Kubernetes service type
type: ClusterIP
Expand Down

0 comments on commit 447f4c9

Please sign in to comment.