为什么 AKS 的外部 IP 不起作用? yaml有问题吗?

Why external IP of AKS is not working? Something wrong with yaml?

我尝试将简单的 API 部署到 AKS。 API 在本地 docker 中工作正常。 我没有错误。我从 AKS 看到状态是 运行。但是浏览器没有响应。有人可以检查 yaml 或提示可能有什么问题吗?

C:\Azure\ACIPythonAPI\conda-flask-api> kubectl get service demo-flask-api --watch
NAME             TYPE           CLUSTER-IP     EXTERNAL-IP    PORT(S)        AGE
demo-flask-api   LoadBalancer   10.0.105.135   11.22.33.44   80:31551/TCP   5m53s

aks.yaml 文件:

apiVersion: v1
kind: Service
metadata:
  name: demo-flask-api
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: demo-flask-api
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: demo-flask-api
spec:
  replicas: 1
  selector:
    matchLabels:
      app: demo-flask-api
  template:
    metadata:
      labels:
        app: demo-flask-api
    spec:
      containers:
      - name: demo-flask-api
        image: mycontainerregistry.azurecr.io/demo/flask-api:v1
        ports:
        - containerPort: 8080

您似乎没有定义 Ingress resource nether an Ingress Controller

这是 MS 的工作流,用于在您的集群上安装 ingress-nginx 作为 Ingress Controller。

然后像这样公开 IC 服务:

apiVersion: v1
kind: Service
metadata:
  annotations:
    service.beta.kubernetes.io/azure-load-balancer-resource-group: myResourceGroup # only needed if the LB is in another RG
  name: ingress-nginx-controller
spec:
  loadBalancerIP: <YOUR_STATIC_IP>
  type: LoadBalancer

Ingress Controller 然后会将传入流量路由到您的演示 flask API,并使用 Ingress 资源:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: minimal-ingress
spec:
  ingressClassName: nginx # ingress-nginx specifix
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: test
            port:
              number: 80