测试 nginx 和 alpine 与 hello world 的连接
testing nginx and alpine connection with hello world
我有一个由 1 个 nginx 容器和 1 个 alpine 容器组成的 kubernetes pod。我想用 hello world 进行测试,以确保我可以从 nginx 卷曲高山。谁能告诉我如何最好地测试它?
我是否需要将文件从主机复制到 pod,如果需要,我最好怎么做?
当你设置 nginx 时,在它前面设置一个服务,然后你应该能够在那个 alpine 容器上的交互式会话中使用 curl,或者作为你 运行 并杀死,或使用 exec
打开会话并执行您想要的操作。
a walk-through on how to run nginx as a stateless application using a deployment that you can follow for the first part of this, and then the docs on kubernetes services 应该可以让您了解如何构建该服务。您也可以使用快捷方式创建此服务,只需使用以下命令:
kubectl expose deployment nginx-deployment --port=80
这将与文档中的示例部署相匹配。
创建该服务后,它将在该集群中拥有 a DNS entry that will be visible to other pods。您可以通过使用同一个 Alpine 容器中的 nslookup
来很容易地进行审查。您可以 运行 一个 quick'n'dirty interactive alpine container with:
kubectl run -it alpine-interactive --image=alpine -- sh
然后:
nslookup nginx-deployment.default
和
curl nginx-deployment.default
应该能带你去你想去的地方。
(我在没有环境的情况下写这篇文章来仔细检查,但希望它相当接近准确)
我有一个由 1 个 nginx 容器和 1 个 alpine 容器组成的 kubernetes pod。我想用 hello world 进行测试,以确保我可以从 nginx 卷曲高山。谁能告诉我如何最好地测试它?
我是否需要将文件从主机复制到 pod,如果需要,我最好怎么做?
当你设置 nginx 时,在它前面设置一个服务,然后你应该能够在那个 alpine 容器上的交互式会话中使用 curl,或者作为你 运行 并杀死,或使用 exec
打开会话并执行您想要的操作。
a walk-through on how to run nginx as a stateless application using a deployment that you can follow for the first part of this, and then the docs on kubernetes services 应该可以让您了解如何构建该服务。您也可以使用快捷方式创建此服务,只需使用以下命令:
kubectl expose deployment nginx-deployment --port=80
这将与文档中的示例部署相匹配。
创建该服务后,它将在该集群中拥有 a DNS entry that will be visible to other pods。您可以通过使用同一个 Alpine 容器中的 nslookup
来很容易地进行审查。您可以 运行 一个 quick'n'dirty interactive alpine container with:
kubectl run -it alpine-interactive --image=alpine -- sh
然后:
nslookup nginx-deployment.default
和
curl nginx-deployment.default
应该能带你去你想去的地方。
(我在没有环境的情况下写这篇文章来仔细检查,但希望它相当接近准确)