我已经在 debian 12 上设置了一个 kubernetes 集群(第一次),并且我使用 docker mailserver 项目来安装 pod。
到目前为止一切顺利,但现在我似乎无法将 80 或 443 暴露给可从主机和/或互联网访问的网络。
我的服务
apiVersion: v1
kind: Service
metadata:
name: postfixadmin
namespace: mailserver
spec:
selector:
app: mailserver
tier: postfixadmin
ports:
- port: 80
targetPort: http
我的部署
apiVersion: apps/v1
kind: Deployment
metadata:
name: postfixadmin
namespace: mailserver
spec:
selector:
matchLabels:
app: mailserver
tier: postfixadmin
template:
metadata:
labels:
app: mailserver
tier: postfixadmin
logType: apache
spec:
containers:
- name: postfixadmin
image: technicalguru/mailserver-postfixadmin
imagePullPolicy: IfNotPresent
env:
- name: PFA_DB_HOST
value: "mariadb"
- name: PFA_DB_NAME
value: "mail"
- name: PFA_DB_USER
value: "postfix"
- name: PFA_DB_PASS
value: "<my-mariadb-postfix-password>"
- name: PFA_SETUP_PASS
value: "<my-postfixadmin-setup-password>"
- name: PFA_POSTFIX_SERVER
value: "postfix"
- name: PFA_POSTFIX_PORT
value: "25"
- name: PFA_ABUSE_EMAIL
value: "<my-abuse-email-address>"
- name: PFA_HOSTMASTER_EMAIL
value: "<my-hostmaster-email-address>"
- name: PFA_POSTMASTER_EMAIL
value: "<my-postmaster-email-address>"
- name: PFA_WEBMASTER_EMAIL
value: "<my-webmaster-email-address>"
ports:
- containerPort: 80
name: http
当我描述这个pod时,我得到了这个
Status: Running
IP: 192.168.55.82
IPs:
IP: 192.168.55.82
Port: 80/TCP
Host Port: 0/TCP
State: Running
为什么主机端口为零?
我尝试过在我的服务中使用 NodePort 或 LoadBalancer,但没有效果,我在工作节点上有这些路由
default via 10.0.0.1 dev eth0 proto dhcp
src 10.0.0.5 metric 100
10.0.0.0/24 dev eth0 proto kernel scope l
ink src 10.0.0.5 metric 100
10.0.0.1 dev eth0 proto dhcp scope link s
rc 10.0.0.5 metric 100
168.63.129.16 via 10.0.0.1 dev eth0 proto
dhcp src 10.0.0.5 metric 100
169.254.169.254 via 10.0.0.1 dev eth0 pro
to dhcp src 10.0.0.5 metric 100
172.17.0.0/16 dev docker0 proto kernel sc
ope link src 172.17.0.1 linkdown
192.168.6.64/26 via 10.0.0.4 dev tunl0 pr
oto bird onlink
blackhole 192.168.55.64/26 proto bird
192.168.55.65 dev cali8fb4941a749 scope l
ink
192.168.55.66 dev cali412dc594ad1 scope l
ink
192.168.55.67 dev calife0a454e65c scope l
ink
192.168.55.68 dev cali39db290e63b scope l
ink
192.168.55.70 dev cali0d3689f40c9 scope l
ink
192.168.55.72 dev cali9f9b29a13b3 scope l
ink
192.168.55.73 dev cali2e3727ded1f scope l
ink
192.168.55.75 dev cali6f24beac01c scope l
ink
192.168.55.82 dev cali7040637c394 scope l
ink