Finding the URL for an AKS Cluster

浪尽此生 提交于 2019-12-13 04:16:41

问题


I've set-up an AKS cluster and am now trying to connect to it. My deployment YAML is here:

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

If I run the dashboard, I get this:

Which looks like it should be telling me the external endpoint, but isn't. I have a theory that this is because the Yaml file is only deploying a Pod, which is in some way not able to expose an endpoint - is that the case and if so, why? Otherwise, how can I find this endpoint?


回答1:


Thats not how that works, you need to read up on basic kubernetes concept. Pods are only container, to expose pods you need to create services (and you need labels), to expose pods externally you need to set service type to LoadBalancer. You probably want to use deployments instead of pods, its a lot easier\reliable.

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

so in short, you need to add labels to your pod and create a service of type load balancer with selectors that match your pods labels

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


来源:https://stackoverflow.com/questions/54685755/finding-the-url-for-an-aks-cluster

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!