{{- if eq .Values.mode "standalone" }}
{{- if and .Values.persistence.storageClass (eq .Values.persistence.storageClass "local-storage") }}
apiVersion: v1
kind: PersistentVolume
metadata:
  name: {{ .Release.Namespace }}-{{ template "minio.fullname" . }}-pv
spec:
  capacity:
    storage: {{ .Values.persistence.size | quote }}
  volumeMode: Filesystem
  accessModes:
    - {{ .Values.persistence.accessMode }}
  persistentVolumeReclaimPolicy: Delete
  storageClassName: {{ .Values.persistence.storageClass }}
  local: # local类型
    path: {{ .Values.persistence.storagePath | default "/opt/milvus/data" }}/minio
  claimRef:
    apiVersion: v1
    kind: PersistentVolumeClaim
    name: {{ template "minio.fullname" . }}
    namespace: {{ .Release.Namespace }}
  nodeAffinity:
    required:
      nodeSelectorTerms:
        - matchExpressions:
            - key: kubernetes.io/hostname
              operator: In
              values:
                - {{ .Values.persistence.storageNode }}

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: {{ template "minio.fullname" . }}
  {{- with .Values.persistence.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  labels:
    app: {{ template "minio.name" . }}
    chart: {{ template "minio.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  accessModes:
    - {{ .Values.persistence.accessMode | quote }}
  volumeName: {{ .Release.Namespace }}-{{ template "minio.fullname" . }}-pv
  volumeMode: Filesystem
  resources:
    requests:
      storage: {{ .Values.persistence.size | quote }}
  storageClassName: {{ .Values.persistence.storageClass }}

{{- else }}

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: {{ template "minio.fullname" . }}
  {{- with .Values.persistence.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  labels:
    app: {{ template "minio.name" . }}
    chart: {{ template "minio.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  accessModes:
    - {{ .Values.persistence.accessMode | quote }}
  {{- if .Values.persistence.storageClass }}
  storageClassName: {{ .Values.persistence.storageClass }}
  {{- end }}
  resources:
    requests:
      storage: {{ .Values.persistence.size | quote }}
{{- end }}
{{- end }}