Add router chart
Change-Id: I1a7c66a159f0d6b5095521329ee451445f78aec5
diff --git a/router/templates/network.yaml b/router/templates/network.yaml
new file mode 100644
index 0000000..d92d5f8
--- /dev/null
+++ b/router/templates/network.yaml
@@ -0,0 +1,23 @@
+# SPDX-FileCopyrightText: {C) 2022 Intel Corporation
+#
+# SPDX-License-Identifier: Apache-2.0
+
+apiVersion: "k8s.cni.cncf.io/v1"
+kind: NetworkAttachmentDefinition
+metadata:
+ name: router-net
+{{- if eq .Values.config.router.cni "sriov" }}
+ annotations:
+ k8s.v1.cni.cncf.io/resourceName: {{ .Values.config.router.resourceName }}
+{{- end }}
+spec:
+ config: '{
+ "cniVersion": "0.3.1",
+ "type": "{{ .Values.config.router.cni }}",
+ {{- if eq .Values.config.router.cni "macvlan" }}
+ "master": "{{ .Values.config.router.dataIface }}",
+ {{- end }}
+ "ipam": {
+ "type": "static"
+ }
+ }'
diff --git a/router/templates/router-deployment.yaml b/router/templates/router-deployment.yaml
new file mode 100644
index 0000000..0b279f5
--- /dev/null
+++ b/router/templates/router-deployment.yaml
@@ -0,0 +1,54 @@
+# SPDX-FileCopyrightText: {C) 2022 Intel Corporation
+#
+# SPDX-License-Identifier: Apache-2.0
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: router
+ labels:
+ app: router
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: router
+ template:
+ metadata:
+ labels:
+ app: router
+ annotations:
+ k8s.v1.cni.cncf.io/networks: '[
+ {{- $first := true}}
+ {{- range .Values.config.router.interfaces }}
+ {{- if $first }}
+ {{- $first = false }}
+ {{- else }},
+ {{- end }}
+ { "name": "router-net", "interface": {{ .name | quote }}, "ips": [{{.ip | quote }}] }
+ {{- end }}
+ ]'
+ spec:
+ containers:
+ - name: router
+ command: ["/bin/bash", "-c"]
+ args:
+ - >
+ sysctl -w net.ipv4.ip_forward=1;
+ iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;
+ {{- range .Values.config.router.routes }}
+ ip route add {{ .to }} via {{ .via }};
+ {{- end }}
+ trap : TERM INT; sleep infinity & wait
+ image: {{ .Values.images.tags.router }}
+ securityContext:
+ capabilities:
+ add:
+ - NET_ADMIN
+ {{- if eq .Values.config.router.cni "sriov" }}
+ resources:
+ requests:
+ {{ .Values.config.router.resourceName }}: {{ len .Values.config.router.interfaces }}
+ limits:
+ {{ .Values.config.router.resourceName }}: {{ len .Values.config.router.interfaces }}
+ {{- end }}