Loading

K8S的Ingress

原文博客:https://nosae.top

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: tls-example-ingress
spec:
tls:

注意这里是一个数组,可以配置多个hosts + secretName,即可以配置多个证书

  • hosts:
    • https-example.foo.com
      secretName: testsecret-tls
      rules:
  • host: https-example.foo.com
    http:
    paths:
    • path: /
      pathType: Prefix
      backend:
      service:
      name: service1
      port:
      number: 80

### 负载均衡

Ingress 本身不能让你配置“高级负载均衡策略”。 你想要更智能的负载均衡(例如会话保持、动态权重)只能在 Service 的 LoadBalancer 层实现,Ingress 只做基本的转发策略。因为 Ingress 是 L7 路由入口,不是高级负载均衡器。Ingress 只做:

- Path/Host 路由
- TLS 终止
- 基础反向代理
- 基础健康检查

它不像 Istio、Nginx(这里是指 Nginx 本身,而不是 Nginx Ingress Controller)、Envoy 那样是高级 L7 网关。高级 LB 特性都在 Service 层,不在 Ingress 层:

Client
|
v
Ingress Controller (basic LB only)
|
v
Service (L4 LB from Kubernetes/cloud LB)
|
v
Pods


apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example
namespace: foo
spec:
ingressClassName: nginx
rules:
- host: www.example.com
http:
paths:
- pathType: Prefix
backend:
service:
name: exampleService
port:
number: 80
path: /

posted @ 2025-12-12 00:43  NOSAE  阅读(3)  评论(0)    收藏  举报