Products | Versions |
---|---|
Spotfire Server | 12.0 and later |
In most cases, you need to install additional R packages on the machine which runs your Spotfire Server TERR service. This presents a challenge when deploying in a Kubernetes cluster (using the Spotfire Cloud Deployment Kit), as it requires some changes to be applied to the running spotfire-terrservice pod. Follow the steps below to implement a Helm post-install hook for the Spotfire TERR service that will install additional R packages after the TERR service pod has started.
$ kubectl apply -f - <<! # Create the PV apiVersion: v1 kind: PersistentVolume metadata: name: terr-pv-volume labels: type: local spec: storageClassName: standard capacity: storage: 10Gi accessModes: - ReadWriteOnce hostPath: path: "/mnt/data" --- # Create the PVC apiVersion: v1 kind: PersistentVolumeClaim metadata: name: terr-pv-claim spec: storageClassName: standard accessModes: - ReadWriteOnce resources: requests: storage: 3Gi !
$ kubectl apply -f - <<! # Create the cluster role apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: pod-viewer rules: - apiGroups: [""] resources: ["pods", "pods/exec"] verbs: ["get", "list", "create"] --- # Create the cluster role binding apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: default-pod-viewer-binding subjects: - kind: ServiceAccount name: default namespace: default roleRef: kind: ClusterRole name: pod-viewer apiGroup: rbac.authorization.k8s.io !
ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update \ && apt-get clean all
ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update \ && apt-get clean all # additional packages for TERR & kubectl RUN apt install -y libtinfo5 make r-base-core curl ca-certificates apt-transport-https RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" RUN install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
# Configure logging ENV LOGGING_SERVICELOG_SIZE=10MB ENV LOGGING_SERVICELOG_MAX=2 # add PATH and JAVA_HOME ENV JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64" ENV PATH="/usr/lib/jvm/java-17-openjdk-amd64/bin:${PATH}" CMD ["./entrypoint-terr.sh"]
$ ls -al /mnt/data/rinclude/ total 32 drwxr-xr-x 5 jmulcahe group 100 Sep 15 2020 . drwxr-xr-x 3 root root 22 Dec 20 13:19 .. -rw-r--r-- 1 user group 293 Sep 15 2020 DESCRIPTION drwxr-xr-x 3 user group 21 Dec 15 20:28 inst -rw-r--r-- 1 user group 18011 Sep 15 2020 LICENSE drwxr-xr-x 2 user group 33 Dec 15 20:28 man -rw-r--r-- 1 user group 2986 Sep 15 2020 MD5 -rw-r--r-- 1 user group 1 Sep 15 2020 NAMESPACE drwxr-xr-x 2 user group 19 Dec 15 20:28 R
# The Job starts a TERR container and runs 'install.pacakges()', which # installs the packages onto the PersistentVolume pointed # to by the PersistentVolumeClaim 'terr-pv-claim'. apiVersion: batch/v1 kind: Job metadata: name: "post-install-job" labels: app.kubernetes.io/managed-by: {{ .Release.Service | quote }} app.kubernetes.io/instance: {{ .Release.Name | quote }} app.kubernetes.io/version: {{ .Chart.AppVersion }} helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" annotations: # This is what defines this resource as a hook. Without this line, the # job is considered part of the release. "helm.sh/hook": post-install "helm.sh/hook-weight": "-5" "helm.sh/hook-delete-policy": hook-succeeded spec: template: metadata: name: "post-install-job" labels: app.kubernetes.io/managed-by: {{ .Release.Service | quote }} app.kubernetes.io/instance: {{ .Release.Name | quote }} helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" spec: volumes: - name: terr-pv-storage persistentVolumeClaim: claimName: terr-pv-claim restartPolicy: Never containers: - name: post-install-job image: 127.0.0.1:5000/spotfire/spotfire-terrservice:1.17.0-2.0.0 imagePullPolicy: Always command: ["/bin/sh"] args: ['-c', 'TERR_SERVICE_POD_NAME=`kubectl get pod | grep terrservice` ; kubectl exec $TERR_SERVICE_POD_NAME -- /opt/spotfire/nodemanager/nm/services/TERR/terr/bin/TERR -e ''install.packages( file.path("/opt/packages", list.files("/opt/packages")), repos = NULL, type = "source" )'''] volumeMounts: - mountPath: "/opt/packages" name: terr-pv-storage
$ helm install tss1400-terrservice . \ --set acceptEUA=true \ --set global.spotfire.image.registry="127.0.0.1:5000" \ --set global.spotfire.image.pullPolicy="Always" \ --set nodemanagerConfig.serverBackendAddress="$SPOTFIRE_SERVER" \ --set logging.logForwarderAddress="$LOG_FORWARDER" \ --set persistentVolumeClaim.create="false" \ --set volumes.packages.existingClaim="terr-pv-claim" \ --set volumes.packages.persistentVolumeClaim.volumeName="terr-pv-volume"
$ kubectl exec tss1400-terrservice-spotfire-terrservice-6d676b596f-dt5l7 \ -- /opt/spotfire/nodemanager/nm/services/TERR/terr/bin/TERR -e 'installed.packages()' ... methods NA "file LICENSE" NA "6.1.0" parallel NA "file LICENSE" NA "6.1.0" rinclude NA "GPL-2 (see LICENSE)" NA "4.0.2" sjdbc NA "file LICENSE" NA "6.1.0" splines NA "file LICENSE" NA "6.1.0" ...