Skip to content

Agent Mesh

charts: front the mesh with Gateway API

Tomas Tormof2b76a0fd585
diff --git a/charts/sam-mesh/templates/gateway.yaml b/charts/sam-mesh/templates/gateway.yaml
new file mode 100644
index 00000000..8d6105e3
--- /dev/null
+++ b/charts/sam-mesh/templates/gateway.yaml
@@ -0,0 +1,102 @@
+{{- if .Values.gateway.enabled -}}
+{{- $fullName := include "sam-mesh.fullname" . -}}
+apiVersion: gateway.networking.k8s.io/v1
+kind: Gateway
+metadata:
+ name: {{ $fullName }}-gateway
+ labels:
+ {{- include "sam-mesh.labels" . | nindent 4 }}
+ {{- with .Values.gateway.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ gatewayClassName: {{ required "gateway.className is required when gateway.enabled is true" .Values.gateway.className }}
+ {{- with .Values.gateway.addresses }}
+ addresses:
+ {{- toYaml . | nindent 2 }}
+ {{- end }}
+ listeners:
+ {{- toYaml .Values.gateway.listeners | nindent 2 }}
+---
+apiVersion: gateway.networking.k8s.io/v1
+kind: HTTPRoute
+metadata:
+ name: {{ $fullName }}-route
+ labels:
+ {{- include "sam-mesh.labels" . | nindent 4 }}
+spec:
+ parentRefs:
+ - name: {{ $fullName }}-gateway
+ {{- with .Values.gateway.hostnames }}
+ hostnames:
+ {{- toYaml . | nindent 2 }}
+ {{- end }}
+ rules:
+ # The enrollment surface, matching the cloud's allow-list exactly.
+ - matches:
+ - path:
+ type: Exact
+ value: /register
+ - path:
+ type: Exact
+ value: /info
+ - path:
+ type: Exact
+ value: /keys
+ - path:
+ type: Exact
+ value: /routers/lease
+ - path:
+ type: Exact
+ value: /policies
+ - path:
+ type: Exact
+ value: /enroll
+ - path:
+ type: Exact
+ value: /enroll/status
+ - path:
+ type: Exact
+ value: /refresh
+ backendRefs:
+ - name: {{ $fullName }}-control-plane
+ port: {{ .Values.controlPlane.service.port }}
+ {{- if .Values.gateway.adminRoute }}
+ - matches:
+ - path:
+ type: PathPrefix
+ value: /admin
+ backendRefs:
+ - name: {{ $fullName }}-control-plane
+ port: {{ .Values.controlPlane.service.port }}
+ {{- end }}
+ {{- if and .Values.console.enabled .Values.gateway.consolePath }}
+ # The cloud deployment's console shape: the bare prefix 302s to <prefix>/, and
+ # URLRewrite (Extended conformance) strips it before the console sees the request.
+ - matches:
+ - path:
+ type: Exact
+ value: {{ .Values.gateway.consolePath }}
+ filters:
+ - type: RequestRedirect
+ requestRedirect:
+ path:
+ type: ReplaceFullPath
+ replaceFullPath: {{ .Values.gateway.consolePath }}/
+ statusCode: 302
+ - matches:
+ - path:
+ type: PathPrefix
+ value: {{ .Values.gateway.consolePath }}/
+ filters:
+ - type: URLRewrite
+ urlRewrite:
+ path:
+ type: ReplacePrefixMatch
+ replacePrefixMatch: /
+ backendRefs:
+ - name: {{ $fullName }}-console
+ port: {{ .Values.console.service.port }}
+ {{- end }}
+{{- end }}
diff --git a/charts/sam-mesh/values.yaml b/charts/sam-mesh/values.yaml
index 2b0c2884..af1fd446 100644
--- a/charts/sam-mesh/values.yaml
+++ b/charts/sam-mesh/values.yaml
@@ -2,6 +2,33 @@ global:
imageTag: local
imagePullPolicy: IfNotPresent
+# One Gateway fronting the mesh: the control plane's enrollment surface plus the console
+# under gateway.consolePath, mirroring the cloud deployment.
+gateway:
+ enabled: false
+ # Required when enabled. No default: the GatewayClass is provider-specific, e.g.
+ # cloud-provider-kind in kind, gke-l7-global-external-managed on GKE.
+ className: ""
+ # Routes the control plane's /admin API. Dev only; the cloud leaves it unrouted.
+ adminRoute: false
+ # External prefix the console is served under. The bare prefix 302s to <prefix>/ and a
+ # URLRewrite filter (Extended conformance) strips it before the console sees the
+ # request, as on the cloud. Empty leaves the console unrouted.
+ consolePath: /console
+ # listeners, hostnames, addresses and annotations pass through to the Gateway API
+ # objects verbatim, so anything the spec allows is expressible. Plain HTTP on 80
+ # matching any host suits a local cluster.
+ listeners:
+ - name: http
+ protocol: HTTP
+ port: 80
+ allowedRoutes:
+ namespaces:
+ from: Same
+ hostnames: []
+ addresses: []
+ annotations: {}
+
controlPlane:
replicaCount: 2
image: