[英]Postgres on Kubernetes on IBM Bluemix containers
I am trying to deploy Postgres on Bluemix Container service (Kubernetes)我正在尝试在 Bluemix 容器服务 (Kubernetes) 上部署 Postgres
I have created the Image and deployed it through the following yaml file:我已经创建了图像并通过以下 yaml 文件部署了它:
apiVersion: v1
kind: Service
metadata:
name: tripbru-postgres
labels:
app: tripbruREST
spec:
ports:
- port: 5432
targetPort: 5432
nodePort: 31432
selector:
app: tripbruREST
tier: frontend
type: NodePort
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: tripbru-postgres
labels:
app: tripbruREST
spec:
strategy:
type: Recreate
template:
metadata:
labels:
app: tripbruREST
tier: postgres
spec:
containers:
- image: registry.ng.bluemix.net/eliza/postgres:9.5
name: postgres
env:
- name: POSTGRES_PASSWORD
value: MYPASSWORD
ports:
- containerPort: 5432
name: postgres
volumeMounts:
- name: pg-data
mountPath: /var/lib/postgresql/data
- name: tz-config
mountPath: /etc/localtime
volumes:
- name: pg-data
emptyDir: {}
- name: tz-config
hostPath:
path: /usr/share/zoneinfo/Europe/Madrid
This effectively deploys it:这有效地部署了它:
icordoba$ kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes 10.10.10.1 <none> 443/TCP 1d
tripbru-postgres 10.10.10.232 <nodes> 5432:31432/TCP 1d
But I can't connect to the node IP address on port 31432. I have tested Postgres is running using:但是我无法连接到端口 31432 上的节点 IP 地址。我已经测试过 Postgres 正在使用:
kubectl exec -it tripbru-postgres-3667814974-pzmsk bash
I get in the docker instance and check Postgres is running ok.我进入 docker 实例并检查 Postgres 是否运行正常。
I am sure I am missing something.我确定我错过了一些东西。 Do I need any other yaml file?
我还需要其他 yaml 文件吗? Thanks.
谢谢。
I solved it using "Pod" and not Deployment.我使用“Pod”而不是部署解决了它。 I also changed hostPath and note the ephemeral "emptyDir" volume format (this is a test in free Kubernetes service by Bluemix so I can't use real volumes).
我还更改了 hostPath 并注意临时的“emptyDir”卷格式(这是 Bluemix 免费 Kubernetes 服务中的测试,因此我无法使用实际卷)。 This is the working yaml:
这是工作的 yaml:
apiVersion: v1
kind: Pod
metadata:
name: postgres
labels:
name: postgres
spec:
containers:
- name: postgres
image: registry.ng.bluemix.net/eliza/postgres:9.5
env:
- name: POSTGRES_PASSWORD
value: MYPASSWORD
ports:
- containerPort: 5432
volumeMounts:
- name: pg-data
mountPath: /var/lib/postgresql/data
- name: tz-config
mountPath: /etc/localtime
volumes:
- name: pg-data
#emptyDir: {}
hostPath:
path: "/opt/tripbruPostgres"
- name: tz-config
hostPath:
path: /usr/share/zoneinfo/Europe/Madrid
(Note I still don't know what was wrong with my "Deployment" approach, but using Pod works as I don't need replication at this stage) (注意我仍然不知道我的“部署”方法有什么问题,但是使用 Pod 是可行的,因为我在这个阶段不需要复制)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.