在RedisEnterpriseCluster上建立外部路由

Ingress 是一种 API 资源,它提供了一种标准化且灵活的方式来管理对 Kubernetes 集群内运行服务的外部访问。

安装Ingress控制器

Redis Enterprise for Kubernetes 支持以下 Ingress 控制器:

OpenShift 用户可以使用 routes 而不是 Ingress。

安装您选择的Ingress控制器,确保启用了ssl-passthroughssl-passthrough在NGINX中默认关闭,但在HAProxy中默认启用。

配置DNS

  1. 根据以下推荐的命名规范选择您将用于访问数据库的主机名(FQDN),并将<placeholders>替换为您自己的值。

    REC API 主机名: api-<rec-name>-<rec-namespace>.<subdomain> REAADB 主机名: -db-<rec-name>-<rec-namespace>.<subdomain>

    我们建议使用通配符(*)代替数据库名称,后跟主机名后缀。

  2. 检索您的Ingress控制器的LoadBalancer服务的EXTERNAL-IP

    $ kubectl get svc <haproxy-ingress | ingress-ngnix-controller> \
                        -n <ingress-ctrl-namespace>
    

    以下是在AWS托管的K8s集群上运行的HAProxy入口控制器的示例输出。

    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
    
  3. 创建DNS记录,将您选择的REC API主机名和数据库主机名解析为上一步中找到的EXTERNAL-IP

编辑REC规范

编辑 RedisEnterpriseCluster (REC) 规范以添加 ingressOrRouteSpec 字段,将下面的 <placeholders> 替换为您自己的值。

NGINX 或 HAproxy 入口控制器

  • 定义您在配置DNS时选择的REC API主机名(apiFqdnUrl)和数据库主机名后缀(dbFqdnSuffix)。
  • method 设置为 ingress
  • ssl-passthrough 设置为 "true"。
  • 为您的入口控制器添加任何所需的额外注释。有关更多信息,请参阅NGINX文档HAproxy文档
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 路由

  • 定义您在配置DNS时选择的REC API主机名(apiFqdnUrl)和数据库主机名后缀(dbFqdnSuffix)。
  • method 设置为 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 路由在 ingressOrRouteSpec 中不需要任何 ingressAnnotations

RATE THIS PAGE
Back to top ↑