Let's see whether we can solve the problem with PersistentVolumes through a StatefulSet. As a reminder, our goal (for now) is for each instance of a MongoDB to get a separate volume.
The updated definition is in the sts/go-demo-3-sts.yml file.
1 cat sts/go-demo-3-sts.yml
Most of the new definition is the same as the one we used before, so we'll comment only on the differences. The first in line is StatefulSet that replaces the db Deployment. It is as follows.
apiVersion: apps/v1beta2 kind: StatefulSet metadata: name: db namespace: go-demo-3 spec: serviceName: db replicas: 3 selector: matchLabels: app: db template: metadata: labels: app: db spec: terminationGracePeriodSeconds: ...