我开始使用Kubernates,并在使用带有GCE持久磁盘的Kubernetes安装Postgres时遇到问题。我可以使用Kubernates演练和以下指南成功安装Mysql:http://amygdala.github.io/kubernetes/2015/01/13/k8s1.html
然而,当我试图用postgres实现类似的事情时,当我连接到磁盘或使用磁盘时,它似乎失败了。我从上面的帖子中创建了一个基于mysql的post,但是替换了postgres码头映像:
apiVersion: v1beta1
id: postgres
desiredState:
manifest:
version: v1beta1
id: postgres
containers:
- name: postgres
image: postgres
env:
- name: DB_PASS
value: password
cpu: 100
ports:
- containerPort: 5432
volumeMounts:
# name must match the volume name below
- name: persistent-storage
# mount path within the container
mountPath: /var/lib/postgresql/data
volumes:
- name: persistent-storage
source:
persistentDisk:
# This GCE PD must already exist and be formatted ext4
pdName: postgres-disk
fsType: ext4
labels:
name: postgres
kind: Pod然而,当我创建
$ kubectl create -f postgres.yaml我得到以下错误:
$ kubectl logs postgres
$ postgres cannot access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory我可以看到postgres-磁盘被附加到一个附属服务器上,所以我想知道它是否与我正在使用的docker映像中的卷有关,或者是否需要postgresql.conf文件的单独挂载路径。
现在,如果我更改挂载路径(例如mountPath: /var/lib/postgresql),pod将启动ok,但它似乎没有使用持久数据。检查附属物上的码头集装箱中的体积,我得到了以下信息:
"Volumes": {
"/dev/termination-log": "/var/lib/kubelet/pods/52177db4-149c-11e5-a64b-42010af06968/containers/postgres/91ecf33c939588b4165865f46b646677bf964fab81ea7ec08b598568513d4644",
"/var/lib/postgresql": "/var/lib/kubelet/pods/52177db4-149c-11e5-a64b-42010af06968/volumes/kubernetes.io~gce-pd/pgdata",
"/var/lib/postgresql/data": "/var/lib/docker/vfs/dir/c3ecda11de6a598d99842c06bee22097f1cb63a6e467cbe7af874d003140a4af",
"/var/run/secrets/kubernetes.io/serviceaccount": "/var/lib/kubelet/pods/52177db4-149c-11e5-a64b-42010af06968/volumes/kubernetes.io~secret/default-token-b6s28"
},我还尝试在v1beta3中使用json文件,结果类似:
{
"kind": "Pod",
"apiVersion": "v1beta3",
"metadata": {
"name": "postgres"
},
"spec": {
"volumes": [{
"name": "pgdata",
"gcePersistentDisk": {
"pdName": "postgres-disk",
"fsType": "ext4"
}
}],
"containers": [
{
"name": "postgres",
"image": "postgres",
"ports": [
{
"name": "postgres-ports",
"hostPort": 5432,
"containerPort": 5432
}
],
"env": [
{
"name": "DB_USER",
"value": "postgres"
},
{
"name": "DB_PASS",
"value": "password"
}
],
"volumeMounts": [
{
"name": "pgdata",
"readOnly": false,
"mountPath": "/var/lib/postgresql/data"
}
]
}
]
}
}这很可能是我刚刚错过了一些在多卡,但任何帮助将是感谢的!
发布于 2015-07-11 09:32:53
请查看https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/volumes.md#gcepersistentdisk卷的文档
在使用带有pod的GCE之前,您需要创建它。
gcloud compute disks create --size=500GB --zone=us-central1-a pg-data-disk这将是您的配置,请注意gcePersistentDisk
apiVersion: v1beta1
id: postgres
desiredState:
manifest:
version: v1beta1
id: postgres
containers:
- name: postgres
image: postgres
env:
- name: DB_PASS
value: password
cpu: 100
ports:
- containerPort: 5432
volumeMounts:
# name must match the volume name below
- name: persistent-storage
# mount path within the container
mountPath: /var/lib/postgresql/data
volumes:
- name: persistent-storage
source:
gcePersistentDisk:
# This GCE PD must already exist and be formatted ext4
pdName: pg-data-disk
fsType: ext4
labels:
name: postgres
kind: Pod发布于 2015-07-14 11:44:36
我也遇到了同样的问题--这是由于db初始化脚本错误地假设一个非空的卷目录意味着它已经被初始化了。
不幸的是,一个新的GCE持久性磁盘包含一个lost+found目录。
我已经为码头图像这里提交了一个补丁。
发布于 2015-07-07 18:43:16
yaml有"persistentDisk“,其中应有"gcePersistentDisk”。使用kubectl create -f <file> --validate来捕获这样的错误。不过,你的json看起来是对的。
postgres是否可能要求该配置文件已经存在?
https://stackoverflow.com/questions/30881637
复制相似问题