How to deploy the Spotfire R-Service in Kubernetes with additional R packages installed

How to deploy the Spotfire R-Service in Kubernetes with additional R packages installed

book

Article ID: KB0070354

calendar_today

Updated On:

Products Versions
Spotfire Server 14.2.0 and later

Description

In most cases, if you are using the Spotfire R Service, you will require some additional 3rd party R packages to be installed. For Kubernetes deployments using the Spotfire Cloud Deployment Kit (CDK), this can be challenging if any of these packages require additional system libraries to be installed on the OS that runs the R Service.

Follow the steps outlined below to install the 'arrow' R package. This is an example of a 3rd party package that requires additional steps other than those already mentioned in the CDK documentation. 

Arrow documentation reference
 

Resolution

1. Open spotfire-cloud-deployment-kit/containers/images/spotfire-rservice/additional-packages.txt in a text editor, and add the word 'arrow' to the first line. Then save the change. When building the Docker image in a later step, Docker will look to the additional-packages.txt file, and execute R's 'install.packages()' method to install any packages you've added to the list.

2. Add the directive to run 'arrow::install_arrow()' to spotfire-cloud-deployment-kit/containers/images/spotfire-rservice/Dockerfile. This should be done immediately after the 'install.packages' line. This is an extra step for packages like arrow, which require additional system libraries to be built and installed on the resulting Docker container image.

Example:
 
# Install any additional packages, also /opt/packages (see packagePath) can be used for additional packages
COPY --chown=spotfire:spotfire additional-packages.txt /tmp
RUN R --quiet -e 'install.packages(readLines(file("/tmp/additional-packages.txt", "r")))' \
&& rm /tmp/additional-packages.txt
RUN R --quiet -e 'arrow::install_arrow()'

3. Navigate to the spotfire-cloud-deployent-kit/containers/ directory, and run 'make build' to build your Docker images.

Note that since additional system libraries need to be built and installed, the 'make build' step will now take longer to complete.

4. Deploy the spotfire-server pod as noted in the CDK Help on Github, or review this KB article for guidance.

5. Deploy the spotfire-rservice pod as noted in the CDK Help https://github.com/spotfiresoftware/spotfire-cloud-deployment-kit/tree/main/helm/charts/spotfire-rservice

Issue/Introduction

Outlines the basic steps needed to use the Spotfire Cloud Deployment Kit (CDK) to deploy the Spotfire R Service with additional 3rd party R packages installed.