shinyproxy-operator icon indicating copy to clipboard operation
shinyproxy-operator copied to clipboard

How to Modify and Deploy Custom ShinyProxy Resources in a Kubernetes Cluster

Open flash0926 opened this issue 1 year ago • 3 comments

I have deployed ShinyProxy in my Kubernetes cluster using the official ShinyProxy Operator. I need to modify some of the ShinyProxy styles, such as the landing page and other resources. How can I copy these modifications into the ShinyProxy pod to make them effective? image

flash0926 avatar Aug 06 '24 08:08 flash0926

Hi @flash0926 , there are multiple ways to achieve this:

  • create a custom Docker image containing your resources and templates. In practice we believe this is the easiest way to do it, especially if you use CI/CD pipelines to build the docker image and deploy a new version of ShinyProxy.

    FROM openanalytics/shinyproxy:3.1.1
    COPY templates /opt/shinyproxy/templates
    
  • store the templates on a network file system and mount the volume into the ShinyProxy pod. Make sure the volume can be accessible by multiple pods on multiple nodes (i.e. ReadWriteMany), otherwise your deployment will fail when changing the ShinyProxy configuration. You can use kubernetesPodTemplateSpecPatches to add the k8s code to mount the volume (https://github.com/openanalytics/shinyproxy-operator/tree/master/docs/deployment#modify-the-shinyproxy-pod).

  • store the templates in k8s configmaps or secrets and mount these in the container (again using kubernetesPodTemplateSpecPatches). In our experience this is quite cumbersome and often requires changes at multiple places when modifying the templates (e.g. the list of files to mount etc).

LEDfan avatar Sep 12 '24 11:09 LEDfan

I tried mounting template files using a persistentVolumeClaim but when I do this the sp-shinyproxy* pod is never started and I'm not sure why.

Here is the change to the kubernetesPodTemplateSpecPatches

    - op: add
      path: /spec/containers/0/volumeMounts/-
      value:
        - name: shinyproxy-templates
          mountPath: /etc/shinyproxy/templates
          readOnly: true
    - op: add
      path: /spec/volumes/-
      value:
        - name: shinyproxy-templates
          persistentVolumeClaim:
            claimName: shinyproxy-pvc

I made sure to include the - at the end of the path. If I remove the /- then the sp container starts as expected but the default (demo) configuration of ShinyProxy is loaded instead of the custom template.

gacolitti avatar Dec 10 '24 19:12 gacolitti

Hi, you are correct that if you don't include - at the end, it will not load the config. However, you'll also have to remove the - in the value sections:

   - op: add
      path: /spec/containers/0/volumeMounts/-
      value:
          name: shinyproxy-templates
          mountPath: /etc/shinyproxy/templates
          readOnly: true
    - op: add
      path: /spec/volumes/-
      value:
          name: shinyproxy-templates
          persistentVolumeClaim:
            claimName: shinyproxy-pvc

Otherwise you are adding an array to the volumeMounts array, instead of adding an object to the array.

LEDfan avatar Feb 13 '25 11:02 LEDfan

Hi

I believe this issue has been solved or has become outdated, therefore I'm going to close it. If you still experience this problem, feel free to re-open the issue. As always, any other issue or suggestion is welcome as well!

LEDfan avatar Jul 08 '25 08:07 LEDfan