我想将我的selenium / hub容器链接到POD中的chrome和firefox节点容器 .
在docker中,它很容易在docker compose yaml文件中定义 . 我想知道如何在kubernetes中实现这种链接 .
这是日志中出现的内容:
这是错误图像:
apiVersion: v1
kind: Pod
metadata:
name: mytestingpod
spec:
containers:
- name: seleniumhub
image: selenium/hub
ports:
- containerPort: 4444
hostPort: 4444
- name: chromenode
image: selenium/node-chrome-debug
ports:
- containerPort: 5901
links: seleniumhub:hub
- name: firefoxnode
image: selenium/node-firefox-debug
ports:
- containerPort: 5902
links: seleniumhub:hub
2:
2 回答
您不需要链接它们 . Kubernetes的工作方式,all the containers in the same Pod are already on the same networking namespace,意味着他们可以通过
localhost
和正确的端口相互交谈 .如果要从
seleniumhub
容器访问chromenode
容器,只需向localhost:5901发送请求 .如果要从
chromenode
容器访问seleniumhub
容器,只需向localhost发送请求:4444 .只需使用“Translate a Docker Compose File to Kubernetes Resources”中描述的 kompose :它会将您的
docker-compose.yml
文件转换为kubernetes yaml文件 .然后,您将看到如何将selenium / hub容器声明转换为kubernetes配置文件 .
请注意,docker link已过时 .
请尝试关注kubernetes examples/selenium,它们是described here .
将应用程序与Kubernetes连接的方式是通过服务:
见“Connecting Applications with Services” .