Delete/recreate volumes used by a pipeline when it starts

I’m using K3s as a service in my pipeline to test some kubernetes stuff. For some reason this container doesn’t start unless I specify a host path volume for its data - no volume or temp volume do not work. The problem is that at the end of the pipeline the data is left in the host directory, so when the pipeline starts again and creates the service container, the old data is still there causing tests to fail. Is there a way to ensure that the volumes used by a service are either deleted at the end or recreated at the beginning? Thanks

I think I sorted it out. K3s was giving out write permission errors so that was kinda fixed with the hostpath volume, but with the problem described above. I have now removed the volume and set the service as privileged and it seems to work. What are the implications? Can this affect the underlaying kubernetes cluster somehow?