Adding RStudio to Anaconda Enterprise (AE) 5

This topic covers how to install RStudio and use it within AE5.

Note

Anaconda recommends installing RStudio during a scheduled maintenance interval to prevent users from creating new sessions during installation. Existing sessions or deployments do not need to be halted.

Prerequisites

These instructions are written for AE version 5.5.2 or later, and require the /tools volume from managed persistence to be enabled. For more information, see Mounting an external file share.

Installing RStudio

Launch the RStudio installer project

  1. Log in to AE5 as a user with read/write access to the /tools volume. Typically, this will be the anaconda-enterprise user.
  2. Download the RStudio installer project and save it to your machine.
  3. Open a new browser window and login to AE5.
  4. Use the Create+ / Upload Project dialog to upload the RStudio installer project you just downloaded. Anaconda recommends using the JupyterLab editor for this project.
  5. Open a session for the RStudio installer project.

Obtain the RStudio Server binaries

Now that your project is created, you need to obtain and install the Red hat Package Manager (RPM) files and pull them into the project session. There are multiple methods for accomplishing this.

Downloading RStudio directly from AE5

Anaconda recommends users with clusters that have internet access download RStudio directly through AE5.

  1. From your RStudio project session, open a new terminal window.
  2. If you need to set proxy variables manually to access the internet, do so now.
  3. Run the command:
bash download_rstudio.sh

The output from the script will look something like this:

+------------------------+
| AE5 RStudio Downloader |
+------------------------+
- Target version: 2021.09.1-372
- Downloading into the data directory
- Downloading RHEL8/CentOS8 RPM file to data/rs-centos8.rpm
- URL: https://download2.rstudio.org/server/centos8/x86_64/rstudio-server-rhel-2021.09.1-372-x86_64.rpm
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                Dload  Upload   Total   Spent    Left  Speed
100 58.3M  100 58.3M    0     0   250M      0 --:--:-- --:--:-- --:--:--  249M
- Verifying data/rs-centos8.rpm
- Downloading RHEL7/CentOS7 RPM file to data/rs-centos7.rpm
- URL: https://download2.rstudio.org/server/centos7/x86_64/rstudio-server-rhel-2021.09.1-372-x86_64.rpm
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 58.3M  100 58.3M    0     0   193M      0 --:--:-- --:--:-- --:--:--  193M
- Verifying data/rs-centos7.rpm
+------------------------+
The RStudio binaries have been downloaded.
You may now proceed with the installation step.
See the README.md file for more details.
+------------------------+

Using the download script on another Unix server

If you need to download the binaries on a separate machine first, use the download_rstudio.sh script.

  1. Download the script file download_rstudio.sh from the project to your desktop.

  2. Move the script file to a machine that can run bash and curl and has connectivity to download2.rstudio.org.

  3. Run the command:

    bash download_rstudio.sh
    
  4. If necessary, transfer the binaries rs-centos7.rpm and rs-centos8.rpm to the machine from which you access AE5.

  5. Use the JuptyerLab upload button to upload both binaries into the RStudio installer project.

Manually obtaining the files

If it is not possible for you to use the download_rstudio.sh script, you must obtain the files manually.

The installation process requires two different RPM files that have identical filenames. For this reason, obtaining the files manually requires that each file is renamed after downloading.

  1. Download the CentOS 8 RPM:

    https://download2.rstudio.org/server/centos8/x86_64/rstudio-server-rhel-2021.09.0-351-x86_64.rpm
    
  2. Rename this file rs-centos8.rpm.

  3. Download the CentOS 7 RPM:

    https://download2.rstudio.org/server/centos7/x86_64/rstudio-server-rhel-2021.09.0-351-x86_64.rpm
    
  4. Rename this file rs-centos7.rpm.

  5. If necessary, transfer the files to the machine you use to access AE5.

  6. Use JuptyerLab’s upload button to upload both binaries into the RStudio installer project.

Run the installation script

Now that you have obtained the RStudio binaries and placed the rs-centos7.rpm and rs-centos8.rpm files in the correct locations:

  1. Open a terminal window.
  2. If you have previously installed content into /tools/rstudio, remove it now. Run the command:
  3. Run the command:

Note

The script will verify that all prerequisites are met before performing any file modifications.

The output from the installer will look like this:

+-----------------------+
| AE5 RStudio Installer |
+-----------------------+
- Install prefix: /tools/rstudio
- Verifying data/rs-centos8.rpm
- Verifying data/rs-centos7.rpm
- Creating directory /tools/rstudio
- Staging full RHEL8/CentOS8 package
1069677 blocks
- Staging RHEL7/CentOS7 rsession binary
1069390 blocks
- Moving files into final position
- Installing support files
+-----------------------+
RStudio installation is complete.
Once you have verified the installation, feel free to
shut down this session and delete the project.
+-----------------------+

Enable RStudio as an editor

With installation complete, the next step is to add RStudio to the editor selection list within AE5s User Interface (UI).

  1. Return to the anaconda-platform ConfigMap editor you left open earlier and search for the rstudio: section of the file. The default values in this section will look like this:
  2. Change the value hidden: true to hidden: false.
  3. Once you have verified the correct formatting, click Save Changes.
  4. Return to the kubectl terminal window you left open earlier and restart the UI pod:
