Add initial ROS core chart for drone demo
Change-Id: I065c9640a1d965e53b8a691413d59a41c278dece
diff --git a/apps/ros-core/Chart.yaml b/apps/ros-core/Chart.yaml
new file mode 100644
index 0000000..2b7ba30
--- /dev/null
+++ b/apps/ros-core/Chart.yaml
@@ -0,0 +1,10 @@
+# Copyright 2021-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+apiVersion: v1
+description: ROS-Core chart for Drone use-case
+name: ros-core
+icon: https://guide.opencord.org/logos/cord.svg
+
+version: 0.1.0
diff --git a/apps/ros-core/templates/_helpers.tpl b/apps/ros-core/templates/_helpers.tpl
new file mode 100644
index 0000000..706bdf7
--- /dev/null
+++ b/apps/ros-core/templates/_helpers.tpl
@@ -0,0 +1,28 @@
+{{- /*
+
+# Copyright 2020-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+*/ -}}
+
+{{/*
+Renders a set of standardised labels.
+*/}}
+{{- define "ros-core.metadata_labels" -}}
+{{- $application := index . 0 -}}
+{{- $context := index . 1 -}}
+release: {{ $context.Release.Name }}
+app: {{ $application }}
+{{- end -}}
+
+{{/*
+Render the given template.
+*/}}
+{{- define "ros-core.template" -}}
+{{- $name := index . 0 -}}
+{{- $context := index . 1 -}}
+{{- $last := base $context.Template.Name }}
+{{- $wtf := $context.Template.Name | replace $last $name -}}
+{{ include $wtf $context }}
+{{- end -}}
diff --git a/apps/ros-core/templates/bin/_run_roscore.sh.tpl b/apps/ros-core/templates/bin/_run_roscore.sh.tpl
new file mode 100644
index 0000000..66b3402
--- /dev/null
+++ b/apps/ros-core/templates/bin/_run_roscore.sh.tpl
@@ -0,0 +1,16 @@
+#!/bin/bash
+# Copyright 2021-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+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 }}
+source /opt/ros/melodic/setup.bash && roscore;
+{{ end }}
diff --git a/apps/ros-core/templates/configmap-roscore.yaml b/apps/ros-core/templates/configmap-roscore.yaml
new file mode 100644
index 0000000..a2cfa8f
--- /dev/null
+++ b/apps/ros-core/templates/configmap-roscore.yaml
@@ -0,0 +1,14 @@
+# Copyright 2021-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: ros-core
+ labels:
+{{ tuple "ros-core" . | include "ros-core.metadata_labels" | indent 4 }}
+data:
+ run_roscore.sh: |
+{{ tuple "bin/_run_roscore.sh.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
new file mode 100644
index 0000000..85dacfb
--- /dev/null
+++ b/apps/ros-core/templates/statefulset-roscore.yaml
@@ -0,0 +1,40 @@
+# Copyright 2021-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+ name: ros-core
+ labels:
+{{ tuple "ros-core" . | include "ros-core.metadata_labels" | indent 4 }}
+spec:
+ replicas: 1
+ serviceName: ros-core
+ selector:
+ matchLabels:
+{{ tuple "ros-core" . | include "ros-core.metadata_labels" | indent 6 }}
+ template:
+ metadata:
+ labels:
+{{ tuple "ros-core" . | include "ros-core.metadata_labels" | indent 8 }}
+ spec:
+ hostNetwork: true
+ containers:
+ - name: ros-core
+ image: {{ .Values.images.tags.rosCore }}
+ imagePullPolicy: {{ .Values.images.pullPolicy }}
+ securityContext:
+ privileged: true
+ command:
+ - /root/run_roscore.sh
+ volumeMounts:
+ - name: ros-core
+ mountPath: /root/run_roscore.sh
+ subPath: run_roscore.sh
+ volumes:
+ - name: ros-core
+ configMap:
+ name: ros-core
+ defaultMode: 493
diff --git a/apps/ros-core/values.yaml b/apps/ros-core/values.yaml
new file mode 100644
index 0000000..74386c0
--- /dev/null
+++ b/apps/ros-core/values.yaml
@@ -0,0 +1,32 @@
+# Copyright 2021-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+images:
+ tags:
+ rosCore: registry.central.aetherproject.net/drone-ros:v0.1.0
+ pullPolicy: IfNotPresent
+
+nodeSelector:
+ enabled: true
+ rosCore:
+ label: drone-ros-core
+ value: enabled
+
+resources:
+ enabled: false
+
+config:
+ rosCore:
+ debug: false
+ droneList:
+ - name: drone1
+ domain: "drone1"
+ ipAddr: 10.250.255.251
+ - name: drone2
+ domain: "drone2"
+ ipAddr: 10.250.255.250
+
+networks:
+ hostNetwork: true
+