Code Monkey home page Code Monkey logo

ros-kubernetes's Introduction

ros-kubernetes

WhatInstallBuildRunResources

What

This repository stores a simple kubernetes setup to run the ROS robotic middleware on a distributed cluster. To our knowledge, most of the available tutorials and examples are either outdated or not well documented. Some of them are reported in the Resources section.

This setup is composed of three deployments, each of them running a single-container pod:

  • roscore-deployment Runs the roscore process
  • talker-deployment Publishes a string message to the /chatter topic
  • listener-deployment Subscribes to the /chatter topic and echoes the string

Install

The quicker way to run this kubernetes setup is creating a local cluster with tools such as minikube or kind. Since this is a very trivial setup, we'll be using kind which provides an easy and lightweight cluster. We assume that you already have docker, docker-compose, and kubectl installed, configured, and running in your machine.

Install kind

Refer to the kind repository for the official installation instructions. We'll recap here below the steps we followed:

git clone --depth 1 https://github.com/kubernetes-sigs/kind
cd kind
make build

Then, either add the <path-to-cloned-kind-repo>/bin/ folder to your PATH or add alias kind='<path-to-cloned-kind-repo>/bin/kind' to your ~/.bashrc.

Build the images

All the ROS pods will be running the official ros/melodic-ros-core image. To simplify the kubernetes and kind setup, we extended the official image with minor modifications. You can find the Dockerfiles in the docker folder.

Execute the following commands to build the ROS images:

cd docker
docker-compose -f build-ros-cluster.yml build

After this, make sure with docker images that the following images have been successfully built:

  • roscluster/master:v0
  • roscluster/node:v0

Run the setup

The first step to run the setup is starting a local cluster. Execute:

kind create cluster
export KUBECONFIG="$(kind get kubeconfig-path)"

Make sure executing docker ps -a that the kindest/node:v1.14.2 container is up and running. Also check that the cluster is running:

$ kubectl get all
NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE                                                          
service/kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   1d17h

Then, load the docker images we built into the local cluster:

kind load docker-image roscluster/master:v0
kind load docker-image roscluster/node:v0

The kubernetes setup is stored in the k8s folder. Execute the following to run the setup:

cd k8s
kubectl create -f .

The three deployments should now start. The talker and listener deployments will likely fail at the first attempt because they need to reach first roscore. Their deployment has an initContainer that tries to connect to roscore and restart the pod if it fails. Furthermore, if during their execution the roscore container fails or is restarted, a livenessProbe will restart the talker and listener containers.

Once that the cluster is running, you should have the following kubectl get all output:

NAME                                      READY   STATUS    RESTARTS   AGE
pod/listener-deployment-c7bfb7856-7lhz2   1/1     Running   1          37s
pod/roscore-deployment-7dd8db86d9-cxb7x   1/1     Running   0          37s
pod/talker-deployment-97cbb7744-b6gdr     1/1     Running   1          37s

NAME                              TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)           AGE
service/kubernetes                ClusterIP      10.96.0.1      <none>        443/TCP           3d17h
service/service-listener          ClusterIP      None           <none>        11311/TCP         37s
service/service-master            ClusterIP      None           <none>        11311/TCP         37s
service/service-talker            ClusterIP      None           <none>        11311/TCP         37s

NAME                                  READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/listener-deployment   1/1     1            1           37s
deployment.apps/roscore-deployment    1/1     1            1           37s
deployment.apps/talker-deployment     1/1     1            1           37s

NAME                                            DESIRED   CURRENT   READY   AGE
replicaset.apps/listener-deployment-c7bfb7856   1         1         1       37s
replicaset.apps/roscore-deployment-7dd8db86d9   1         1         1       37s
replicaset.apps/talker-deployment-97cbb7744     1         1         1       37s

You can get the listener log containing the topic message executing kubectl logs -l node=listener (note that the log is cut using label selectors, use the listener pod name for a complete log).

Resources

ros-kubernetes's People

Contributors

diegoferigo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ros-kubernetes's Issues

Communicate to roscore from outside the cluster

This repository contains a simple setup to get ROS running in a kubernetes cluster. If all ROS nodes are deployed within the same cluster, headless services would suffice to connect all their pods.

However, external communication is not that straightforward and should be further investigated. I'm not even sure if it is actually possible to have an external ROS node that communicates with both the roscore and other nodes running within the cluster.

My initial attempts using LoadBalancer services all failed. It would be great if anyone with more kubernetes knowledge is willing to investigate more this use-case and report their results. Existing solutions (as rdbox-intec/rdbox) use a dedicated VPN connection, but despite it is a valid solution, it would be ideal obtaining a setup that only uses kubernetes networking.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.