How to Deploy RStudio (Posit) Connect into Local Kubernetes Cluster

Estimated time:

RStudio (Posit) Connect is a publishing platform that lets you and your team share R Shiny applications, R Markdown reports, APIs, dashboards, Jupyter Notebook, and interactive Python content in one convenient place. Today we'll show you how to deploy RStudio Connect to the local Kubernetes cluster with ease. Following along shouldn't take you more than 10 minutes, provided you have a valid RStudio Connect license. We'll walk you through the process step by step. We'll start by covering the prerequisites on macOS, creating a Kubernetes cluster with <code>k3d</code>, installing dependencies with Helm, configuring the Postgres database, and much more. All the shell commands you'll see are up-to-date and copy-paste-friendly. <blockquote>Looking for alternative ways to share R Shiny apps? <a href="" target="_blank" rel="noopener">Try GitHub,, and ShinyServer - All explained in our detailed guide</a>.</blockquote> Table of contents: <ul><li><a href="#prerequisites">Prerequisites to Deploying RStudio Connect to Local Kubernetes Cluster</a></li><li><a href="#local-kubernetes-cluster">How to Create Local Kubernetes Cluster with k3d</a></li><li><a href="#dependencies">Install Dependencies with Helm</a></li><li><a href="#postgres">Install the Postgres Database</a></li><li><a href="#rstudio-connect">How to Install RStudio Connect to Local Kubernetes Cluster</a></li><li><a href="#removing-deployment">Removing the Deployment</a></li><li><a href="#summary">Summary of Deploying RStudio Connect to Local Kubernetes Cluster</a></li></ul> <hr /> <h2 id="prerequisites">Prerequisites to Deploying RStudio (Posit) Connect to Local Kubernetes Cluster</h2> We assume you're using a macOS environment, but most of the commands will work on Linux as well. Before attempting to deploy RStudio Connect into Kubernetes, you’ll need a couple of software prerequisites. These are: <ul><li><a href="" target="_blank" rel="noopener">Homebrew</a> package manager</li><li>Kubernetes cluster</li><li>Valid RStudio Connect license</li></ul> Once you install Homebrew, you should also install the rest of the command-line dependencies by running: <script src=""></script> Before you can deploy resources, you'll need to have a working Kubernetes cluster. We suggest using <code>k3d</code> project for development purposes, as it allows you to create single and multi-node Kubernetes cluster in Docker. If you're wondering, <code>k3d</code> is a highly available, certified Kubernetes distribution. Up next, we'll use <code>k3d</code> to prepare a local Kubernetes cluster. <h2 id="local-kubernetes-cluster">How to Create Local Kubernetes Cluster with k3d</h2> To start, install the current latest release of <code>k3d</code> binary by running the following shell command: <script src=""></script> You can verify the binary was installed successfully by running the following command: <script src=""></script> If you did everything correctly, you'll see something similar as the output: <img class="wp-image-12810 size-full" title="Image 1 - k3d version output" src="" alt="" width="1532" height="966" /> Image 1 - k3d version output The next step is to create a cluster named <code>rstudio</code> with a single server node: <script src=""></script> From here, use this shell command to verify the cluster has been created: <script src=""></script> <img class="size-full wp-image-12812" src="" alt="" width="1532" height="966" /> Image 2 - Printing local clusters And that's it - a local Kubernetes cluster is now created. Up next, we'll install the dependencies needed to integrate RStudio Connect to our local Kubernetes cluster. <h2 id="dependencies">Install Dependencies with Helm</h2> In the Kubernetes world, there's a standardized way of deploying things. You don't have to worry about how to pass configuration options like database credentials and figure out how to tie multiple RStudio Connects together. Kubernetes uses YAML configuration files to describe resources you attempt to deploy. A layer above these files that will allow you to treat your deployment as a package is called a <b>Helm chart.</b> The best feature of RStudio Helm charts is that you don't have to write them from scratch. RStudio team has already done that for you, and these charts are already <a href="" target="_blank" rel="noopener">available</a> for public usage. Before deploying Helm charts, we need to ensure respective repositories are configured: <script src=""></script> You should see the following messages while running the above commands: <img class="size-full wp-image-12814" src="" alt="" width="1532" height="966" /> Image 3 - Installing dependencies with Helm Deploying things with Helm charts will make your life easier. You can always roll back to a previous version of your deployment or even have multiple deployments within the same Kubernetes cluster. <h2 id="postgres">Install the Postgres Database</h2> At the very minimum, the PostgreSQL Helm chart requires a database password. You can set one from the terminal easily: <script src=""></script> Next, deploy the database into Kubernetes by running the following commands: <script src=""></script> <img class="size-full wp-image-12816" src="" alt="" width="1532" height="966" /> Image 4 - Installing Postgres database Postgres database installed! You can check its status with the following command: <script src=""></script> <img class="size-full wp-image-12818" src="" alt="" width="1532" height="966" /> Image 5 - Status of the PostgreSQL database We now have everything needed to finally install RStudio Connect. <h2 id="rstudio-connect">How to Install RStudio (Posit) Connect to Local Kubernetes Cluster</h2> You will need a working license key before attempting to deploy RStudio Connect into Kubernetes. If you do not have one, contact us at <a href=""></a>. First, export your license key as a variable named <code>RSC_LICENSE</code>: <script src=""></script> And now deploy RStudio Connect into Kubernetes by running the following commands: <script src=""></script> <img class="size-full wp-image-12820" src="" alt="" width="1532" height="966" /> Image 6 - Installing RStudio Connect Once done, you can use this command to check the status of RStudio Connect: <script src=""></script> <img class="size-full wp-image-12822" src="" alt="" width="1532" height="966" /> Image 7 - Status of the RStudio Connect pod You won't be able to access RStudio Connect in this as of now - you'll have to configure port forwarding. <code>kubectl port-forward</code> command allows using resource names, such as a ReplicaSet, to select a matching ReplicaSet to port forward to. First, grab the ReplicaSet name: <script src=""></script> <img class="size-full wp-image-12824" src="" alt="" width="1532" height="966" /> Image 8 - Status of the RStudio Connect ReplicaSet Next, port-forward port 3939 on <code>localhost</code> to port 3939 of the running ReplicaSet: <script src=""></script> You should see similar output in the console: <img class="size-full wp-image-12826" src="" alt="" width="1532" height="966" /> Image 9 - Status of port forwarding the RStudio Connect ReplicaSet to localhost Connections made to local port 3939 are forwarded to port 3939 of the ReplicaSet that is running the RStudio Connect server. With this connection in place, you can use your local workstation to access the application using your web browser, i.e. by navigating to <code>http://localhost:3939</code>. <h2 id="removing-deployment">Removing the Deployment</h2> To stop and remove the existing deployment, run the followings commands: <script src=""></script> RStudio Connect chart will automatically deregister your license key. <hr /> <h2 id="summary">Summary of RStudio Connect in a Local Kubernetes Cluster</h2> And there you have it - you've successfully deployed RStudio Connect to the local Kubernetes cluster. There were a lot of steps in the process, we know, but all the shell commands can easily be copied, so we guarantee you won't run into any issues. With RStudio Connect on a local Kubernetes cluster, you can now experiment with the product and get familiar with the commonly used features. You'll want to make sure the applications can be deployed to RStudio Connect locally before you put them into production. Running Connect on a local machine is also a great way to troubleshoot issues related to your deployments and environment in general. In the next post, we'll describe how RStudio Connect can be deployed into a more production-grade Kubernetes cluster! <blockquote>Want to deploy Python Streamlit apps to RStudio Connect? <a href="" target="_blank" rel="noopener">This guide will teach you everything you need to know</a>.</blockquote>

Contact us!
Damian's Avatar
Damian Rodziewicz
Head of Sales
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Have questions or insights?
Engage with experts, share ideas and take your data journey to the next level!
Join Slack
Explore Possibilities

Take Your Business Further with Custom Data Solutions

Unlock the full potential of your enterprise with our data services, tailored to the unique needs of Fortune 500 companies. Elevate your strategy—connect with us today!

Talk to our Experts
rstudio connect