我在谷歌云平台上使用kubernetes掌舵。
我的postgres部署出现以下错误:
SchedulerPredicates failed due to PersistentVolumeClaim is not bound
它似乎无法连接到持久存储,但我不明白为什么因为持久存储加载正常。
我已经尝试完全删除了helm版本,然后在google-cloud-console> “计算引擎”>磁盘;我删除了所有永久磁盘。最后尝试从掌舵图表安装,但postgres部署仍然没有连接到PVC。
我的数据库配置:
{{- $serviceName := "db-service" -}}
{{- $deploymentName := "db-deployment" -}}
{{- $pvcName := "db-disk-claim" -}}
{{- $pvName := "db-disk" -}}
apiVersion: v1
kind: Service
metadata:
name: {{ $serviceName }}
labels:
name: {{ $serviceName }}
env: production
spec:
type: LoadBalancer
ports:
- port: 5432
targetPort: 5432
protocol: TCP
name: http
selector:
name: {{ $deploymentName }}
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: {{ $deploymentName }}
labels:
name: {{ $deploymentName }}
env: production
spec:
replicas: 1
template:
metadata:
labels:
name: {{ $deploymentName }}
env: production
spec:
containers:
- name: postgres-database
image: postgres:alpine
imagePullPolicy: Always
env:
- name: POSTGRES_USER
value: test-user
- name: POSTGRES_PASSWORD
value: test-password
- name: POSTGRES_DB
value: test_db
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
ports:
- containerPort: 5432
volumeMounts:
- mountPath: "/var/lib/postgresql/data/pgdata"
name: {{ $pvcName }}
volumes:
- name: {{ $pvcName }}
persistentVolumeClaim:
claimName: {{ $pvcName }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ $pvcName }}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
selector:
matchLabels:
name: {{ $pvName }}
env: production
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ .Values.gcePersistentDisk }}
labels:
name: {{ $pvName }}
env: production
annotations:
volume.beta.kubernetes.io/mount-options: "discard"
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
gcePersistentDisk:
fsType: "ext4"
pdName: {{ .Values.gcePersistentDisk }}
这个kubenetes的配置是否正确?我已阅读文档,看起来这应该工作。我是Kubernetes的新手,掌舵,所以任何建议都值得赞赏。
编辑:
我添加了PersistentVolume并将其链接到PersistentVolumeClaim以查看是否有帮助,但似乎当我这样做时,PersistentVolumeClaim状态陷入“待定”状态(导致与之前相同的问题)。
答案 0 :(得分:0)
对于此声明,您没有受约束的PV。您用于此声明的存储空间。您需要在PVC文件中提及它