我有一个kubernetes单节点设置(参见https://coreos.com/kubernetes/docs/latest/kubernetes-on-vagrant-single.html)
我有一个服务和一个复制控制器创建pod.这些pod需要连接到同一服务中的其他pod(注意:这最终是因为我可以让mongo运行w /副本集(非localhost),但这个简单的例子演示了mongo的问题).
当我从任何节点连接到服务时,它将被分发(按预期)到其中一个pod.这将一直有效,直到它自身负载平衡(我所在的容器).然后它无法连接.
很抱歉是冗长的,但我要附上我的所有文件,以便你可以看到我在这个小例子中做了什么.
Dockerfile:
FROM ubuntu
MAINTAINER Eric H
RUN apt-get update; apt-get install netcat
EXPOSE 8080
COPY ./entry.sh /
ENTRYPOINT ["/entry.sh"]
Run Code Online (Sandbox Code Playgroud)
这是切入点
#!/bin/bash
# wait for a connection, then tell them who we are
while : ; do
echo "hello, the date=`date`; my host=`hostname`" | nc -l 8080
sleep .5
done
Run Code Online (Sandbox Code Playgroud)
构建dockerfile
docker build -t echoserver .
标记并上传到我的k8s群集的注册表
docker tag -f echoserver:latest 127.0.0.1:5000/echoserver:latest
docker push 127.0.0.1:5000/echoserver:latest
Run Code Online (Sandbox Code Playgroud)
这是我的复制控制器
apiVersion: v1
kind: ReplicationController
metadata:
labels:
role: echo-server …Run Code Online (Sandbox Code Playgroud)