美文网首页
k8s ingress对外暴露接口的几种方式

k8s ingress对外暴露接口的几种方式

作者: hugoren | 来源:发表于2021-05-26 20:45 被阅读0次

    先看结果

    DaemonSet+HostNetwork+nodeSelector

    image.png

    Deployment+NodePort模式的Service

    image.png

    Deployment+LoadBalancer模式的Service

    修改deploy.yaml的service


    image.png

    因没有外部地址,一直处于pending状态


    image.png

    原理

    为什么需要ingress?实际就是service的service

    service不足

    1.nodepoint过多,管理不便
    2.cluster-ip 只能在同一个集群内访问
    3.lb增加费用

    调用过程controller(pod)运行着nginx-->ingress配置调用指向service

    controller上运行的nginx
    ingress 的service配置
    apiVersion: networking.k8s.io/v1beta1
    kind: Ingress
    metadata:
      name: ingress-nginx
      namespace: test
      annotations:
        # use the shared ingress-nginx
        kubernetes.io/ingress.class: "nginx"
        nginx.ingress.kubernetes.io/use-regex: "true"
    spec:
      rules:
      - host: hugo.com
        http:
          paths:
          - path: /
            backend:
              serviceName: svc-nginx
              servicePort: 80
    

    相关文章

      网友评论

          本文标题:k8s ingress对外暴露接口的几种方式

          本文链接:https://www.haomeiwen.com/subject/dwwksltx.html