【发布时间】:2019-03-09 05:31:40
【问题描述】:
我有一个包含 3 个容器 A、B 和 C 的 pod。我想从 C 访问容器 A 和 B 中的服务。localhost:<port> 和 127.0.0.1 都不起作用。
我的 yaml
apiVersion: "v1"
kind: Pod
metadata:
name: web3
labels:
name: web
app: demo
spec:
containers:
- name: client
image: ubuntu
command: ['cat']
tty: true
- name: apache1
image: nimmis/apache-php5
ports:
- containerPort: 8080
name: apacheport1
protocol: TCP
- name: apache2
image: nimmis/apache-php5
command: ['cat']
tty: true
ports:
- containerPort: 8088
name: apacheport2
protocol: TCP
我在做什么
kubectl apply -f example.yaml
kubectl exec -it web3 -c client bash
然后尝试访问其他 2 个服务
root@web3:/# curl http://localhost:8080
curl: (7) Failed to connect to localhost port 8080: Connection refused
root@web3:/# curl http://localhost:8088
curl: (7) Failed to connect to localhost port 8088: Connection refused
root@web3:/# curl http://localhost:80
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
Modified from the Debian original for Ubuntu
问题 如何使前 2 卷曲工作。 (我不想使用该服务,因为我的用例仅用于测试目的) 为什么在我没有暴露端口的情况下还有一个开放的80端口。
【问题讨论】:
-
nimmis/apache-php5 镜像中暴露的端口是什么?
-
80 和 443 端口在 Apache 容器中打开