kubectl get pods | grep 'ap-ui-' | cut -d' ' -f1 | xargs kubectl delete pods

Note

Minor disruptions in UI responsiveness may occur while the pod is stabilizing. If you have allowed users to continue working during this installation, they may need to refresh their browsers.

Once the UI pod stabilizes, the RStudio editor will be present in the Default Editor dropdown on the project’s Settings page.

With RStudio enabled as an editor, your Op-Center will typically look like this:

../../_images/ops-center-rstudio.png

Verify your installation

  1. If necessary, stop the session for your RStudio installer project.
  2. Go to the project’s Settings page.
  3. Select RStudio in the Default Editor dropdown, and click Save.
  4. Start a new session and wait for the editor to launch.
../../_images/rstudio-editor.png

If your installation is unsuccessful:

  1. Click on the Logs tab.
  2. Search the editor logs for a section titled AE5 R Session Manager and look for errors there and below.
  3. Copy the full content of this log so it can be shared with Anaconda.
  4. Stop the session completely.
  5. Go to the project’s Settings page, and change the Default Editor back to JupyterLab.
  6. If your errors are obvious to you and understand what corrective action is needed, open a new session to make those changes.

Please reach out to Anaconda support if this occurs. Make sure to include a copy of the editor logs you obtained above.

Disabling RStudio

To remove RStudio as an editor option for new projects:

  1. Open your anaconda-platform.yml ConfigMap.

  2. Search for the rstudio: section of this file. The default values in this section will look like this:

    rstudio:
       default: false
       hidden: true
       label: RStudio
    
  3. Once you have verified the correct formatting, click Save Changes.

  4. Return to the kubectl terminal window you left open earlier and restart the UI pod:

    kubectl get pods | grep ap-ui | cut -d ' ' -f 1 | xargs kubectl delete pods
    

Existing projects that have RStudio installed will still have access to the editor. You can revert hidden: false to hidden: true at any time to re-enable RStudio as an editor option for new projects.

Uninstalling RStudio

Caution

If you need to permanently remove /tools/rstudio, instruct all users to stop all sessions currently using RStudio and choose a different editor, such as JupyterLab, before continuing. If they do not, sessions will fail to fully start.

To permanently uninstall RStudio, you need to remove the /tools/rstudio directory. Anaconda recommends removing the directory from outside AE5 if possible. If necessary, instructions are provided to remove RStudio using AE5.

Uninstalling RStudio using AE5

  1. Log in to AE5 as a user with read/write access to the /tools volume. Typically, this will be the anaconda-enterprise user.
  2. Remove /tools/rstudio from within an AE5 session. Run the command:
rm -r /tools/rstudio

Upgrading to a new version of AE5

Upgrading to a new version of AE5 will not affect your RStudio installation; however, the upgrade process will cause the editor to be hidden. Once the upgrade is complete, you’ll need to enable RStudio as an editor again.

Upgrading RStudio

Anaconda recommends performing a fresh installation when upgrading RStudio.

  1. Launch the RStudio installation project.

  2. Obtain the RStudio server binaries.

  3. (Optional) Rename your existing RStudio directory. If your installation is unsuccessful for any reason, you can rename the existing RStudio directory back to its original state to avoid downtime. Run the command:

    mv /tools/rstudio /tools/rstudio.old
    
  4. Instruct all users to stop all sessions currently using RStudio.

  5. Run the installation script.

  6. Enable RStudio as an editor.

  7. Verify your installation.

  8. If necessary, remove the old installation /tools/rstudio.old. Run the command:

    rm -r /tools/rstudio.old
    
  9. Log out of AE5.

Installing RStudio on additional AE5 instances

Once you have successfully installed RStudio on one instance, you can copy and move the /tools/rstudio directory to another instance, reducing the amount of work involved for a second install.

Create an archive of an existing installation

  1. Log in to an instance of AE5 with a running RStudio installation.

  2. Open a session using the JupyterLab editor.

  3. Open a terminal window.

  4. Create the archive. Run the command:

    tar cfz rstudio.tar.gz -C /tools rstudio
    
  5. Download this file to your desktop. Once you have done so, you can remove the file from your AE5 session.

Move the archive to a new instance

  1. Open any session using the JupterLab editor.

  2. Upload the archive rstudio.tar.gz into the project.

  3. Open a terminal window.

  4. (Optional) Rename your existing RStudio directory. If your installation is unsuccessful for any reason, you can rename the existing RStudio directory back to its original state to avoid downtime. Run the command:

    mv /tools/rstudio /tools/rstudio.old
    
  5. Install the archive. Run the command:

    tar xfz rstudio.tar.gz -C /tools
    
  6. Verify your installation.

  7. If necessary, remove the old installation /tools/rstudio.old. Run the commmand:

    rm -r /tools/rstudio.old
    
  8. Enable RStudio as an editor.

  9. Log out of AE5.