open-rmf / rmf_deployment_template

This repo provides a template to deploy RMF
Apache License 2.0
16 stars 11 forks source link

Is there a recommended way to add your own building + nav + config yamls into a deployment? #19

Closed jh-chng closed 1 year ago

jh-chng commented 2 years ago

Feature request

Ideally, I would like to be able to separate my site specific files (png, config yamls, etc.) from my deployment files. Appreciate any suggestions in advance.

I understand the current way to insert such files is from a rmf-site.yaml file. But inserting it directly causes a files too large issue during helm install, especially when dealing with floorplans of multiple levels. This would require inserting PNGs in the form of binarydumps.

Inserting files from outside helm is not an option by design. May I ask what would be the recommendation on this?

Description

In my current setup, I put all such files into the helm charts folder charts/rmf-core-modules, and I have configmaps pointing to them. But this gets unmanageable and messy very quickly.

To duplicate the error described above on file being too large, you could run the following in a kubernetes cluster:

git clone https://github.com/sharp-rmf/rmf-deployment/tree/galen
mv ./rmf-deployment/charts/rmf-core-modules/* ./rmf-deployment # Agree to overwrite warning
helm install rmf-deployment rmf-core-modules

The error:

Error: create: failed to create: Secret "sh.helm.release.v1.rmf-deployment.v1" is invalid: data: Too long: must have at most 1048576 bytes

Implementation considerations

To provide a way to manage site specific files without compromising on the continuous deployment aspect.

Additional information

K8s version: v1.24.4+k3s1 Docker version: Docker version 20.10.16, build aa7e414 RMF version: Following main branch as much as possible

JohnTGZ commented 1 year ago

The following is just a recommendation as there are multiple ways to achieve your aims.

Your site-specific files do not have to be in the continuous deployment workflow and can exist in a separate github repository. This github repository (with the specified git commit/branch ) can then be cloned into your CI branch's github actions workflow like so:

    steps:
      ...

      - 
        name: Clone site-specific repo
        uses: actions/checkout@v3
        with:
          repository: user/site-specific-repo
          ref: <GIT_COMMIT_SHA / BRANCH_NAME>
          # Take note of the path here, it will be used in building your RMF Site image
          path: site-repo
       ...

Going back to the build branch main. Here, you will have to create a docker file to build your site-specific image on top of the RMF base image. This image will be where you will copy your site-specific files (that have been cloned in the github actions workflow).

An example is provided below:

FROM $REGISTRY_BASE/rmf_base_img:$TAG

# Copy over site-specific configurations and files 
COPY site-repo /opt/rmf/src/site-repo

SHELL ["bash", "-c"]

WORKDIR /opt/rmf

# Build your workspace
RUN . /opt/ros/$ROS_DISTRO/setup.sh \
  && /ros_entrypoint.sh \
  colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["bash"]

Following suit, in your continuous deployment branch cloud_infra you can then use the environment variables in values.yaml file to hold the path to your site-specific configurations (which are now in your rmf site image). One such variable RMF_BUILDING_MAP_SERVER_CONFIG_PATH has been provided. This value can then be provided to your rmf-site pods as in the rmf-site.yaml file.

This approach separates your site deployment configurations from the core RMF images. You can quickly iterate on your site deployment configurations in a separate repo without having to continoually push to the continous deployment repo.

jh-chng commented 1 year ago

So it's been awhile, I think this can be closed.

Just a note on the above approach, this would imply the git repo would need to be public (there maybe an approach with private repos which I am not aware of). Which may not be suitable for site-specific resources like floorplans.

JohnTGZ commented 1 year ago

@JunHaoChng Yes, you can achieve the same thing with private repos too! Most modern CD tools should support SSH/HTTPS Git credentials: https://argo-cd.readthedocs.io/en/stable/user-guide/private-repositories/