Skip to content

Agent Mesh

charts: expose the router at its node IP, GKE-style

Tomas Tormo71e472f4b619
diff --git a/charts/sam-mesh/templates/router-service.yaml b/charts/sam-mesh/templates/router-service.yaml
index 0735681b..708fc098 100644
--- a/charts/sam-mesh/templates/router-service.yaml
+++ b/charts/sam-mesh/templates/router-service.yaml
@@ -11,9 +11,6 @@ spec:
- name: p2p-tcp
port: {{ .Values.router.service.port }}
targetPort: 4501
- {{- if and (eq .Values.router.service.type "NodePort") .Values.router.service.nodePort }}
- nodePort: {{ .Values.router.service.nodePort }}
- {{- end }}
protocol: TCP
- name: p2p-udp
port: {{ .Values.router.service.port }}
diff --git a/charts/sam-mesh/templates/router-statefulset.yaml b/charts/sam-mesh/templates/router-statefulset.yaml
index 94def123..f07b0fd4 100644
--- a/charts/sam-mesh/templates/router-statefulset.yaml
+++ b/charts/sam-mesh/templates/router-statefulset.yaml
@@ -24,6 +24,10 @@ spec:
app: {{ include "sam-mesh.fullname" . }}-router
spec:
serviceAccountName: {{ include "sam-mesh.fullname" . }}-router-sa
+ {{- with .Values.router.nodeSelector }}
+ nodeSelector:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
{{- with .Values.router.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
@@ -76,6 +80,13 @@ spec:
name: {{ include "sam-mesh.fullname" . }}-router-token
key: token
{{- end }}
+ {{- if .Values.router.hostPort }}
+ # kubelet expands $(HOST_IP) in the args below.
+ - name: HOST_IP
+ valueFrom:
+ fieldRef:
+ fieldPath: status.hostIP
+ {{- end }}
args:
- "--control-plane=http://{{ include "sam-mesh.fullname" . }}-control-plane:{{ .Values.controlPlane.service.port }}"
- "--listen=/ip4/0.0.0.0/tcp/4501"
@@ -84,11 +95,16 @@ spec:
{{- range .Values.router.externalAddrs }}
- "--external-addr={{ . }}"
{{- end }}
+ {{- else if .Values.router.hostPort }}
+ - "--external-addr=/ip4/$(HOST_IP)/tcp/{{ .Values.router.hostPort }}"
+ - "--external-addr=/ip4/$(HOST_IP)/udp/{{ .Values.router.hostPort }}/quic-v1"
{{- else }}
- "--external-addr=/dns4/{{ include "sam-mesh.fullname" . }}-router/tcp/4501"
{{- end }}
- "--keys-path=/data/router.key"
+ {{- if .Values.router.allowLoopback }}
- "--allow-loopback"
+ {{- end }}
- "--log-level={{ .Values.router.logLevel }}"
{{- if .Values.router.useOidcToken }}
- "--jwt-path=/var/run/secrets/tokens/sam-token"
diff --git a/charts/sam-mesh/values.yaml b/charts/sam-mesh/values.yaml
index 96386274..dc54b6a2 100644
--- a/charts/sam-mesh/values.yaml
+++ b/charts/sam-mesh/values.yaml
@@ -61,6 +61,13 @@ router:
repository: sam-router
useOidcToken: false
logLevel: info
+ # Binds 4501 TCP+UDP on the router's own node and announces /ip4/<node IP>/... for both
+ # transports. One router per node.
+ hostPort: null
+ nodeSelector: {}
+ # Overrides the announced multiaddrs; derived from hostPort when left empty.
+ externalAddrs: []
+ allowLoopback: false
resources:
requests:
cpu: 100m
@@ -71,7 +78,6 @@ router:
service:
type: ClusterIP
port: 4501
- nodePort: null
console:
enabled: true