This site is archived

Posit Connect support for off-host content execution has entered General Availability (GA).
Documentation about off-host execution is now included in the Connect Admin Guide.
The instructions presented here were associated with the off-host execution beta and are now obsolete.

Configuration and Deployment

Using Kubernetes to host Posit Connect service and content execution

Kubernetes Cluster Preparation

Step 1: Create namespace for Posit Connect

You will need a Kubernetes namespace for Posit Connect. We recommend creating a new one called rstudio-connect. This can be accomplished with the following commands:

# Create the new namespace
kubectl create namespace rstudio-connect

# Switch to the new namespace in your current context
kubectl config set-context --current --namespace=rstudio-connect
Warning

The Postgres and NFS installation instructions described below are intended to serve as a reference only.

When configuring Postgres and NFS for production, make sure to follow industry best-practices with respect to security and availability.

Step 2: Install PostgreSQL database

Note

If you are using an external PostgreSQL database or a local SQLite database as the store for Posit Connect, then you may skip this step. Note that PostgreSQL is required if you plan to run Connect with HA enabled.

Run the following command to install Postgres in your cluster:

# replace this value with your postgres password
RSC_POSTGRES_PASS="<your-postgres-database-password>"

helm upgrade --install rsc-db bitnami/postgresql \
--version 11.6.16 \
--set auth.database="rsc_k8s" \
--set auth.username="connect" \
--set auth.password="${RSC_POSTGRES_PASS}"

Step 3: Install NFS server provisioner

This guide will use NFS as the storage provider for Connect’s data directory. Run the following command to install NFS in your cluster:

Note

If you already have an NFS instance that you wish to use, you may skip this section. The External Storage appendix describes how to configure an external NFS instance for use by the Posit Connect Helm chart.

Warning

Please note that if you wish to use something other than NFS as Connect’s data directory, the StorageClass selected must support ReadWriteMany and symlinks.

helm upgrade --install rsc-nfs kvaps/nfs-server-provisioner \
--version 1.4.0 \
--set persistence.enabled=true \
--set persistence.size="100Gi" \
--set storageClass.name="rsc-nfs"

Step 4: Validate NFS and Postgres are running

To check that the NFS and Postgres pods have started successfully, use the command:

kubectl get pods

You should see output like the following:

NAME                                READY   STATUS    RESTARTS   AGE
rsc-nfs-nfs-server-provisioner-0    1/1     Running   0          65s
rsc-db-postgresql-0                 1/1     Running   0          69s

If either pod indicates that its status not Running after a few minutes, use the describe command to check for dianostic information about the pod. In the following example, we can see that the nfs pod failed to start because Kubernetes could not pull the container image:

kubectl describe pod rsc-nfs-nfs-server-provisioner-0

Output:

Name:           rsc-nfs-nfs-server-provisioner-0
Namespace:      rsc-dev
...
Events:
  Type     Reason          Age               From               Message
  ----     ------          ----              ----               -------
  Normal   Scheduled       17s               default-scheduler  Successfully assigned rsc-dev/rsc-nfs-nfs-server-provisioner-0 to docker-desktop
  Warning  FailedMount     16s               kubelet            MountVolume.SetUp failed for volume "rsc-nfs-nfs-server-provisioner-token-2lnb2" : failed to sync secret cache: timed out waiting for the condition
  Warning  Failed          13s               kubelet            Failed to pull image "k8s.gcr.io/sig-storage/nfs-provisioner:v0.0.0": rpc error: code = Unknown desc = Error response from daemon: manifest for k8s.gcr.io/sig-storage/nfs-provisioner:v0.0.0 not found: manifest unknown: Failed to fetch "v0.0.0" from request "/v2/sig-storage/nfs-provisioner/manifests/v0.0.0".
  Warning  Failed          13s               kubelet            Error: ErrImagePull