Deploy Agents on Persistent Volumes
An example illustrating how to deploy an Agent on a Kubernetes persistent volume (PV).
In this example, you deploy an Agent on a PV, so that each time an application container is started, its mapping to the PV allows to start the Agent directly without the need to download it.
-
Create a PV specification file pv-volume.yml:
pv-volume.yml apiVersion: v1 kind: PersistentVolume metadata: name: task-pv-volume labels: type: local spec: storageClassName: manual capacity: storage: 10Gi accessModes: - ReadWriteOnce hostPath: path: "/tmp/data"
-
Run this command to create a PV in the specified path:
kubectl apply -f ./pv-volume.yml
-
Create a PV claim specification file pv-claim.yml:
pv-claim.yml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: task-pv-claim spec: storageClassName: manual accessModes: - ReadWriteOnce resources: requests: storage: 3G
-
Run this command to claim the PV:
kubectl apply -f ./pv-claim.yml
-
Deploy the Node.js Agent to the PV:
# Download the Agent package curl -k -o /tmp/seeker-agent.zip "${SEEKER_SERVER_URL}/rest/api/latest/installers/agents/binaries/NODEJS" # Unzip the Agent package unzip -d /tmp/seeker /tmp/seeker-agent.zip # Install the Agent for fetching its dependencies npm install /tmp/seeker/seeker-agent.tgz --prefix seeker --save # Copy the Agent installation to PV cp -r ./seeker /tmp/data
Note: Since you are running these commands on your host, be sure to replace${SEEKER_SERVER_URL}
with its actual URL. -
Modify your application image to use the PV by changing
run.sh as follows:
run.sh #!/bin/sh # Deploy the Seeker Agent if [ -n "${SEEKER_SERVER_URL}" ]; then # Start the application with the Agent node -r '/data/seeker/node_modules/@synopsys-sig/seeker' index.js else node index.js fi
-
Build and publish the application:
docker build -t node-sample . docker publish node-sample
-
Create a deployment Pod for the application:
pv-pod.yml apiVersion: v1 kind: Pod metadata: name: task-pv-pod spec: volumes: - name: task-pv-storage persistentVolumeClaim: claimName: task-pv-claim containers: - name: task-pv-container image: node-sample ports: - containerPort: 3000 name: "node-sample" env: - name: SEEKER_SERVER_URL value: "https://seeker-server:8443" - name: SEEKER_PROJECT_KEY value: "nodejs-sample" volumeMounts: - mountPath: "/data" name: task-pv-storage
-
Launch the application:
kubectl apply -f ./pv-pod.yml