我为 SpringBoot-Java-App 创建了一个带有部署 + 服务 (LoadBalancer) 的 Kubernetes 集群。如果我想通过外部 IP 访问 Web-App,我会收到超时错误。现在有人如何解决这个问题吗?
LoadBalancerService.yml:
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: webapp
name: webapp
spec:
ports:
- name: 8080-8080
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: webapp
type: LoadBalancer
部署.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: webapp
labels:
app: webapp
spec:
replicas: 4
selector:
matchLabels:
app: webapp
template:
metadata:
labels:
app: webapp
spec:
containers:
- name: webapp-container
image: skrivutenliv/raspi_stress:latest
ports:
- containerPort: 8080
集群概览:
NAME READY STATUS RESTARTS AGE
pod/svclb-webapp-5gs9s 1/1 Running 1 120m
pod/svclb-webapp-qfkzn 1/1 Running 1 120m
pod/nginx-app-b8b875889-272nw 1/1 Running 2 6h26m
pod/webapp-ffb868dbb-nw9bw 1/1 Running 1 121m
pod/webapp-ffb868dbb-4gv8d 1/1 Running 1 121m
pod/webapp-ffb868dbb-8j8ld 1/1 Running 1 121m
pod/svclb-webapp-zsvbf 1/1 Running 1 120m
pod/webapp-ffb868dbb-nps6s 1/1 Running 1 121m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 7d4h
service/webapp LoadBalancer 10.43.216.123 192.168.0.233,192.168.0.235 8080:30313/TCP 120m
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
daemonset.apps/svclb-webapp 3 3 3 3 3 <none> 120m
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/nginx-app 1/1 1 1 5d1h
deployment.apps/webapp 4/4 4 4 121m
NAME DESIRED CURRENT READY AGE
replicaset.apps/nginx-app-b8b875889 1 1 1 5d1h
replicaset.apps/webapp-ffb868dbb 4 4 4 121m
集群节点
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
knode2 Ready <none> 7d v1.18.6+k3s1 192.168.0.233 <none> Raspbian GNU/Linux 10 (buster) 5.4.51-v7l+ containerd://1.3.3-k3s2
knode1 Ready <none> 7d v1.18.6+k3s1 192.168.0.232 <none> Raspbian GNU/Linux 10 (buster) 4.19.118-v7l+ containerd://1.3.3-k3s2
kmasternode Ready master 7d21h v1.18.6+k3s1 192.168.0.231 <none> Raspbian GNU/Linux 10 (buster) 4.19.118-v7l+ containerd://1.3.3-k3s2