How to Modify and Deploy Custom ShinyProxy Resources in a Kubernetes Cluster
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?
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 usekubernetesPodTemplateSpecPatchesto 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).
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.
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.
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!