GKE k8s agent persistency

I’m trying to add persistency to k8s’ agent like this:

# usual agent setup above
...
          volumeMounts:
            - name: agent-storage
              mountPath: /var/testproject/agent
      volumes:
        - name: agent-storage
          persistentVolumeClaim:
            claimName: tp-agent-pvc
---
#***************************************
#TESTPROJECT VOLUME
#***************************************
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: tp-agent-pvc
  namespace: testproject
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi

However the agent fails to start with the error:

Data folder '/var/testproject/agent' is not writable

What am I doing wrong?

For everyone in the community who find it relevant:

This issue was solved by adding this to the configuration:

TP_AGENT_TEMP: “true” - this will remove the agent from TP when the agent is taken down after deleting the pod. It will take a few moments until you will see it removed.

You can find the whole list of docker env vars in this documentation:

To assign to a job you will need to add a comment to run curl commands to add to a job this is the end point:
https://api.testproject.io/docs/v2/#/Jobs/Jobs_UpdateJobAsync