查找 AKS 群集的 URL

Finding the URL for an AKS Cluster

我已经设置了一个 AKS 群集,现在正在尝试连接到它。我的部署 YAML 在这里:

apiVersion: v1
kind: Pod
spec: 
  containers:
    - name: dockertest20190205080020
      image: dockertest20190205080020.azurecr.io/dockertest
      ports:
      - containerPort: 443
metadata: 
  name: my-test

如果我 运行 仪表板,我得到这个:

它看起来应该告诉我外部端点,但不是。我有一个理论,这是因为 Yaml 文件只部署了一个 Pod,它在某种程度上无法公开端点 - 是这样吗?如果是这样,为什么?否则,我如何找到这个端点?

那不是它的工作原理,您需要阅读基本的 kubernetes 概念。 Pods 只是容器,要公开 pods 你需要创建服务(并且你需要标签),要公开 pods 外部你需要将服务类型设置为 LoadBalancer。您可能想使用部署而不是 pods,它很多 easier\reliable.

https://kubernetes.io/docs/concepts/services-networking/service/
https://kubernetes.io/docs/concepts/workloads/controllers/deployment/

简而言之,您需要将标签添加到您的 pod 并创建一个负载均衡器类型的服务,其选择器与您的 pods 标签相匹配

kind: Service
apiVersion: v1
metadata:
  name: my-service
spec:
  selector:
    app: MyApp
  ports:
  - protocol: TCP
    port: 80
    targetPort: 443
  type: LoadBalancer