【发布时间】:2020-01-20 06:08:00
【问题描述】:
我在 Windows 的“Docker Desktop”上运行 Kubernetes。
我有一个用于具有 3 个副本的部署的 LoadBalancer 服务。 我想通过某种方式访问 SPECIFIC pod (例如通过 URL 路径::8090/pod1)。
有没有办法实现这个用例?
deployment.yaml:
apiVersion: v1 kind: Service metadata: name: my-service1 labels: app: stream spec: ports: - port: 8090 targetPort: 8090 name: port8090 selector: app: stream # clusterIP: None type: LoadBalancer --- apiVersion: apps/v1beta2 kind: Deployment metadata: name: stream-deployment labels: app: stream spec: replicas: 3 selector: matchLabels: app: stream strategy: type: Recreate template: metadata: labels: app: stream spec: containers: - image: stream-server-mock:latest name: stream-server-mock imagePullPolicy: Never env: - name: STREAMER_IP valueFrom: fieldRef: fieldPath: status.podIP - name: STREAMER_ADDRESS value: stream-server-mock:8090 ports: - containerPort: 8090
我的最终目标是实现 pod 的水平自动缩放。
到目前为止,应用程序的设计/工作方式(没有 kubernetes):
有 3 个组件:REST-Server、Stream-Server(3 个实例 本地在不同端口上的不同JVM上)和RabbitMQ。
1 - The client sends a request to "REST-Server" for a stream url.
2 - The REST-Server puts in the RabbitMQ queue.
3 - One of the Stream-Server picks it up and populates its IP and sends back to REST-Server through RabbitMQ.
4 - The client receives the IP and establishes a direct WS connection using the IP.
我面临的问题是:
1 - When the client requests for a stream IP, one of the pods (lets say POD1) picks it up and sends its URL (which is service URL, comes through LoadBalancer Service).
2 - Next time when the client tries to connect (WebSocket Connection) using the Service IP, it wont be the same pod which accepted the request.
它应该与接受请求的 pod 相同,并且必须可供客户端访问。
【问题讨论】:
-
我已经更新了问题
标签: kubernetes kubernetes-ingress kubernetes-pod