我正试图在一个Pod上暴露8080端口,以便我可以直接从服务器wget。使用端口转发(kubectl --namespace jenkins port-forward pods/jenkins-6f8b486759-6vwkj 9000:8080
),一切都正常工作,我能够连接到127.0.0.1:9000。
但是当我尝试避免使用端口转发并永久开放端口时(kubectl expose deployment jenkins --type=LoadBalancer -njenkins
):
我在svc中看到它(kubectl describe svc jenkins -njenkins
):
Name: jenkins
Namespace: jenkins
Labels: <none>
Annotations: <none>
Selector: app=jenkins
Type: LoadBalancer
IP Families: <none>
IP: 10.111.244.192
IPs: 10.111.244.192
Port: port-1 8080/TCP
TargetPort: 8080/TCP
NodePort: port-1 31461/TCP
Endpoints: 172.17.0.2:8080
Port: port-2 50000/TCP
TargetPort: 50000/TCP
NodePort: port-2 30578/TCP
Endpoints: 172.17.0.2:50000
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
但是端口仍然没有开启,netstat
没有显示任何内容。应该如何正确操作?
使用的 minikube 版本为:v1.20.0,以下是 pod 的 yaml 配置:
apiVersion: apps/v1
kind: Deployment
metadata:
name: jenkins
spec:
replicas: 1
selector:
matchLabels:
app: jenkins
template:
metadata:
labels:
app: jenkins
spec:
securityContext:
containers:
- name: jenkins
image: jenkins/jenkins:lts
ports:
- name: http-port
containerPort: 8080
hostPort: 8080
- name: jnlp-port
containerPort: 50000
volumeMounts:
- name: task-pv-storage
mountPath: /var/jenkins_home
volumes:
- name: task-pv-storage
persistentVolumeClaim:
claimName: task-pv-claim