I have a application of workload deployment and need to change it to statefulset
apiVersion: apps/v1
kind: Deployment
metadata:
name: app
labels:
app: app
spec:
replicas: 1
selector:
matchLabels:
app: app
template:
metadata:
labels:
app: app
spec:
containers:
- name: app
image: nginx:1.14.2
ports:
- containerPort: 80
volumeMounts:
- name: data
subPath: app/log
mountPath: /opt/app/log
volumes:
- name: data
peristentVolumeClaim:
claimName: pv-app-claim
PV
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-app
labels:
pv: app
spec:
storageClassName: "default"
capacity:
storage: 8Gi
accessModes:
- ReadWriteMany
persistentVolumeclaimPolicy: Retain
nfs:
server: someIP
path: "/somepath"
PVC
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pv-app-claim
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 8Gi
selector:
matchLabels:
pv: app
I have tried to change the required file but struck in a place where I need the data in the volume to be there even when I'm moving to statefulset. In statefulset we use volumeclaimtemplate this is where i'm struck how to retain the data and claim with volumeclaimtemplate.
Note: I'm going to use only one pod
volumeclaimtemplate
asvolumeclaimtemplate
will create a new PVC .pod spec
just like you mention in a deploymentExample: