小编Ram*_*nti的帖子

如何在 kubernetes 中的不同端口而不是端口 80 上配置 echo pod

apiVersion: v1
    kind: Pod
    metadata:
       name: echo-pod
       namespace: echo
    spec:
       containers:
       - name: nginx
         image: nginx
         ports:
            -  containerPort: 81
Run Code Online (Sandbox Code Playgroud)

尝试通过运行上面的 yaml 文件来连接端口 81,但它仍在端口 80 上连接。使用 telnet 检查连接

echo -pod的ip是192.168.211.1

能够从 busybox pod(已存在)在端口 80 上连接 echo pod,但不能在端口 81 上连接。您可以观察到以下内容

root@ip-172-31-16-143:~# kubectl exec busybox -- telnet 192.168.211.1 80
Connected to 192.168.211.1

root@ip-172-31-16-143:~# kubectl exec busybox -- telnet 192.168.211.1 81
telnet: can't connect to remote host (192.168.211.1): Connection refused
command terminated with exit code 1
Run Code Online (Sandbox Code Playgroud)

kubernetes

2
推荐指数
1
解决办法
2235
查看次数

标签 统计

kubernetes ×1