Skip to content

Commit ce278c5

Browse files
chore: support gcp multi cluster ingress (#1198)
1 parent d6cb3d6 commit ce278c5

File tree

14 files changed

+182
-11
lines changed

14 files changed

+182
-11
lines changed
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1-
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "api.fullname" . }})
2-
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
3-
echo http://$NODE_IP:$NODE_PORT
1+
{{- if contains "NodePort" .Values.service.type }}
2+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "api.fullname" . }})
3+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
4+
echo http://$NODE_IP:$NODE_PORT
5+
{{- else if contains "LoadBalancer" .Values.service.type }}
6+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
7+
You can watch the status of by running 'kubectl get svc -w {{ template "api.fullname" . }}'
8+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "api.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
9+
echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
10+
{{- else if contains "ClusterIP" .Values.service.type }}
11+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "api.name" . }},release={{ template "api.fullname" . }}" -o jsonpath="{.items[0].metadata.name}")
12+
echo "Visit http://127.0.0.1:8080 to use your application"
13+
kubectl port-forward $POD_NAME 8080:80
14+
{{- end }}

manifests/bucketeer/charts/api/templates/backend-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ metadata:
77
spec:
88
healthCheck:
99
requestPath: /health
10+
type: HTTP2
1011
timeoutSec: 40
1112
connectionDraining:
1213
drainingTimeoutSec: 60

manifests/bucketeer/charts/api/templates/ingress.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if not .Values.gcpMultiCluster.enabled }}
12
apiVersion: networking.k8s.io/v1
23
kind: Ingress
34
metadata:
@@ -23,3 +24,4 @@ spec:
2324
- host: {{ .Values.ingress.host }}
2425
http:
2526
paths: {{- toYaml .Values.ingress.rulePaths | nindent 10 }}
27+
{{- end }}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{- if and .Values.gcpMultiCluster.enabled .Values.gcpMultiCluster.configCluster }}
2+
apiVersion: networking.gke.io/v1
3+
kind: MultiClusterIngress
4+
metadata:
5+
name: {{ .Values.gcpMultiCluster.ingress.name }}
6+
namespace: {{ .Values.namespace }}
7+
labels:
8+
app: {{ template "api.name" . }}
9+
chart: {{ template "api.chart" . }}
10+
release: {{ template "api.fullname" . }}
11+
heritage: {{ .Release.Service }}
12+
annotations:
13+
networking.gke.io/static-ip: {{ .Values.gcpMultiCluster.ingress.staticIPName }}
14+
spec:
15+
template:
16+
spec:
17+
backend:
18+
serviceName: {{ .Values.gcpMultiCluster.service.name }}
19+
servicePort: {{ .Values.service.externalPort }}
20+
tls:
21+
- secretName: {{ .Values.gcpMultiCluster.ingress.secretName }}
22+
rules:
23+
- host: {{ .Values.gcpMultiCluster.ingress.host }}
24+
http:
25+
paths: {{- toYaml .Values.gcpMultiCluster.ingress.rulePaths | nindent 14 }}
26+
{{- end }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{- if and .Values.gcpMultiCluster.enabled .Values.gcpMultiCluster.configCluster }}
2+
apiVersion: networking.gke.io/v1
3+
kind: MultiClusterService
4+
metadata:
5+
name: {{ .Values.gcpMultiCluster.service.name }}
6+
namespace: {{ .Values.namespace }}
7+
labels:
8+
app: {{ template "api.name" . }}
9+
chart: {{ template "api.chart" . }}
10+
release: {{ template "api.fullname" . }}
11+
heritage: {{ .Release.Service }}
12+
annotations:
13+
cloud.google.com/backend-config: '{"ports": {"{{ .Values.service.externalPort }}":"{{ template "api.fullname" . }}"}}'
14+
networking.gke.io/app-protocols: '{"service":"HTTP2"}'
15+
cloud.google.com/neg: '{"ingress": true}'
16+
spec:
17+
template:
18+
spec:
19+
selector:
20+
app: {{ template "api.name" . }}
21+
release: {{ template "api.fullname" . }}
22+
ports:
23+
- name: service
24+
port: {{ .Values.service.externalPort }}
25+
targetPort: {{ .Values.envoy.port }}
26+
protocol: TCP
27+
- name: metrics
28+
port: {{ .Values.env.metricsPort }}
29+
protocol: TCP
30+
- name: admin
31+
port: {{ .Values.envoy.adminPort }}
32+
protocol: TCP
33+
{{- end }}

manifests/bucketeer/charts/api/templates/service.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ metadata:
1515
envoy: "true"
1616
metrics: "true"
1717
spec:
18-
type: NodePort
18+
type: {{ .Values.service.type }}
1919
ports:
2020
- name: service
2121
port: {{ .Values.service.externalPort }}
@@ -29,4 +29,4 @@ spec:
2929
protocol: TCP
3030
selector:
3131
app: {{ template "api.name" . }}
32-
release: {{ template "api.fullname" . }}
32+
release: {{ template "api.fullname" . }}

manifests/bucketeer/charts/api/values.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ envoy:
6262
maxRequests: 3500
6363
maxConnections: 3500
6464
service:
65+
type: ClusterIP
6566
externalPort: 9000
6667
ingress:
6768
name: api
@@ -86,3 +87,18 @@ health:
8687
resources: {}
8788
serviceAccount:
8889
annotations: {}
90+
gcpMultiCluster:
91+
configCluster: false
92+
enabled: false
93+
service:
94+
name: api-multi-cluster-service
95+
ingress:
96+
name: api-multi-cluster-ingress
97+
host:
98+
staticIPName:
99+
secretName:
100+
rulePaths:
101+
- path: /
102+
backend:
103+
serviceName: api-multi-cluster-service
104+
servicePort: 9000
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
1. Get the application URL by running these commands:
21
{{- if contains "NodePort" .Values.service.type }}
32
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "web.fullname" . }})
43
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
@@ -7,9 +6,9 @@
76
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
87
You can watch the status of by running 'kubectl get svc -w {{ template "web.fullname" . }}'
98
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "web.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
10-
echo http://$SERVICE_IP:{{ .Values.service.port }}
9+
echo http://$SERVICE_IP:{{ .Values.service.httpPort }}
1110
{{- else if contains "ClusterIP" .Values.service.type }}
1211
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "web.name" . }},release={{ template "web.fullname" . }}" -o jsonpath="{.items[0].metadata.name}")
1312
echo "Visit http://127.0.0.1:8080 to use your application"
1413
kubectl port-forward $POD_NAME 8080:80
15-
{{- end }}
14+
{{- end }}

manifests/bucketeer/charts/web/templates/backend-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ metadata:
55
name: {{ template "web.fullname" . }}
66
namespace: {{ .Values.namespace }}
77
spec:
8+
healthCheck:
9+
requestPath: /health
10+
type: HTTP2
811
timeoutSec: 300
912
connectionDraining:
1013
drainingTimeoutSec: 60

manifests/bucketeer/charts/web/templates/ingress.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if not .Values.gcpMultiCluster.enabled }}
12
apiVersion: networking.k8s.io/v1
23
kind: Ingress
34
metadata:
@@ -22,4 +23,5 @@ spec:
2223
rules:
2324
- host: {{ .Values.ingress.host }}
2425
http:
25-
paths: {{- toYaml .Values.ingress.rulePaths | nindent 10 }}
26+
paths: {{- toYaml .Values.ingress.rulePaths | nindent 10 }}
27+
{{- end }}

0 commit comments

Comments
 (0)