【发布时间】:2016-09-02 09:41:51
【问题描述】:
我想在 pod 中的 2 个容器和主机之间进行通信,以更好地了解 kubernetes ketworking:
#DockerfileA
FROM debian:sid
RUN /bin/bash -c "apt-get update && apt-get install -y netcat"
CMD /bin/bash echo hello world | nc 127.0.0.1 40000
#DockerfileB
FROM debian:sid
RUN /bin/bash -c "apt-get update && apt-get install -y netcat"
EXPOSE 40000
CMD /bin/bash nc -l 40000 | nc 127.0.0.1 50000
#my_pod.yml
apiVersion: v1
kind: Pod
metadata:
name: netcat
labels:
app: netcat
spec:
containers:
- name: my_container_a
image: my_image_a:1
- name: my_container_b
image: my_image_b:1
ports:
- containerPort: 40000
#my_service.yml
apiVersion: v1
kind: Service
metadata:
name: netcat-service
spec:
ports:
- port: 50000
targetPort: 50000
protocol: TCP
selector:
app: netcat
在实践中,我希望 containerA 通过 netcat "hello world" 发送到 containerB,然后 containerB 将其转发到主机。
但是当我创建 pod 时,我收到了以下警告(kubectl describe pod netcat):
警告 FailedSync 同步 pod 时出错,正在跳过:[failed to 带有 CrashLoopBackOff 的“my_container_a”的“StartContainer”:“Back-off 10s 重启失败的容器=my_container_a pod=netcat_default(f141c598-1439-11e6-83fc-009c028bec97)",未能 带有 CrashLoopBackOff 的“my_container_b”的“StartContainer”:“Back-off 10s 重启失败的容器=my_container_b pod=netcat_default(f141c598-1439-11e6-83fc-009c028bec97)"
文件有错误吗?
是否需要 netcat 服务来使用 netcat 侦听主机上的“hello world”消息,还是不需要?
我应该在主机的哪个地址:端口上使用 netcat/curl?
谢谢!
【问题讨论】:
标签: kubernetes dockerfile