Speed Run Installation

Cheat to Win - Things I did ahead of time

  • Set up the Kubernetes cluster (Amazon EKS)

  • Set environment variables: RStudio Connect License Key and PostgreSQL Database Password (of my choosing)

  • Have kubectl and helm installed

Install all the things - “A Love Letter to Helm”

Helm helps you to:

  • Achieve a simple (one command) and repeatable deployment
  • Update/rollback and test application deployments

Pull the helm charts and update the helm repo:

# RStudio Connect
helm repo add rstudio https://helm.rstudio.com

# Postgres (optional)
helm repo add bitnami https://charts.bitnami.com/bitnami

# NFS (optional)
helm repo add kvaps https://kvaps.github.io/charts

# Pull the latest versions of the helm charts
helm repo update

Create a namespace for RStudio Connect

(guide assumes rstudio-connect)

# 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

Install PostgreSQL with Helm

Just an example – You can bring your own:

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}"

Install NFS with Helm

BYO: The StorageClass 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"

Create a values.yaml file for your Connect installation

Overrides defaults specified in the Helm chart.

View the Helm chart’s entire set of default values:

helm show values rstudio/rstudio-connect

Configure shared storage and enable the launcher:

# Controls how many instances of RStudio Connect will be created.
replicas: 1

# Configures shared storage for the RStudio Connect pod.
sharedStorage:
  create: true
  mount: true

  # The name of the PVC that will be created for Connect's data directory.
  # This PVC is also specified by `Launcher.DataDirPVCName` below.
  name: rsc-pvc

  # The storageClass to use for Connect's data directory. Must support RWX.
  storageClassName: rsc-nfs
  requests:
    storage: 100G

# Enables building and executing content in isolated Kubernetes pods.
launcher:
  enabled: true

Check what will be generated with helm template:

helm template rstudio/rstudio-connect -f values.yaml | less

Use values.yaml to manage the Connect .gcfg configuration file:

# The config section overwrites values in RStudio Connect's main .gcfg configuration file.
config:

  # Configures the Postgres connection for RStudio Connect.
  Database:
    Provider: "Postgres"
  Postgres:
    URL: "postgres://connect@rsc-db-postgresql.rstudio-connect.svc.cluster.local:5432/rsc_k8s?sslmode=disable"
    # While it is possible to set a Postgres password here in the values file, we recommend providing
    #   the password at runtime using helm install's --set argument instead
    #   (e.g. --set config.Postgres.Password=<your-postgres-database-password>)

  Launcher:
    # Configures the job launcher to use Connect's data dir PVC when launching content jobs
    # This has the same value as `sharedStorage.name` above
    DataDirPVCName: rsc-pvc

Helm Install RStudio Connect!

(remember I’ve already set the license key and postges password as environment variables)

helm upgrade --install rstudio-connect-prod rstudio/rstudio-connect \
  --set license.key="${RSC_LICENSE}" \
  --set config.Postgres.Password="${RSC_POSTGRES_PASS}" \
  --values values.yaml
  • Watch Connect get started: kubectl get events --watch
  • Verify everything is running kubectl get pods

Access RStudio Connect!

  • Test locally with manual port forwarding
  • (In AWS Cloud9 use kube-proxy to “Preview” the application)