Kubernetes没有暴露的集装箱港口

时间:2017-01-06 15:30:20

标签: django docker kubernetes

我正在尝试将Postgres pod与我的Django应用程序pod连接,但不知怎的,我的Django应用程序pod端口未公开。在我的应用Dockerfile中,我添加了EXPOSE 8000,但是当我进入我的广告连播时,我无法投放我的应用(返回错误,询问postgres服务器是否已启动并在端口5432上运行并接受TCP / IP连接在端口5432上)当运行nmap时,我得到了这个

root@app-kbqd8:~/app# nmap 12.3.4.567

Starting Nmap 7.01 ( https://nmap.org ) at 2017-01-06 15:24 UTC
Nmap scan report for postgres-service.default.svc.cluster.local (12.3.4.567)
Host is up (0.00063s latency).
All 1000 scanned ports on postgres-service.default.svc.cluster.local (10.0.0.171) are filtered

我的应用程序服务是:

---
kind: Service
apiVersion: v1
metadata:
  name: app-service
spec:
  selector:
    name: myapp
  ports:
    - port: 80
      targetPort: 8000
      protocol: TCP

我的postgres pod

---
kind: Deployment
apiVersion: extensions/v1beta1
containers:
    - name: postgres
      image: user/postgres
      imagePullPolicy: IfNotPresent
      ports:
        - containerPort: 5432

及其服务

---
kind: Service
apiVersion: v1
metadata:
  name: postgres-service
spec:
  ports:
    - port: 5432
      targetPort: 5432
      protocol: TCP
  selector:
    component: postgres
    role: master
    name: postgres

0 个答案:

没有答案