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
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 ×1