Update roscore to have separate dns and use official ros
Change-Id: Ifb28800bfaba66907ab8178caad5e229d484d848
diff --git a/apps/ros-core/templates/bin/_net_listener.tpl b/apps/ros-core/templates/bin/_net_listener.tpl
new file mode 100644
index 0000000..5fd5f28
--- /dev/null
+++ b/apps/ros-core/templates/bin/_net_listener.tpl
@@ -0,0 +1,15 @@
+# Copyright 2019-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+import argparse, socket
+from socket import gethostbyaddr
+from datetime import datetime
+
+sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+sock.bind(('0.0.0.0', {{ .Values.config.droneNetListener.port }}))
+print('Listening at {}'.format(sock.getsockname()))
+while True:
+ data, address = sock.recvfrom(65535)
+ text = data.decode('ascii')
+ print('The client at {} says {!r}'.format(address, text))
diff --git a/apps/ros-core/templates/bin/_run_roscore.sh.tpl b/apps/ros-core/templates/bin/_run_roscore.sh.tpl
index 66b3402..54eff77 100644
--- a/apps/ros-core/templates/bin/_run_roscore.sh.tpl
+++ b/apps/ros-core/templates/bin/_run_roscore.sh.tpl
@@ -5,10 +5,6 @@
set -ex
-{{- range .Values.config.rosCore.droneList }}
-echo "{{ .ipAddr }} {{ .domain }}" >> /etc/hosts
-{{- end }}
-
{{ if .Values.config.rosCore.debug }}
while true; do sleep 3600; done;
{{ else }}
diff --git a/apps/ros-core/templates/configmap-roscore.yaml b/apps/ros-core/templates/configmap-roscore.yaml
index a2cfa8f..5a7680f 100644
--- a/apps/ros-core/templates/configmap-roscore.yaml
+++ b/apps/ros-core/templates/configmap-roscore.yaml
@@ -12,3 +12,5 @@
data:
run_roscore.sh: |
{{ tuple "bin/_run_roscore.sh.tpl" . | include "ros-core.template" | indent 4 }}
+ net_listener.py: |
+{{ tuple "bin/_net_listener.tpl" . | include "ros-core.template" | indent 4 }}
diff --git a/apps/ros-core/templates/statefulset-roscore.yaml b/apps/ros-core/templates/statefulset-roscore.yaml
index 58ac1cc..28cb41a 100644
--- a/apps/ros-core/templates/statefulset-roscore.yaml
+++ b/apps/ros-core/templates/statefulset-roscore.yaml
@@ -24,19 +24,39 @@
nodeSelector:
{{ .Values.nodeSelector.rosCore.label }}: {{ .Values.nodeSelector.rosCore.value }}
{{- end }}
- hostNetwork: {{ .Values.networks.hostNetwork }}
+ {{- if .Values.networks.hostNetwork }}
+ hostNetwork: true
+ dnsPolicy: None
+ dnsConfig:
+ nameservers:
+ - {{ .Values.coredns.service.clusterIP }}
+ {{- end }}
containers:
- name: ros-core
image: {{ .Values.images.tags.rosCore }}
imagePullPolicy: {{ .Values.images.pullPolicy }}
securityContext:
privileged: true
+ stdin: true
+ tty: true
command:
- /root/run_roscore.sh
volumeMounts:
- name: ros-core
mountPath: /root/run_roscore.sh
subPath: run_roscore.sh
+ - name: drone-net-listener
+ image: {{ .Values.images.tags.droneNetListener }}
+ imagePullPolicy: {{ .Values.images.pullPolicy }}
+ stdin: true
+ tty: true
+ command: ["bash", "-xc"]
+ args:
+ - python /opt/net_listener.py
+ volumeMounts:
+ - name: ros-core
+ mountPath: /opt/net_listener.py
+ subPath: net_listener.py
volumes:
- name: ros-core
configMap: