简体   繁体   English

通过入口访问所有 kubernetes statefulset pod

[英]Access to all kubernetes statefulset pods via ingress

Using a STS with 3 pods: "pod-0, pod-1, pod-2" to create an Apache Spark cluster, each pod is a worker with logs available via HTTP.使用具有 3 个 pod 的 STS:“pod-0, pod-1, pod-2”来创建 Apache Spark 集群,每个 pod 都是一个工作器,其日志可通过 HTTP 获得。

In order to see logs, I would like to access to all pods via a HTTP ingress, something like:为了查看日志,我想通过 HTTP 入口访问所有 pod,例如:

"https://pod-0.my-ingress.domain" or "https://my-ingress.domain/pod-0" “https://pod-0.my-ingress.domain”或“https://my-ingress.domain/pod-0”

Is it possible to do this automatically by declaring a single Ingress?是否可以通过声明一个 Ingress 来自动执行此操作?

There is no out of the box solution in kubernetes for this, but you could create service per each pod in the statefulset and then reference it in the ingress: kubernetes 中没有开箱即用的解决方案,但您可以在 statefulset 中为每个 pod 创建服务,然后在入口中引用它:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: sts-ingress
spec:
  rules:
  - http:
      paths:
      - path: /pod-0
        pathType: Prefix
        backend:
          service:
            name: pod-0
            port:
              number: 80
      - path: /pod-1
        pathType: Prefix
        backend:
          service:
            name: pod-1
            port:
              number: 80

You could leverage operator pattern to automate it, an example of metacontroller already exists for this use case: https://github.com/metacontroller/metacontroller/tree/master/examples/service-per-pod您可以利用操作员模式将其自动化,此用例已经存在元控制器示例: https://github.com/metacontroller/metacontroller/tree/master/examples/service-per-pod

I had the same kind of issue with a DaemonSet.我对 DaemonSet 也有同样的问题。

I solve my issue with a Docker image: dyn-ingress我用 Docker 图像解决了我的问题: dyn-ingress

This container needs access to the Host Kubernetes:此容器需要访问主机 Kubernetes:

  • Ingress to maintain Ingress routes to all pods. Ingress 维护到所有 Pod 的 Ingress 路由。
  • Service to create and maintain a dedicated service per pod.为每个 pod 创建和维护专用服务的服务。
  • Pod to watch them and add labels on them. Pod 观看它们并在它们上添加标签。

The current version only support adding route like: http://<host>/nodename/ And host a webServer that can list the current nodes.当前版本仅支持添加路由如: http://<host>/nodename/并托管一个可以列出当前节点的webServer。

For your case you prefer url likes http://<host>/podname/ or http://podname.<host>/对于您的情况,您更喜欢 url 喜欢http://<host>/podname/http://podname.<host>/

I'm looking for feedback.我正在寻找反馈。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何连接 kubernetes 中的 2 个 pod,因为它们位于同一个本地网络中且所有端口均已打开 - How to connect 2 pods in kubernetes as they were in the same local-net with all the ports opened 如何在Kubernetes中从外部公开StatefulSet cassandra集群的无头服务 - How to expose a headless service for a StatefulSet cassandra cluster externally in Kubernetes Spark Executors PODS 在 Kubernetes 部署中待定 State 部署 - Spark Executors PODS in Pending State on Kubernetes Deployment 优雅地杀死 kubernetes 中的容器和 Pod,并出现火花异常 - Gracefully killing container and pods in kubernetes with spark exception Spark 中的数据局部性在 Kubernetes 与 HDFS pod 位于同一位置 - Data Locality in Spark on Kubernetes colocated with HDFS pods Kubernetes 上的 Spark:执行程序 pod 被无声地杀死 - Spark on Kubernetes: Executor pods silently get killed 如何在 Kubernetes 容器/Pod 上挂载 S3 存储桶? - How to mount S3 bucket on Kubernetes container/pods? 每个Kubernetes节点运行多少个Spark Executor Pod - How many Spark Executor Pods you run per Kubernetes Node 使用kubernetes作为主文件创建后,Spark执行器Pod迅速出错 - Spark executor pods quickly in error after their creation using kubernetes as master kubernetes 上的 Spark:执行程序 pod 在创建 sparkContext 时无法启动 - Spark on kubernetes: Executor pods not able to start and while creating sparkContext
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM