我在StatefulSet postgres下面有EKS。当我运行它时,我遇到了错误。
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedCreate 7s (x17 over 1m) statefulset-controller create Pod postgres-0 in StatefulSet postgres failed error: Pod "postgres-0" is invalid: spec.containers[0].volumeMounts[0].name: Not found: "postgredb"
StatefulSet:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgres
spec:
selector:
matchLabels:
app: postgres # has to match .spec.template.metadata.labels
serviceName: "postgres"
replicas: 1
template:
metadata:
labels:
app: postgres
spec:
terminationGracePeriodSeconds: 10
containers:
- name: postgres
image: postgres:10.4
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 5432
volumeMounts:
- name: postgredb
mountPath: /var/lib/postgresql/data
volumeClaimTemplates:
- metadata:
name: postgresdb
annotations:
volume.beta.kubernetes.io/storage-class: "aws-efs"
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
我也配置了StorageClass。我在这里做什么错了?
答案 0 :(得分:1)
只是一个错字。
volumeMounts:
- name: postgredb
应为name:postgresdb
,而不是name:postgredb
。