求助:无法在Minikube集群外部访问部署的Flask API
无法从Minikube集群外部访问Flask API的排障求助
我是Kubernetes新手,部署Flask应用后,能在集群内部(容器内、其他测试Pod)正常访问API,但无法从Minikube集群外部访问。以下是详细信息:
API信息
call: curl http://10.101.180.25:81/api/v1.0/result expected output: {"result":[]}
集群内部访问验证
容器内访问成功:
user2@abc-poc-deployment-655c5c5999-dcgxz:/app$ curl http://10.101.180.25:81/api/v1.0/result {"result":[]} user2@abc-poc-deployment-655c5c5999-dcgxz:/app$
额外验证:部署了另一个测试Pod,从该Pod内也能正常访问API,仅集群外部无法访问。
环境与资源详情
Minikube配置
user@machine1:~/project/pro-oso-abc$ minikube profile list |----------------|-----------|------------|--------------|------|---------|---------|-------|--------| | Profile | VM Driver | Runtime | IP | Port | Version | Status | Nodes | Active | |----------------|-----------|------------|--------------|------|---------|---------|-------|--------| | minikube | docker | containerd | 192.168.49.2 | 6443 | v1.26.3 | Stopped | 1 | * | | poc-abc-deploy | docker | containerd | 192.168.58.2 | 8443 | v1.26.3 | Running | 1 | | |----------------|-----------|------------|--------------|------|---------|---------|-------|--------|
Pod信息
Pod列表
user@machine1:~/practise/deployments/poc_abc_deploy$ kubectl get pods -n abc-poc-ns NAME READY STATUS RESTARTS AGE abc-poc-deployment-655c5c5999-dcgxz 1/1 Running 1 (27m ago) 54m user@machine1:~/practise/deployments/poc_abc_deploy$
Pod描述
user@machine1:~/practise/deployments/poc_abc_deploy$ kubectl describe pod abc-poc-deployment-655c5c5999-dcgxz -n abc-poc-ns Name: abc-poc-deployment-655c5c5999-dcgxz Namespace: abc-poc-ns Priority: 0 Service Account: default Node: poc-abc-deploy/192.168.58.2 Start Time: Mon, 26 Jun 2023 02:05:30 +0530 Labels: app=abc-poc pod-template-hash=655c5c5999 Annotations: <none> Status: Running IP: 10.244.0.3 IPs: IP: 10.244.0.3 Controlled By: ReplicaSet/abc-poc-deployment-655c5c5999 Containers: abc-poc-container: Container ID: containerd://29aa1cc2e719087443f2e9f65187c9e6b0265eb1cffc5c34d9416f8d6bc149cc Image: user11/abc_poc_repo:v1.1 Image ID: sha256:ebc3cd704a425aac030c681959db1e2a65d4412114f0dcd019616070bbee3023 Port: 5000/TCP Host Port: 0/TCP State: Running Started: Mon, 26 Jun 2023 02:32:59 +0530 Last State: Terminated Reason: Unknown Exit Code: 255 Started: Mon, 26 Jun 2023 02:05:30 +0530 Finished: Mon, 26 Jun 2023 02:32:31 +0530 Ready: True Restart Count: 1 Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-cht87 (ro) Conditions: Type Status Initialized True Ready True ContainersReady True PodScheduled True Volumes: kube-api-access-cht87: Type: Projected (a volume that contains injected data from multiple sources) TokenExpirationSeconds: 3607 ConfigMapName: kube-root-ca.crt ConfigMapOptional: <nil> DownwardAPI: true QoS Class: BestEffort Node-Selectors: <none> Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s node.kubernetes.io/unreachable:NoExecute op=Exists for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 55m default-scheduler Successfully assigned abc-poc-ns/abc-poc-deployment-655c5c5999-dcgxz to poc-abc-deploy Normal Pulled 55m kubelet Container image "user11/abc_poc_repo:v1.1" already present on machine Normal Created 55m kubelet Created container abc-poc-container Normal Started 55m kubelet Started container abc-poc-container Normal SandboxChanged 28m kubelet Pod sandbox changed, it will be killed and re-created. Normal Pulled 28m kubelet Container image "user11/abc_poc_repo:v1.1" already present on machine Normal Created 28m kubelet Created container abc-poc-container Normal Started 28m kubelet Started container abc-poc-container user@machine1:~/practise/deployments/poc_abc_deploy$
Service信息
Service列表
user@machine1:~/practise/deployments/poc_abc_deploy$ kubectl get svc -n abc-poc-ns NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE abc-poc-service NodePort 10.101.180.25 <none> 81:30701/TCP 85m user@machine1:~/practise/deployments/poc_abc_deploy$
Service描述
user@machine1:~/practise/deployments/poc_abc_deploy$ kubectl describe svc abc-poc-service -n abc-poc-ns Name: abc-poc-service Namespace: abc-poc-ns Labels: <none> Annotations: <none> Selector: app=abc-poc Type: NodePort IP Family Policy: SingleStack IP Families: IPv4 IP: 10.101.180.25 IPs: 10.101.180.25 Port: <unset> 81/TCP TargetPort: 5000/TCP NodePort: <unset> 30701/TCP Endpoints: 10.244.0.3:5000 Session Affinity: None External Traffic Policy: Cluster Events: <none> user@machine1:~/practise/deployments/poc_abc_deploy$
已经尝试了所有能想到的排障方法,仍无法解决问题,求帮助。
内容的提问来源于stack exchange,提问作者sandy560
相关产品推荐
相关产品推荐

