diff --git a/docs/ROS2_Deployment_Intermediate.md b/docs/ROS2_Deployment_Intermediate.md index f04406d..53e15fe 100644 --- a/docs/ROS2_Deployment_Intermediate.md +++ b/docs/ROS2_Deployment_Intermediate.md @@ -19,22 +19,57 @@ To control the capability such as `which node has display`, it will use node lab **see deployment description [ROS 2 turtlesim and rqt](./../yaml/ros2-turtlesim.yaml)** -![ROS 2 Turtlesim and Rqt Example](./../images/ros2_turtlesim_sample.png) +![ROS 2 Turtlesim and Rqt Overview](./../images/ros2_turtlesim_overview.png) + +- Disable xhost access control + +```bash +tomoyafujita@~/DVT >xhost +local:root +non-network local connections being added to access control list +``` - Labeling the display capability. + In this example, `edgeserver` is the server runs GUI capability, but `edgedevice`. + ```bash -xxx +root@tomoyafujita-HP-Compaq-Elite-8300-SFF:~# kubectl label nodes tomoyafujita-hp-compaq-elite-8300-sff nodetype=edgeserver +root@tomoyafujita-HP-Compaq-Elite-8300-SFF:~# kubectl label nodes ubuntu nodetype=edgedevice +root@tomoyafujita-HP-Compaq-Elite-8300-SFF:~# kubectl get nodes --show-labels +NAME STATUS ROLES AGE VERSION LABELS +tomoyafujita-hp-compaq-elite-8300-sff Ready control-plane 63m v1.25.5 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=tomoyafujita-hp-compaq-elite-8300-sff,kubernetes.io/os=linux,node-role.kubernetes.io/control-plane=,node.kubernetes.io/exclude-from-external-load-balancers=,nodetype=edgeserver +ubuntu Ready 45m v1.25.5 beta.kubernetes.io/arch=arm64,beta.kubernetes.io/os=linux,kubernetes.io/arch=arm64,kubernetes.io/hostname=ubuntu,kubernetes.io/os=linux,nodetype=edgedevice ``` -- Start turtlesim and rqt on the node with display. +- Start turtlesim and rqt on `edgeserver`, and start bash process node in `edgedevice`. ```bash -xxx +root@tomoyafujita-HP-Compaq-Elite-8300-SFF:/ros_k8s/yaml# kubectl apply -f ros2-turtlesim.yaml +deployment.apps/ros2-turtlesim-gui created +deployment.apps/rqt created +deployment.apps/ros2-teleop-key created ``` - Use `turtle_teleop_key` to control the turtlesim. + process is already running in the cluster system on the host `edgedevice` labeled, so we can jump in the container `turtle_teleop_key` via kubernetes command as below. + ```bash -xxx -``` \ No newline at end of file +root@tomoyafujita-HP-Compaq-Elite-8300-SFF:/ros_k8s/yaml# kubectl get pods +NAME READY STATUS RESTARTS AGE +ros2-teleop-key-75f7c5475c-s6hwj 1/1 Running 0 33s +ros2-turtlesim-gui-849df7c66b-gzmt9 1/1 Running 0 33s +rqt-5886589dfc-v8q92 1/1 Running 0 33s +root@tomoyafujita-HP-Compaq-Elite-8300-SFF:/ros_k8s/yaml# kubectl exec --stdin --tty ros2-teleop-key-75f7c5475c-s6hwj -- /bin/bash + +root@ros2-teleop-key-75f7c5475c-s6hwj:/# source /opt/ros/rolling/setup.bash +root@ros2-teleop-key-75f7c5475c-s6hwj:/# ros2 run turtlesim turtle_teleop_key +Reading from keyboard +--------------------------- +Use arrow keys to move the turtle. +Use G|B|V|C|D|E|R|T keys to rotate to absolute orientations. 'F' to cancel a rotation. +'Q' to quit. +... +``` + + diff --git a/images/ros2_turtlesim_output.png b/images/ros2_turtlesim_output.png new file mode 100644 index 0000000..3e2dcf6 Binary files /dev/null and b/images/ros2_turtlesim_output.png differ diff --git a/images/ros2_turtlesim_overview.png b/images/ros2_turtlesim_overview.png new file mode 100644 index 0000000..015529e Binary files /dev/null and b/images/ros2_turtlesim_overview.png differ diff --git a/images/system_overview.odp b/images/system_overview.odp index 8f465a4..0c4cc5c 100644 Binary files a/images/system_overview.odp and b/images/system_overview.odp differ diff --git a/yaml/ros2-turtlesim.yaml b/yaml/ros2-turtlesim.yaml new file mode 100644 index 0000000..a11c4e9 --- /dev/null +++ b/yaml/ros2-turtlesim.yaml @@ -0,0 +1,131 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ros2-turtlesim-gui +spec: + replicas: 1 + selector: + matchLabels: + app: ros2-turtlesim-gui + template: + metadata: + labels: + app: ros2-turtlesim-gui + spec: + containers: + - image: tomoyafujita/ros:rolling + command: ["/bin/bash", "-c"] + args: ["source /opt/ros/$ROS_DISTRO/setup.bash && ros2 run turtlesim turtlesim_node"] + imagePullPolicy: IfNotPresent + tty: true + name: ros2-turtlesim-gui + ### mounting host file to container + volumeMounts: + - mountPath: /tmp/.X11-unix + name: xserver + ### bind host environment variable to container + env: + - name: DISPLAY + value: ":1" # can this be host variable instead? + ### select the node with GUI for this deployment + nodeSelector: + nodetype: edgeserver + ### bind the host xserver unix to the container + volumes: + - name: xserver + hostPath: + path: /tmp/.X11-unix + type: Directory # host should have this always + tolerations: + - key: node-role.kubernetes.io/master + operator: Exists + effect: NoSchedule + - key: node-role.kubernetes.io/control-plane + operator: Exists + effect: NoSchedule + restartPolicy: Always + +--- + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: rqt +spec: + replicas: 1 + selector: + matchLabels: + app: rqt + template: + metadata: + labels: + app: rqt + spec: + containers: + - image: tomoyafujita/ros:rolling + command: ["/bin/bash", "-c"] + args: ["source /opt/ros/$ROS_DISTRO/setup.bash && rqt"] + imagePullPolicy: IfNotPresent + tty: true + name: rqt + ### mounting host file to container + volumeMounts: + - mountPath: /tmp/.X11-unix + name: xserver + ### bind host environment variable to container + env: + - name: DISPLAY + value: ":1" # can this be host variable instead? + ### select the node with GUI for this deployment + nodeSelector: + nodetype: edgeserver + ### bind the host xserver unix to the container + volumes: + - name: xserver + hostPath: + path: /tmp/.X11-unix + type: Directory # host should have this always + tolerations: + - key: node-role.kubernetes.io/master + operator: Exists + effect: NoSchedule + - key: node-role.kubernetes.io/control-plane + operator: Exists + effect: NoSchedule + restartPolicy: Always + +--- + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ros2-teleop-key +spec: + replicas: 1 + selector: + matchLabels: + app: ros2-teleop-key + template: + metadata: + labels: + app: ros2-teleop-key + spec: + containers: + - image: tomoyafujita/ros:rolling + command: ["/bin/bash", "-c"] + #args: ["source /opt/ros/$ROS_DISTRO/setup.bash && ros2 run turtlesim turtle_teleop_key"] + args: ["/bin/bash"] + imagePullPolicy: IfNotPresent + tty: true + name: ros2-teleop-key + ### select the node w/o GUI for this deployment + nodeSelector: + nodetype: edgedevice + tolerations: + - key: node-role.kubernetes.io/master + operator: Exists + effect: NoSchedule + - key: node-role.kubernetes.io/control-plane + operator: Exists + effect: NoSchedule + restartPolicy: Always \ No newline at end of file