[英]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:
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.