无法通过LoadBalancer Azure Kubernetes Service访问Pod

euoag5mw  于 2023-05-16  发布在  Kubernetes
关注(0)|答案(1)|浏览(194)

昨天我把我的webapi部署到了AKS,除了这个pod,我还创建了一个LoadBalancer。由于某种原因,我无法从Postman调用我的API而不给出错误:
错误:connect ETIMEDOUT {{负载均衡的外部ip}}:8080
这是我的部署。yml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: neume-billing-service-deployment
  labels:
    app: neume-billing-service
spec:
  replicas: 1
  selector:
    matchLabels:
      app: neume-billing-service-pod
  template:
    metadata:
      labels:
        app: neume-billing-service-pod
    spec:
      containers:
        - name: neume-billing-service-container
          image: neume.azurecr.io/neume:v2
          ports:
            - containerPort: 80

这就是服务。yml:

apiVersion: v1
kind: Service
metadata:
  name: neume-service
spec:
  selector:
    app: neume-billing-service-pod
  ports:
  - port: 8080
    targetPort: 80
  type: LoadBalancer

下面是kubectl describe pod命令:

Name:             neume-billing-service-deployment-7dc454b957-b9vtb
Namespace:        namespace-workflow-1683420009400
Priority:         0
Service Account:  default
Node:             aks-agentpool-39303421-vmss000003/10.224.0.4
Start Time:       Sun, 07 May 2023 12:34:02 +0000
Labels:           app=neume-billing-service-pod
                  pod-template-hash=7dc454b957
Annotations:      <none>
Status:           Running
IP:               10.244.0.8
IPs:
  IP:           10.244.0.8
Controlled By:  ReplicaSet/neume-billing-service-deployment-7dc454b957
Containers:
  neume-billing-service-container:
    Container ID:   containerd://b4e24117d6998222f638b9b43a926348f725dabf40799a61d9f4cdada492797b
    Image:          neume.azurecr.io/neume:80bc1072755113ebb4b39249d9b738ffbd769bd0
    Image ID:       neume.azurecr.io/neume@GITHUB.SHA
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Sun, 07 May 2023 12:34:16 +0000
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-frgpd (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  kube-api-access-frgpd:
    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
  ----     ------            ----  ----               -------
  Warning  FailedScheduling  43m   default-scheduler  0/1 nodes are available: 1 node(s) had untolerated taint {node.kubernetes.io/network-unavailable: }. preemption: 0/1 nodes are available: 1 Preemption is not helpful for scheduling.
  Normal   Scheduled         42m   default-scheduler  Successfully assigned namespace-workflow-1683420009400/neume-billing-service-deployment-7dc454b957-b9vtb to aks-agentpool-39303421-vmss000003
  Normal   Pulling           42m   kubelet            Pulling image "neume.azurecr.io/neume:80bc1072755113ebb4b39249d9b738ffbd769bd0"
  Normal   Pulled            42m   kubelet            Successfully pulled image "neume.azurecr.io/neume:80bc1072755113ebb4b39249d9b738ffbd769bd0" in 4.458762571s (12.044207816s including waiting)
  Normal   Created           42m   kubelet            Created container neume-billing-service-container
  Normal   Started           42m   kubelet            Started container neume-billing-service-container

下面是服务的describe命令:

Name:                     neume-service
Namespace:                default
Labels:                   <none>
Annotations:              <none>
Selector:                 app=neume-billing-service-pod
Type:                     LoadBalancer
IP Family Policy:         SingleStack
IP Families:              IPv4
IP:                       10.0.178.196
IPs:                      10.0.178.196
LoadBalancer Ingress:     20.23.207.47
Port:                     <unset>  8080/TCP
TargetPort:               80/TCP
NodePort:                 <unset>  31656/TCP
Endpoints:                <none>
Session Affinity:         None
External Traffic Policy:  Cluster
Events:
  Type    Reason                Age   From                Message
  ----    ------                ----  ----                -------
  Normal  EnsuringLoadBalancer  16m   service-controller  Ensuring load balancer
  Normal  EnsuredLoadBalancer   16m   service-controller  Ensured load balancer

如果我在AKS Jmeter 板中单击我的服务并转到“Pod”选项卡,我看不到为此服务列出的Pod。
每当我运行kubectl get pods命令时,它都说我的pod运行得很好。
Stack Overflow上已经存在的问题似乎都没有帮助我,所以我希望有人能告诉我我在这里做错了什么。
这是一个熟悉在云中运行的Kubernetes的项目,所以我不太担心在这个问题中暴露的IP地址。

rbpvctlc

rbpvctlc1#

从您发布的屏幕截图中可以观察到,部署位于 namespace-workflow-1683420009400 命名空间中,服务位于 default 命名空间中。要在服务和pod之间建立连接,两者都应该在namespace中,或者必须配置dns名称以连接不同namespace的服务。请参阅access service from different namespace | 8gwifi.org链接,了解跨不同名称空间的连接服务。
问:如果我在AKS控制面板中点击我的服务并转到“Pod”选项卡,我看不到此服务的Pod列表。每当我运行kubectl get pods命令时,它都说我的pod运行得很好。
要在AKS Jmeter 板中查看Pod,请执行以下过程。

在portal中,AKS集群>工作负载> pod并选择所需的过滤器。

要查看服务,请转到服务和入口。

相关问题