【发布时间】:2021-09-22 19:34:09
【问题描述】:
我正在学习 K8s,并使用下面的 yaml 创建了一个 nginx pod
apiVersion: v1
kind: Pod
metadata:
name: apache-manual
spec:
containers:
- image: ewoutp/docker-nginx-curl
name: apache-manual
ports:
- containerPort: 8080
protocol: TCP
我现在使用命令 microk8s.kubectl create -f k8s-apache.yaml 运行这个 pod,如果我描述我的 pod 它看起来像
Name: apache-manual
Namespace: default
Priority: 0
Node: itsupport-thinkpad-l490/192.168.0.190
Start Time: Wed, 22 Sep 2021 15:30:15 +0530
Labels: <none>
Annotations: <none>
Status: Running
IP: 10.1.7.69
IPs:
IP: 10.1.7.69
Containers:
apache-manual:
Container ID: containerd://b7f1e7c2779076b786c001de2743d53f8c44214a1f3f98a21a77321f036138bf
Image: ewoutp/docker-nginx-curl
Image ID: sha256:806865143d5c6177c9fad6f146cc2e01085f367043f78aa16f226da5c09217b2
// ##### PORT it's taking is 8080 here but when I am hitting curl on 8080 it's failing but working on port 80 #########
Port: 8080/TCP
Host Port: 0/TCP
State: Running
Started: Wed, 22 Sep 2021 15:30:20 +0530
Ready: True
Restart Count: 0
Environment: <none>
// other stuff
现在如果我正在执行 **microk8s.kubectl exec -it apache-manual -- curl http://localhost:8080 ** 当 microk8s.kubectl exec -it apache-manual -- curl http://localhost:80 工作正常时,它给了我连接被拒绝,我无法理解为什么 nginx 默认运行端口,即 80,但不在我在上述 yaml 中指定的端口上,即 - containerPort: 8080
我错过了什么吗?
【问题讨论】:
标签: nginx kubernetes