这就是我要做的:获取上一步创建的nginx的ip,使用临时的busybox映像来获取它的'/‘。
现在我的问题是,当我运行这个命令时,它是有效的:
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}')但是当我这样做的时候,它就行不通了。有人能解释我为什么吗?
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发布于 2022-05-21 15:57:11
你必须先创建一个尼克斯吊舱。这就是所谓的“前一步”。
$ kubectl run nginx --image=nginx --restart=Never --port=80
pod/nginx created然后,您可以在BusyBox荚中运行wget:
$ 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" deletedhttps://stackoverflow.com/questions/72296932
复制相似问题