首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Kubernetes CKAD准备问题:暴露的端口不工作

Kubernetes CKAD准备问题:暴露的端口不工作
EN

Stack Overflow用户
提问于 2022-05-18 23:12:20
回答 1查看 73关注 0票数 1

这就是我要做的:获取上一步创建的nginx的ip,使用临时的busybox映像来获取它的'/‘。

查找您参考的链接:https://github.com/dgkanatsios/CKAD-exercises/blob/main/a.core_concepts.md#get-nginx-pods-ip-created-in-previous-step-use-a-temp-busybox-image-to-wget-its-

现在我的问题是,当我运行这个命令时,它是有效的:

代码语言:javascript
复制
kubectl run busybox --image=busybox --rm -it --restart=Never -- wget -O- $(kubectl get pod nginx -o jsonpath='{.status.podIP}:{.spec.containers[0].ports[0].containerPort}')

但是当我这样做的时候,它就行不通了。有人能解释我为什么吗?

代码语言:javascript
复制
kubectl get po -o wide # get the IP, will be something like '10.1.1.131'
# create a temp busybox pod
kubectl run busybox --image=busybox --rm -it --restart=Never -- wget -O- 10.1.1.131:80
EN

回答 1

Stack Overflow用户

发布于 2022-05-21 15:57:11

你必须先创建一个尼克斯吊舱。这就是所谓的“前一步”。

代码语言:javascript
复制
$ kubectl run nginx --image=nginx --restart=Never --port=80

pod/nginx created

然后,您可以在BusyBox荚中运行wget:

代码语言:javascript
复制
$  kubectl run BusyBox --image=busybox --rm -it --restart=Never -- wget -O- $(kubectl get pod nginx -o jsonpath='{.status.podIP}:{.spec.containers[0].ports[0].containerPort}')

Connecting to 10.42.0.52:80 (10.42.0.52:80)
writing to stdout
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
-                    100% |********************************|   615  0:00:00 ETA
written to stdout
pod "busybox" deleted
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72296932

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档