从GCP上的实例访问Kubernetes Pods

问题描述 投票:0回答:2

鉴于:

  • VPN实例。此实例在内部IP 10.6.240.3上运行
  • 在Kubernetes POD上运行内部IP 10.6.240.4

问:为什么无法从VPN实例ping / curl /访问POD ip?

我需要实现的是通过VPN隧道从本地网络内部连接到POD ip。

我究竟做错了什么?

编辑:同样适用于NodePorts:enter image description here

@vpn-gateway:~$ curl -vvv 10.7.244.149:666
* Rebuilt URL to: 10.7.244.149:666/
*   Trying 10.7.244.149...
* TCP_NODELAY set

VPN网关无法访问NodePort

EDIT2:服务配置:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: scs-ui
  name: scs-ui
spec:
  clusterIP: None
  ports:
  - name: application
    port: 666
  selector:
    app: scs-ui
kubernetes google-cloud-platform vpn
2个回答
1
投票

刚刚找到解决方案:

在VPN / Kubernetes的地址范围内创建LB.这样,请求通过VPN从我的本地mashine路由到服务。

apiVersion: v1
kind: Service
metadata:
  name: elassandra-ingress
  annotations:
    cloud.google.com/load-balancer-type: "Internal"
  labels:
    app: elassandra-ingress
spec:
  type: LoadBalancer
  loadBalancerIP: 10.164.0.100
  ports:
  - port: 9042
    protocol: TCP
  selector:
    app: elassandra

0
投票

如果您没有使用Nodeport,Load balancer和clusterIp等任何服务将您的pod暴露到互联网,那么无论如何都无法在kubernetes集群外部访问您的pod。

问:为什么无法从VPN实例ping / curl /访问POD ip?

Answer : without exposing pod outside the world you can not ping pod you can do it in kubernetes cluster network or inside cluster only your pod can be resolved, ping possible

要从本地网络访问您的pod,只需使用负载均衡器公开pod的端口。 Nodeport和loadbalancer与k8s服务一起使用。

使用服务公开pod,你可以ping并做所有事情。

© www.soinside.com 2019 - 2024. All rights reserved.