在 RedisEnterpriseCluster 上建立外部路由

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

安装 Ingress 控制器

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

OpenShift 用户可以使用路由而不是 Ingress。

安装您选择的 Ingress 控制器,确保ssl-passthrough已启用。ssl-passthrough对于 NGINX 默认是关闭的,但对于 HAProxy 默认是启用的。

配置 DNS

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

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

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

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

    $ 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
  • 设为。methodingress
  • 设置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
  • 设为。methodopenShiftRoute
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\"}}}"

ingressAnnotationsOpenShift路由不需要任何ingressOrRouteSpec

给此页面评分
返回顶部 ↑