PVC Storage in Deployment kubernetes file

Hi every one !

i have one question about kubernetes storage (PVC)

can i use pvc in kubernetes deployment yaml file with replica more than 1 ?
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment
spec:
replicas: 2
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:

  • name: my-deployment-container
    image: nginx
    volumeMounts:
  • mountPath: /log
    name: log-volume
    volumes:
  • name: log-volume
    persistentVolumeClaim:
    claimName: claim-log-1

BR

I wanted to edit your post to use code block so we can actually see the indentations, then I noticed that even your inserted yaml is syntactically wrong. Whe you insert code, please, make sure it is readable and syntactically correct unless your question is about syntax.

I think you should use StatefulSet instead of Deployment

In StatefulSet you can define a volumeClaimTemplate

Note: Probably many of us know Kubernetes, but keep in mind that this is a Docker forum and Kubernetes does not necessarily use Docker at all. Although I can see that you asked about this on the Kubernetes forum as well: