{{ range $count := untilStep 1 (add1 .Values.replicaCount|int) 1 }}
---
apiVersion: v1
kind: Pod
metadata:
  name: {{ include "volume-test.fullname" $ }}-{{ $count }}
  labels:
    helm.sh/chart: {{ include "volume-test.chart" $ }}
    app.kubernetes.io/instance: {{ $.Release.Name }}
    app.kubernetes.io/managed-by: {{ $.Release.Service }}
spec:
  containers:
  - name: whatever
    image: {{ $.Values.image.repository }}:{{$.Values.image.tag}}
    imagePullPolicy: {{ $.Values.image.pullPolicy }}
    command: ['sh', '-c', 'echo Hello Kubernetes! && sleep 3600']
    volumeMounts:
      - mountPath: /vol
        name: vol
  volumes:
    - name: vol
      persistentVolumeClaim:
        claimName: {{ include "volume-test.fullname" $ }}-{{ $count }}
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: {{ include "volume-test.fullname" $ }}-{{ $count }}
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
{{ end }}

{{ range $count := untilStep 1 (add1 .Values.replicaCount|int) 1 }}
---
apiVersion: v1
kind: Pod
metadata:
  name: {{ include "volume-test.fullname" $ }}-{{ $count }}
  labels:
    helm.sh/chart: {{ include "volume-test.chart" $ }}
    app.kubernetes.io/instance: {{ $.Release.Name }}
    app.kubernetes.io/managed-by: {{ $.Release.Service }}
spec:
  affinity:
    podAntiAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
      - weight: 100
        podAffinityTerm:
          labelSelector:
            matchExpressions:
            - key: helm.sh/chart
              operator: In
              values:
              - {{ include "volume-test.chart" $ }}
          topologyKey: kubernetes.io/hostname
  containers:
  - name: whatever
    image: {{ $.Values.image.repository }}:{{$.Values.image.tag}}
    imagePullPolicy: {{ $.Values.image.pullPolicy }}
    command: ['sh', '-c', 'echo Hello Kubernetes! && sleep 3600']
    volumeMounts:
      - mountPath: /vol
        name: vol
  volumes:
    - name: vol
      persistentVolumeClaim:
        claimName: {{ include "volume-test.fullname" $ }}-{{ $count }}
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: {{ include "volume-test.fullname" $ }}-{{ $count }}
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
{{ end }}

Add pod anti affinity to volume-test chart to spread pods over all nodes
Add pod anti affinity to volume-test chart to spread pods over all nodes
