我想做一个简单的流量重定向,从app/mobile.dev.net到app.ops.test.com 让 AWS ALB 由 k8s 入口控制器管理,我决定使用 alb.ingress.kubernetes.io/actions.${action-name} 注释根据official docs
达到这个目标这是最终入口清单:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress-public
namespace: test-stg-aws
uid: <uid>
resourceVersion: 'version'
generation: 11
creationTimestamp: 'date'
labels:
app.kubernetes.io/instance: test-stg-aws
annotations:
alb.ingress.kubernetes.io/actions.redirect-to-app: >-
{"type": "redirect", "redirectConfig": {"protocol": "HTTPS", "port":
"443", "statusCode": "HTTP_301", "host": "app.ops.test.com",
"path": "/" }
alb.ingress.kubernetes.io/backend-protocol: HTTP
alb.ingress.kubernetes.io/certificate-arn: >-
<certificate_arn>
alb.ingress.kubernetes.io/healthcheck-interval-seconds: '30'
alb.ingress.kubernetes.io/healthcheck-path: /health-check
alb.ingress.kubernetes.io/healthcheck-protocol: HTTP
alb.ingress.kubernetes.io/healthy-threshold-count: '2'
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS": 443}]'
alb.ingress.kubernetes.io/load-balancer-attributes: >-
access_logs.s3.enabled=true,access_logs.s3.bucket=test-stg-aws-logs,access_logs.s3.prefix=l<pref>
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/ssl-policy: ELBSecurityPolicy-TLS-1-2-2017-01
alb.ingress.kubernetes.io/ssl-redirect: '443'
alb.ingress.kubernetes.io/subnets: subnet-id
alb.ingress.kubernetes.io/tags: >-
<tags>
alb.ingress.kubernetes.io/target-group-attributes: deregistration_delay.timeout_seconds=10
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/unhealthy-threshold-count: '2'
external-dns.alpha.kubernetes.io/hostname: app-test-stg-aws.dev.net
kubectl.kubernetes.io/last-applied-configuration: >
kubernetes.io/ingress.class: alb
status:
loadBalancer:
ingress:
- hostname: >-
k8s-test-stg-aws.elb.amazonaws.com
spec:
defaultBackend:
service:
name: my-app
port:
name: http-my-app-api
rules:
- host: app.dev.net
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: redirect-to-app
port:
name: use-annotations
- host: mobile.dev.net
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: redirect-to-app
port:
name: use-annotations
我希望在 AWS ALB k8s-test-stg-aws.elb.amazonaws.com 上看到 2 个新的侦听器规则,并重定向到注释中指定的所需主机app.ops.test.comredirect-to-应用
但是在申请之后我看到已经创建了不同的规则:
还不知道这种行为。检查了 ALB 日志但没有运气:没有与这些规则相关的记录(但是我只有访问日志)。关于如何正确使用入口进行重定向的任何想法?
根据官方文档进行设置