{"id":17361015,"url":"https://github.com/diegoferigo/ros-kubernetes","last_synced_at":"2025-02-26T11:32:32.376Z","repository":{"id":54960964,"uuid":"188373486","full_name":"diegoferigo/ros-kubernetes","owner":"diegoferigo","description":"A minimal setup to run a simple publisher-subscriber ROS application in a kubernetes cluster","archived":false,"fork":false,"pushed_at":"2021-01-19T14:53:51.000Z","size":6,"stargazers_count":43,"open_issues_count":2,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-06-19T00:46:22.615Z","etag":null,"topics":["cloud","cluster","containers","distributed","docker","kind","kubernetes","middleware","robotics","ros"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/diegoferigo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-24T07:23:33.000Z","updated_at":"2024-06-19T00:46:22.615Z","dependencies_parsed_at":"2022-08-14T07:30:53.179Z","dependency_job_id":null,"html_url":"https://github.com/diegoferigo/ros-kubernetes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegoferigo%2Fros-kubernetes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegoferigo%2Fros-kubernetes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegoferigo%2Fros-kubernetes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegoferigo%2Fros-kubernetes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/diegoferigo","download_url":"https://codeload.github.com/diegoferigo/ros-kubernetes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219842692,"owners_count":16556526,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloud","cluster","containers","distributed","docker","kind","kubernetes","middleware","robotics","ros"],"created_at":"2024-10-15T19:29:46.006Z","updated_at":"2025-02-26T11:32:32.339Z","avatar_url":"https://github.com/diegoferigo.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ch1 align=\"center\"\u003eros-kubernetes\u003c/h1\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cb\u003e\u003ca href=\"https://github.com/diegoferigo/ros-kubernetes#what\"\u003eWhat\u003c/a\u003e\u003c/b\u003e\n•\n\u003cb\u003e\u003ca href=\"https://github.com/diegoferigo/ros-kubernetes#install\"\u003eInstall\u003c/a\u003e\u003c/b\u003e\n•\n\u003cb\u003e\u003ca href=\"https://github.com/diegoferigo/ros-kubernetes#build-the-images\"\u003eBuild\u003c/a\u003e\u003c/b\u003e\n•\n\u003cb\u003e\u003ca href=\"https://github.com/diegoferigo/ros-kubernetes#run-the-setup\"\u003eRun\u003c/a\u003e\u003c/b\u003e\n•\n\u003cb\u003e\u003ca href=\"https://github.com/diegoferigo/ros-kubernetes#resources\"\u003eResources\u003c/a\u003e\u003c/b\u003e\n\u003c/p\u003e\n\n## What\n\nThis repository stores a simple kubernetes setup to run the [ROS robotic middleware](http://ros.org/) 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](#resources) section.\n\nThis setup is composed of three deployments, each of them running a single-container pod:\n\n- **`roscore-deployment`** Runs the roscore process\n- **`talker-deployment`** Publishes a string message to the `/chatter` topic\n- **`listener-deployment`** Subscribes to the `/chatter` topic and echoes the string\n\n## Install\n\nThe quicker way to run this kubernetes setup is creating a local cluster with tools such as [minikube](https://kubernetes.io/docs/setup/minikube/) or [kind](https://github.com/kubernetes-sigs/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.\n\n### Install `kind`\n\nRefer to the [kind repository](https://github.com/kubernetes-sigs/kind/) for the official installation instructions. We'll recap here below the steps we followed:\n\n```bash\ngit clone --depth 1 https://github.com/kubernetes-sigs/kind\ncd kind\nmake build\n```\n\nThen, either add the `\u003cpath-to-cloned-kind-repo\u003e/bin/` folder to your `PATH` or add `alias kind='\u003cpath-to-cloned-kind-repo\u003e/bin/kind'` to your `~/.bashrc`.\n\n## Build the images\n\nAll the ROS pods will be running the [official `ros/melodic-ros-core` image](https://hub.docker.com/_/ros/). To simplify the kubernetes and kind setup, we extended the official image with minor modifications. You can find the `Dockerfile`s in the [docker](docker/) folder.\n\nExecute the following commands to build the ROS images:\n\n```bash\ncd docker\ndocker-compose -f build-ros-cluster.yml build\n```\n\nAfter this, make sure with `docker images` that the following images have been successfully built:\n\n- `roscluster/master:v0`\n- `roscluster/node:v0`\n\n## Run the setup\n\nThe first step to run the setup is starting a local cluster. Execute:\n\n```bash\nkind create cluster\nexport KUBECONFIG=\"$(kind get kubeconfig-path)\"\n```\n\nMake sure executing `docker ps -a` that the `kindest/node:v1.14.2` container is up and running. Also check that the cluster is running:\n\n```\n$ kubectl get all\nNAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE                                                          \nservice/kubernetes   ClusterIP   10.96.0.1    \u003cnone\u003e        443/TCP   1d17h\n```\n\nThen, load the docker images we built into the local cluster: \n\n```bash\nkind load docker-image roscluster/master:v0\nkind load docker-image roscluster/node:v0\n```\n\nThe kubernetes setup is stored in the [k8s](k8s/) folder. Execute the following to run the setup:\n\n```\ncd k8s\nkubectl create -f .\n```\n\nThe 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.\n\nOnce that the cluster is running, you should have the following `kubectl get all` output:\n\n```\nNAME                                      READY   STATUS    RESTARTS   AGE\npod/listener-deployment-c7bfb7856-7lhz2   1/1     Running   1          37s\npod/roscore-deployment-7dd8db86d9-cxb7x   1/1     Running   0          37s\npod/talker-deployment-97cbb7744-b6gdr     1/1     Running   1          37s\n\nNAME                              TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)           AGE\nservice/kubernetes                ClusterIP      10.96.0.1      \u003cnone\u003e        443/TCP           3d17h\nservice/service-listener          ClusterIP      None           \u003cnone\u003e        11311/TCP         37s\nservice/service-master            ClusterIP      None           \u003cnone\u003e        11311/TCP         37s\nservice/service-talker            ClusterIP      None           \u003cnone\u003e        11311/TCP         37s\n\nNAME                                  READY   UP-TO-DATE   AVAILABLE   AGE\ndeployment.apps/listener-deployment   1/1     1            1           37s\ndeployment.apps/roscore-deployment    1/1     1            1           37s\ndeployment.apps/talker-deployment     1/1     1            1           37s\n\nNAME                                            DESIRED   CURRENT   READY   AGE\nreplicaset.apps/listener-deployment-c7bfb7856   1         1         1       37s\nreplicaset.apps/roscore-deployment-7dd8db86d9   1         1         1       37s\nreplicaset.apps/talker-deployment-97cbb7744     1         1         1       37s\n```\n\nYou 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).\n\n## Resources\n\n- https://blog.zhaw.ch/icclab/challenges-with-running-ros-on-kubernetes/\n- https://googlecloudrobotics.github.io/core\n- https://rdbox-intec.github.io/homepage_en/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiegoferigo%2Fros-kubernetes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiegoferigo%2Fros-kubernetes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiegoferigo%2Fros-kubernetes/lists"}