8.2. 流程
按照以下步骤将 Keycloak 站点重新添加到 AWS 全局加速器,以便它可以处理客户端请求。
8.2.1. 全局加速器
确定与要上线的站点关联的 Network Load Balancer (NLB)的 ARN
命令:
NAMESPACE= 1 REGION= 2 HOSTNAME=$(oc -n $NAMESPACE get svc accelerator-loadbalancer --template="{{range .status.loadBalancer.ingress}}{{.hostname}}{{end}}") aws elbv2 describe-load-balancers \ --query "LoadBalancers[?DNSName=='${HOSTNAME}'].LoadBalancerArn" \ --region ${REGION} \ --output text
输出:
arn:aws:elasticloadbalancing:eu-west-1:606671647913:loadbalancer/net/a49e56e51e16843b9a3bc686327c907b/9b786f80ed4eba3d
更新加速器 EndpointGroup,使其包含两个站点
列出 Global Accelerator 的 EndpointGroup 中的当前端点
命令:
ACCELERATOR_NAME= 1 ACCELERATOR_ARN=$(aws globalaccelerator list-accelerators \ --query "Accelerators[?Name=='${ACCELERATOR_NAME}'].AcceleratorArn" \ --region us-west-2 \ 2 --output text ) LISTENER_ARN=$(aws globalaccelerator list-listeners \ --accelerator-arn ${ACCELERATOR_ARN} \ --query "Listeners[*].ListenerArn" \ --region us-west-2 \ --output text ) aws globalaccelerator list-endpoint-groups \ --listener-arn ${LISTENER_ARN} \ --region us-west-2
输出:
{ "EndpointGroups": [ { "EndpointGroupArn": "arn:aws:globalaccelerator::606671647913:accelerator/d280fc09-3057-4ab6-9330-6cbf1f450748/listener/8769072f/endpoint-group/a30b64ec1700", "EndpointGroupRegion": "eu-west-1", "EndpointDescriptions": [ { "EndpointId": "arn:aws:elasticloadbalancing:eu-west-1:606671647913:loadbalancer/net/a3c75f239541c4a6e9c48cf8d48d602f/5ba333e87019ccf0", "Weight": 128, "HealthState": "HEALTHY", "ClientIPPreservationEnabled": false } ], "TrafficDialPercentage": 100.0, "HealthCheckPort": 443, "HealthCheckProtocol": "TCP", "HealthCheckIntervalSeconds": 30, "ThresholdCount": 3 } ] }
更新 EndpointGroup,使其包含现有的 Endpoint 和第 1 步中获取的 NLB。
命令:
aws globalaccelerator update-endpoint-group \ --endpoint-group-arn arn:aws:globalaccelerator::606671647913:accelerator/d280fc09-3057-4ab6-9330-6cbf1f450748/listener/8769072f/endpoint-group/a30b64ec1700 \ --region us-west-2 \ --endpoint-configurations ' [ { "EndpointId": "arn:aws:elasticloadbalancing:eu-west-1:606671647913:loadbalancer/net/a3c75f239541c4a6e9c48cf8d48d602f/5ba333e87019ccf0", "Weight": 128, "ClientIPPreservationEnabled": false }, { "EndpointId": "arn:aws:elasticloadbalancing:eu-west-1:606671647913:loadbalancer/net/a49e56e51e16843b9a3bc686327c907b/9b786f80ed4eba3d", "Weight": 128, "ClientIPPreservationEnabled": false } ] '