Skip to content

Latest commit

 

History

History
266 lines (259 loc) · 9.32 KB

README.md

File metadata and controls

266 lines (259 loc) · 9.32 KB

Rstudio Operator

Overview

RStudio IDE is an integrated development environment for R widely used by data scientists. The RStudio Operator aims to make running an RStudio on Kubernetes easier by using Kubernetes custom resources.

Installation

Clone the repository and install with Kustomize.

cd rstudio-operator
kustomize build manifests/base | kubectl apply -f -

Rstudio Custom Resource

Field Description
apiVersion
string (Required.)
emmaliaocode.dev/v1
kind
string (Required.)
Rstudio
metadata
object (Required.)
Standard object's metadata.
spec
object (Required.)

Specification of the Rstudio instance.

Subfield Description
image
string (Required.)
Image digest from Docker Hub (rocker/rstudio). Must start with the prefix rocker/rstudio and separate the R version with :. For example, rocker/rstudio:4.4.0 creates an Rstudio of R version 4.4.0.
imagePullPolicy
string
Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if the 'latest' tag is specified in image, or IfNotPresent otherwise.
loginSecret
string
Set the password for logining to Rstudio with a Secret, the secret must contain a password key. Default password will be printed in the container log if this is not set.
isRoot
boolean
Whether the Linux system user should be added to the sudoers group during the Rstudio server init process. Default is false.
resources
string

Compute Resources required by this Rstudio instance.

Subfield Description
requests
string
Requests describes the minimum amount of compute resources required.
limits
string
Limits describes the maximum amount of compute resources allowed.
storages
array

Storages are a list of claims that an Rstudio instance is allowed to reference.

Subfield Description
name
string (Required.)
Name of the claim.
storageSize
string (Required.)
StorageSize represents the minimum resources the volume should have.
accessModes
array (Required.)
AccessModes contains the desired access modes the volume should have. Could be ReadWriteOnce, ReadOnlyMany, ReadWriteMany.
storageClassName
string
Name of the StorageClass required by the claim.
volumes
array

Volumes that can be mounted to the Rstudio instance.

Subfield Description
name
string (Required.)
Name of the volume must be unique.
configMap
object
Mount a ConfigMap that already existed in the same namespace.
persistentVolumeClaim
object
Mount a PersistentVolumeClaim that already existed in the same namespace.
secret
object
Mount a Secret that already existed in the same namespace.
emptyDir
object
Mount a temporary directory that can be used by multiple containers in the same pod.
volumeMounts
array

Volumes to mount into the container's filesystem.

Subfield Description
name
string (Required.)
This must match the Name of a Volume.
mountPath
string (Required.)
Path within the container at which the volume should be mounted.
status
object
Most recently observed status of the Rstudio.

Usage

Create a password secret for logging in to Rstudio IDE.

kubectl create secret generic rstudio-secret --from-literal=password=[password]

Create a Rstudio custom resource.

kubectl apply -f - <<EOF
apiVersion: emmaliaocode.dev/v1
kind: Rstudio
metadata:
  name: example
  namespace: default
spec:
  image: rocker/rstudio:4.4.0
  imagePullPolicy: IfNotPresent
  loginSecret: rstudio-secret
  isRoot: true
  resources:
    requests:
      cpu: "250m"
      memory: "64Mi"
    limits:
      cpu: "500m"
      memory: "128Mi"
  storages:
  - name: my-storage
    storageClassName: standard
    storageSize: "1Gi"
    accessModes:
    - ReadWriteMany
  volumes:
  - name: my-config
    configMap:
      name: my-config
  - name: my-pvc
    persistentVolumeClaim:
      claimName: my-pvc
  - name: my-secret
    secret:
      secretName: my-secret
  - name: my-empty-dir
    emptyDir:
      sizeLimit: "1Gi"
  volumeMounts:
  - name: my-storage
    mountPath: /storage
  - name: my-config
    mountPath: /config
  - name: my-pvc
    mountPath: /pvc
  - name: my-secret
    mountPath: /secret
  - name: my-empty-dir
    mountPath: /empty-dir
EOF
rstudio.emmaliaocode.dev/example created

Get objects with rstudio=example label.

kubectl get all -l rstudio=example
NAME                    READY   STATUS    RESTARTS   AGE
pod/example-rstudio-0   1/1     Running   0          4m13s

NAME                      TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
service/example-rstudio   NodePort   10.109.56.60   <none>        8787:32378/TCP   4m13s

NAME                               READY   AGE
statefulset.apps/example-rstudio   1/1     4m13s