In the example below, the Pod definition is embedded in the StatefulSet definition. Is there a way to separate the Pod definition to refer to a separately defined Pod definition?
CodePudding user response:
Is there a way to separate the Pod definition to refer to a separately defined Pod definition
No.
For longer version, here is definition of StatefulSet
CodePudding user response:
If what you are looking for is to split the StatefulSet into multiple manifests - separate for the Pod and PVC, here is what you can do:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hello-web-disk-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 30Gi
apiVersion: v1
kind: Pod
metadata:
name: not-a-stateful-set-pod
labels:
app: MyApp
spec:
containers:
- name: not-a-stateful-set-container
image: nginx
ports:
- containerPort: 80
name: http
volumeMounts:
- name: hello-web-disk
mountPath: "/var/www/html"
volumes:
- name: hello-web-disk
persistentVolumeClaim:
claimName: hello-web-disk-pvc