【问题标题】:How to set an ingress with ClusterIP in AWS-EKS如何在 AWS-EKS 中使用 ClusterIP 设置入口
【发布时间】:2022-12-12 10:16:37
【问题描述】:

我是 AWS EKS 的新手,我想知道如何设置入口并启用 TLS(使用 lets-encrypt 等免费服务)。

我已经部署了一个 EKS 集群,并且我有以下示例 nginx 清单。

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service-loadbalancer
spec:
  type: LoadBalancer.  // <------ can't I use a ClusterIp and still have a LB priovisioned?
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80        
---
#05-ALB-Ingress-Basic.yml
# Annotations Reference:  https://kubernetes-sigs.github.io/aws-alb-ingress-controller/guide/ingress/annotation/
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-usermgmt-restapp-service
  labels:
    app: usermgmt-restapp
  annotations:
    # Ingress Core Settings
    kubernetes.io/ingress.class: "alb"
    alb.ingress.kubernetes.io/scheme: internet-facing
    # Health Check Settings
    alb.ingress.kubernetes.io/healthcheck-protocol: HTTP 
    alb.ingress.kubernetes.io/healthcheck-port: traffic-port
    alb.ingress.kubernetes.io/healthcheck-path: /usermgmt/health-status
    alb.ingress.kubernetes.io/healthcheck-interval-seconds: '15'
    alb.ingress.kubernetes.io/healthcheck-timeout-seconds: '5'
    alb.ingress.kubernetes.io/success-codes: '200'
    alb.ingress.kubernetes.io/healthy-threshold-count: '2'
    alb.ingress.kubernetes.io/unhealthy-threshold-count: '2'
spec:
  rules:
  - http:
      paths:
      - path: /*
        pathType: Prefix
        backend:
          service:
            name: nginx-service-loadbalancer
            port:
              number: 80              

当它创建 LoadBalancer 类型的服务时,它会继续创建一个 classic 负载均衡器。

我的问题是:

  1. 我如何(自动)配置第 7 层应用程序负载均衡器而不是 classic 负载均衡器

  2. 我可以不使用 LoadBalancer 类型的服务,而是使用 ClusterIP 服务并使用我的入口指向它并仍然创建一个自动负载均衡器吗?

    谢谢!

【问题讨论】:

    标签: amazon-web-services nginx kubernetes kubernetes-ingress


    【解决方案1】:
    1. 如何(自动)配置第 7 层应用程序负载 平衡器而不是经典的负载平衡器

      通过使用入口资源并指定 kubernetes.io/ingress.class: "alb"

      1. 我可以不使用 LoadBalancer 类型的服务,而是使用 ClusterIP 服务并使用我的入口指向它并且仍然 创建一个自动负载均衡器?

      是的,当使用 alb 带有注释 alb.ingress.kubernetes.io/target-type: ip 的入口资源时,您可以使用 clusterip 服务。

      所以请不要同时创建服务类型的负载均衡器和入口资源。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-07-08
      • 2021-12-29
      • 2021-05-16
      • 2020-06-28
      • 2021-03-22
      • 2020-07-23
      • 1970-01-01
      • 2019-07-14
      相关资源
      最近更新 更多