Skip to content

Commit

Permalink
add grpc-web-service
Browse files Browse the repository at this point in the history
  • Loading branch information
kahirokunn committed Nov 20, 2022
1 parent 8dacd5f commit 98be7ae
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 0 deletions.
23 changes: 23 additions & 0 deletions grpc-web-service/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions grpc-web-service/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: grpc-web-service
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
82 changes: 82 additions & 0 deletions grpc-web-service/templates/grpc-web-services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{{- range $i, $service := .Values.grpcWebServices -}}
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
name: {{ $service.fqdn }}
namespace: {{ $.Values.gatewayServiceRef.namespace }}
spec:
virtualhost:
fqdn: {{ $service.fqdn }}
corsPolicy:
allowCredentials: true
allowOrigin:
{{- toYaml $.Values.allowOrigin | nindent 6 }}
allowMethods:
- GET
- PUT
- DELETE
- POST
- OPTIONS
allowHeaders:
- keep-alive
- user-agent
- cache-control
- content-type
- content-transfer-encoding
- x-accept-content-transfer-encoding
- x-accept-response-streaming
- x-user-agent
- x-grpc-web
- grpc-timeout
exposeHeaders:
- grpc-status
- grpc-message
- Content-Length
- Content-Range
maxAge: {{ $.Values.maxAge }}
routes:
- conditions:
- prefix: /
services:
- name: {{ $.Values.gatewayServiceRef.name }}
port: {{ $.Values.gatewayServiceRef.port }}
protocol: {{ $.Values.gatewayServiceRef.protocol }}
timeoutPolicy:
{{- toYaml $.Values.timeoutPolicy | nindent 8 }}
---
apiVersion: serving.knative.dev/v1alpha1
kind: DomainMapping
metadata:
name: {{ $service.fqdn }}
namespace: {{ $service.serviceRef.namespace }}
spec:
ref:
name: {{ $service.serviceRef.name }}
kind: Service
apiVersion: serving.knative.dev/v1
---
{{- end -}}
{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $.Values.ingress.name }}
namespace: {{ $.Values.ingress.service.namespace }}
annotations:
{{- toYaml $.Values.ingress.annotations | nindent 4 }}
spec:
ingressClassName: {{ $.Values.ingress.ingressClassName }}
rules:
{{ range $i, $service := .Values.grpcWebServices }}
- host: {{ $service.fqdn }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ $.Values.ingress.service.name }}
port:
name: http
{{- end -}}
{{- end -}}
37 changes: 37 additions & 0 deletions grpc-web-service/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
maxAge: 10m
timeoutPolicy:
response: infinity
idle: infinity
idleConnection: 60s
allowOrigin:
- "*"
gatewayServiceRef:
name: kourier-internal
namespace: default
port: 80
protocol: h2c
grpcWebServices:
- fqdn: grpc-helloworld.default.svc.cluster.local
serviceRef:
name: grpc-helloworld
namespace: default
- fqdn: grpc-ping.default.svc.cluster.local
serviceRef:
name: grpc-ping
namespace: default
ingress:
enabled: false
name: contour-ingress
ingressClassName: alb
service:
name: contour-envoy
namespace: projectcontour
annotations:
# alb.ingress.kubernetes.io/wafv2-acl-arn: <wafv2-acl-arn>
# alb.ingress.kubernetes.io/certificate-arn: <certificate-arn>
# alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]'
# alb.ingress.kubernetes.io/scheme: internet-facing
# alb.ingress.kubernetes.io/target-type: ip
# alb.ingress.kubernetes.io/ssl-redirect: "443"
# alb.ingress.kubernetes.io/tags: Service=grpc-web-service
# alb.ingress.kubernetes.io/load-balancer-attributes: access_logs.s3.enabled=true,access_logs.s3.bucket=alb-logging,access_logs.s3.prefix=contour-ingress,idle_timeout.timeout_seconds=3600

0 comments on commit 98be7ae

Please sign in to comment.