在 RedisEnterpriseCluster 上建立外部路由
| 适用于 Kubernetes 的 Redis Enterprise |
|---|
Ingress 是一种 API 资源,它提供了一种标准化且灵活的方式来管理对 Kubernetes 集群中运行的服务的外部访问。
安装 Ingress 控制器
Redis Enterprise for Kubernetes 支持以下 Ingress 控制器:
OpenShift 用户可以使用路由而不是 Ingress。
安装您选择的 Ingress 控制器,确保ssl-passthrough已启用。ssl-passthrough对于 NGINX 默认关闭,但对于 HAProxy 默认启用。
配置 DNS
-
根据下面建议的命名约定,选择您将用于访问数据库的主机名 (FQDN),并将
<placeholders>替换为你自己的价值观。REC API 主机名:
api-<rec-name>-<rec-namespace>.<subdomain>REAADB 主机名:-db-<rec-name>-<rec-namespace>.<subdomain>我们建议使用通配符 () 代替数据库名称,后跟主机名后缀。
* -
检索
EXTERNAL-IP的 Ingress 控制器的LoadBalancer服务。$ kubectl get svc <haproxy-ingress | ingress-ngnix-controller> \ -n <ingress-ctrl-namespace>Below is example output for an HAProxy ingress controller running on a K8s cluster hosted by AWS.NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE haproxy-ingress LoadBalancer 10.43.62.53 a56e24df8c6173b79a63d5da54fd9cff-676486416.us-east-1.elb.amazonaws.com 80:30610/TCP,443:31597/TCP 21m -
Create DNS records to resolve your chosen REC API hostname and database hostname to the
EXTERNAL-IPfound in the previous step.
Edit the REC spec
Edit the RedisEnterpriseCluster (REC) spec to add the ingressOrRouteSpec field, replacing <placeholders> below with your own values.
NGINX or HAproxy ingress controllers
- Define the REC API hostname (
apiFqdnUrl) and database hostname suffix (dbFqdnSuffix) you chose when configuring DNS.
- Set
method to ingress.
- Set
ssl-passthrough to "true".
- Add any additional annotations required for your ingress controller. See NGINX docs or HAproxy docs for more information.
kubectl patch rec <rec-name> --type merge --patch "{\"spec\": \
{\"ingressOrRouteSpec\": \
{\"apiFqdnUrl\": \"api-<rec-name>-<rec-namespace>.example.com\", \
\"dbFqdnSuffix\": \"-db-<rec-name>-<rec-namespace>.example.com\", \
\"ingressAnnotations\": \
{\"<kubernetes | github>.io/ingress.class\": \
\"<ingress-controller>\", \
\"<ingress-controller-annotation>/ssl-passthrough\": \ \"true\"}, \
\"method\": \"ingress\"}}}"
OpenShift routes
- Define the REC API hostname (
apiFqdnUrl) and database hostname suffix (dbFqdnSuffix) you chose when configuring DNS.
- Set
method to openShiftRoute.
kubectl patch rec <rec-name> --type merge --patch "{\"spec\": \
{\"ingressOrRouteSpec\": \
{\"apiFqdnUrl\": \"api-<rec-name>-<rec-namespace>.example.com\" \
\"dbFqdnSuffix\": \"-db-<rec-name>-<rec-namespace>.example.com\", \
\"method\": \"openShiftRoute\"}}}"
OpenShift routes do not require any ingressAnnotations in the ingressOrRouteSpec.
On this page