View on GitHub

core

Cloud Robotics Core: Kubernetes, Federation, App Management

Connecting a robot to the cloud

Estimated time: 10 min

This page describes how to connect a Kubernetes cluster on a robot to the cloud (tested on Ubuntu 14, 16 and 18).

Once you’ve done this, you can:

Setting up the GCP project

  1. If you haven’t already, complete the Setting up the GCP project steps.

  2. On the computer you used to set up the cloud project, generate an access token, which you’ll use to give the robot access to the cloud:

     gcloud auth application-default print-access-token
    

Installing the cluster on the robot

You’ll need to install a Kubernetes cluster on the robot before you can connect it to the cloud. The cluster manages and supports the processes that communicate with the cloud.

The installation script installs and configures:

  1. Download and run install_k8s_on_robot.sh. This script will take a few minutes as it downloads and installs the dependencies of the Kubernetes cluster.

     $ curl https://raw.githubusercontent.com/googlecloudrobotics/core/master/src/bootstrap/robot/install_k8s_on_robot.sh | bash
     [...]
     The local Kubernetes cluster has been installed.
    

    After the script successfully finishes, the Kubernetes cluster is up and running.

    Note: At the end of the script output, you might notice instructions for creating ~/.kube/config, deploying a pod network, and joining nodes to the cluster. You can ignore these instructions for now, as the script has already set up a single-node cluster.

  2. Set up the robot cluster to connect to the cloud. When running setup_robot.sh, you’ll need to enter the access token you generated earlier. You may find it easiest if you SSH into the robot from the workstation you used to set up the project.

     mkdir -p ~/cloud-robotics-core
     cd ~/cloud-robotics-core
     curl https://raw.githubusercontent.com/googlecloudrobotics/core/master/src/bootstrap/robot/setup_robot.sh >setup_robot.sh
     bash setup_robot.sh my-robot --project ${PROJECT_ID} \
       --robot-type my-robot-type
    

    Set ${PROJECT_ID} to your GCP project ID. When prompted for an access token, provide the authentication token you generated earlier.

    Note: my-robot-type is a placeholder and you can ignore it for now.

What’s next

Uninstalling the local cluster

You can remove the local cluster with the following command:

sudo kubeadm reset

You may also want to remove the following APT packages and repositories, which install_k8s_on_robot.sh installs if they are not present:

sudo apt-get purge kubectl kubelet kubeadm
sudo rm /etc/apt/sources.list.d/kubernetes.list
sudo apt-get purge docker-ce
sudo add-apt-repository --remove \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"