Skip to content

Commit 34f331e

Browse files
Merge pull request #58 from cloudkite-io/add-gateway-api
Add GateWay API to library and update example file
2 parents d00ba23 + 6b940a8 commit 34f331e

File tree

5 files changed

+137
-1
lines changed

5 files changed

+137
-1
lines changed

standard-app/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: standard-app
33
description: A Helm chart library by Cloudkite
44
type: application
5-
version: 0.9.4
5+
version: 0.9.5
66
maintainters:
77
88
name: cloudkite

standard-app/example.values.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,49 @@ serviceAccounts:
9090
annotations:
9191
iam.gke.io/gcp-service-account: GOOGLE_SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com
9292

93+
94+
gateways:
95+
example-gateway:
96+
enabled: true
97+
annotations:
98+
networking.gke.io/certmap: example-gateway-map # Optional, used for Google managed certificate, managed certificate and map can be created manually https://cloud.google.com/kubernetes-engine/docs/how-to/deploying-gateways#create_a_certificate_map
99+
gatewayClass: gke-l7-global-external-managed # Default to GKE L7 Global External Managed Gateway you can change this to internal gateway class
100+
listeners:
101+
- name: https
102+
protocol: HTTPS
103+
port: 443
104+
# Optional, if not specified it defaults to allowing routes in the same namespace. For more permissive settings, you can specify the namespaces or labels: https://cloud.google.com/kubernetes-engine/docs/how-to/deploying-gateways#create_a_certificate_map.
105+
allowedRoutes:
106+
namespaces:
107+
from: Same # Allow routes in the same namespace by default
108+
# Optional, if you want to specify a specific external reserved or internal address for the Gateway, if left empty, the gateway will use the default address for the cluster based on the gateway class.
109+
addresses:
110+
- type: NamedAddress
111+
value: example-ip-address-name # Name of external IP address
112+
# Optional, if you want to specify labels for the allowed routes, this is useful for more fine-grained control over which routes are allowed to be used with this gateway. in this case the routes specified in the rules.
113+
# allowedRoutesLabels:
114+
# app: example-app
115+
# environment: production
116+
hostnames:
117+
- api.dev.example.com
118+
- api.example.com
119+
rules:
120+
- matches:
121+
- path:
122+
type: PathPrefix
123+
value: /v1
124+
backendRefs:
125+
- name: example-app-2
126+
port: 3003
127+
- matches:
128+
- path:
129+
type: PathPrefix
130+
value: /v2
131+
backendRefs:
132+
- name: example-app-2-web-headless
133+
port: 3003
134+
135+
93136
apps:
94137
# you can specify init containers and containers for each deployment for a fine tuning (example-app-1), or use a simplified version in case you only need one container (example-app-2)
95138
# you can specify parameters on multiple levels:
@@ -333,6 +376,11 @@ apps:
333376
capabilities:
334377
drop:
335378
- ALL
379+
# GCP settings for the Gateway IAP backend policy
380+
gatewayBackendPolicy:
381+
- serviceName: example-app-2 # Name of the service to which the backend policy applies
382+
clientSecretName: example-app-2 # Name of the Kubernetes secret containing the OAuth2 client secret. SecretKey must be 'key'
383+
clientID: 00000-xxxaaazzz.apps.googleusercontent.com
336384

337385
example-app-3:
338386
serviceAccount: cloudkite
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{ range $appName, $appConfig := .Values.apps }}
2+
{{- if $appConfig.gatewayBackendPolicy }}
3+
{{- range $appConfig.gatewayBackendPolicy }}
4+
apiVersion: networking.gke.io/v1
5+
kind: GCPBackendPolicy
6+
metadata:
7+
name: {{ .serviceName }}-gateway-backend-policy
8+
spec:
9+
default:
10+
iap:
11+
enabled: true
12+
oauth2ClientSecret:
13+
name: {{ .clientSecretName }}
14+
clientID: {{ .clientID }}
15+
targetRef:
16+
group: ""
17+
kind: Service
18+
name: {{ .serviceName }}
19+
---
20+
{{- end }}
21+
{{- end }}
22+
{{- end }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{{- range $gatewayName, $gatewayConfig := .Values.gateways }}
2+
{{- if $gatewayConfig.enabled }}
3+
apiVersion: gateway.networking.k8s.io/v1
4+
kind: Gateway
5+
metadata:
6+
name: {{ $gatewayName }}
7+
namespace: {{ $.Release.Namespace }}
8+
labels:
9+
app: {{ $.Release.Name }}
10+
{{- with $gatewayConfig.annotations }}
11+
annotations:
12+
{{ toYaml . | indent 4 }}
13+
{{- end }}
14+
spec:
15+
gatewayClassName: {{ default "gke-l7-global-external-managed" $gatewayConfig.gatewayClass }}
16+
listeners:
17+
{{- range $gatewayConfig.listeners }}
18+
- name: {{ .name }}
19+
protocol: {{ .protocol }}
20+
port: {{ .port }}
21+
{{- if .allowedRoutes }}
22+
allowedRoutes:
23+
{{ toYaml .allowedRoutes | indent 8 }}
24+
{{- else }}
25+
allowedRoutes:
26+
namespaces:
27+
from: Same
28+
{{- end }}
29+
{{- end }}
30+
{{- if $gatewayConfig.addresses }}
31+
addresses:
32+
{{ toYaml $gatewayConfig.addresses | indent 4 }}
33+
{{- end }}
34+
---
35+
{{- end }}
36+
{{- end }}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{{- range $gateWayName, $gateWayConfig := .Values.gateways }}
2+
apiVersion: gateway.networking.k8s.io/v1
3+
kind: HTTPRoute
4+
metadata:
5+
name: {{ $gateWayName }}-http-routes
6+
namespace: {{ $.Release.Namespace }}
7+
labels:
8+
app: {{ $.Release.Name }}
9+
{{- with $gateWayConfig.allowedRoutesLabels }}
10+
{{ toYaml . | indent 4 }}
11+
{{- end }}
12+
spec:
13+
parentRefs:
14+
- kind: Gateway
15+
name: {{ $gateWayName }}
16+
{{- if $gateWayConfig.namespace }}
17+
namespace: {{ $gateWayConfig.namespace }}
18+
{{- end }}
19+
{{- with $gateWayConfig.hostnames }}
20+
hostnames:
21+
{{- range . }}
22+
- {{ . | quote }}
23+
{{- end }}
24+
{{- end }}
25+
rules:
26+
{{- with $gateWayConfig.rules }}
27+
{{ toYaml . | indent 4 }}
28+
{{- end }}
29+
---
30+
{{- end }}

0 commit comments

Comments
 (0)