gpt4 book ai didi

kubernetes - 查找在 kubernetes 服务后面服务的 pod/VM 实例

转载 作者:可可西里 更新时间:2023-11-01 11:23:36 26 4
gpt4 key购买 nike

我有一个遗留系统(构建它的人已经辞职,无法联系)。所以它是托管在 GKE 中的微服务应用程序。有一项特别的服务非常奇怪。这是一个 redis 服务(因为通过其内部 IP 地址使用此服务的其他 pod 可以使用 redis 服务并执行 redis PING-PONG)。但是,我看到此服务 0/0 没有 pod。知道这是怎么发生的吗?

服务的 YAML 文件如下:

在我们的 kubernetes 集群中,我没有看到任何服务、部署,也没有看到名为 node-1、node-2 或 node-3 的 pod。所以这对我来说很奇怪。有人知道吗?

我已阅读 kubernetes 文档并搜索了解决方案,但找不到任何解释。

apiVersion: v1
kind: Service
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{"kubernetes.io/change-cause":"kubectl apply --record=true --filename=production/svc/dispatchcache-shard-service.yaml"},"name":"dispatchcache-shard","namespace":"default"},"spec":{"ports":[{"name":"node-1","port":7000,"protocol":"TCP","targetPort":7000},{"name":"node-2","port":7001,"protocol":"TCP","targetPort":7000},{"name":"node-3","port":7002,"protocol":"TCP","targetPort":7000}],"type":"ClusterIP"}}
kubernetes.io/change-cause: kubectl apply --record=true --filename=production/svc/dispatchcache-shard-service.yaml
creationTimestamp: 2018-10-03T08:11:41Z
name: dispatchcache-shard
namespace: default
resourceVersion: "297308103"
selfLink: /api/v1/namespaces/default/services/dispatchcache-shard
uid: f55bd4d0-c6e3-11e8-9489-42010af00219
spec:
clusterIP: 10.171.255.152
ports:
- name: node-1
port: 7000
protocol: TCP
targetPort: 7000
- name: node-2
port: 7001
protocol: TCP
targetPort: 7000
- name: node-3
port: 7002
protocol: TCP
targetPort: 7000
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}

我希望我能找到实际为 redis 服务提供服务的 pod/部署/或实例。

最佳答案

您可以使用以下命令轻松找到提供此服务的 pod 的 IP:

kubectl get endpoints dispatchcache-shard

之后,您可以使用此命令通过 IP 地址找到实际的 pod:

kubectl get pod -o wide

我想补充一点,应该有非常充分的理由来定义没有标签选择器的服务。不确定这是你的情况。

关于kubernetes - 查找在 kubernetes 服务后面服务的 pod/VM 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55846767/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com