diff --git a/examples/kubernetes/00_namespace.yaml b/examples/kubernetes/00_namespace.yaml new file mode 100644 index 0000000..520447c --- /dev/null +++ b/examples/kubernetes/00_namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: modbus-proxy \ No newline at end of file diff --git a/examples/kubernetes/10_modbus-proxy.configmap.yaml b/examples/kubernetes/10_modbus-proxy.configmap.yaml new file mode 100644 index 0000000..0841b39 --- /dev/null +++ b/examples/kubernetes/10_modbus-proxy.configmap.yaml @@ -0,0 +1,26 @@ +# Sample configuration file for modbus-proxy +# You can configure multiple proxies for multiple modbus devices. +# The first proxy configuration provides description for all supported options. +# Pass this file location as an --config-file option argument, e.g.: +# $ modbus-proxy --config-file /etc/modbus-proxy.yaml +# See also: systemd modbus-proxy.service example how to run it +# as a systemd service. +# +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + app: modbus-proxy + name: modbus-proxy-config + namespace: modbus-proxy +data: + #Example config + config.yaml: | + devices: + - modbus: # First proxy configuration + url: modbus.host:502 # modbus connection (the modbus device url) + timeout: 10 # communication timeout [s] (optional, default: 10) + connection_time: 1 # delay after connection [s] (optional, default: 0) + listen: # listen interface + bind: 0:30502 # listening address (mandatory) [IP:port] + # (to which url your clients should connect) diff --git a/examples/kubernetes/20_modbus-proxy-deployment.yaml b/examples/kubernetes/20_modbus-proxy-deployment.yaml new file mode 100644 index 0000000..d01cb2d --- /dev/null +++ b/examples/kubernetes/20_modbus-proxy-deployment.yaml @@ -0,0 +1,42 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: modbus-proxy + annotations: + # Optional: trigger config reloader: https://github.com/stakater/Reloader + reloader.stakater.com/auto: "true" + name: modbus-proxy + namespace: modbus-proxy +spec: + replicas: 1 + selector: + matchLabels: + app: modbus-proxy + strategy: + type: Recreate + template: + metadata: + labels: + app: modbus-proxy + spec: + terminationGracePeriodSeconds: 1 + containers: + - args: + - -c + - /config.yaml + image: quay.io/toschneck/modbus-proxy:2024-09-21 + name: modbus-proxy + ports: + - name: modbus-outgoing + containerPort: 30502 + protocol: TCP + volumeMounts: + - mountPath: /config.yaml + name: modbus-proxy-config + subPath: config.yaml + restartPolicy: Always + volumes: + - configMap: + name: modbus-proxy-config + name: modbus-proxy-config diff --git a/examples/kubernetes/30_modbus-proxy-service.yaml b/examples/kubernetes/30_modbus-proxy-service.yaml new file mode 100644 index 0000000..3155085 --- /dev/null +++ b/examples/kubernetes/30_modbus-proxy-service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: modbus-proxy + name: modbus-proxy + namespace: modbus-proxy +spec: + type: ClusterIP + ports: + ### modbus proxy to mirror traffic from e.g. Huawei pv + - name: modbusproxy + port: 502 + protocol: TCP + targetPort: 30502 + #nodePort: 30502 + selector: + app: modbus-proxy