简体   繁体   English

从外部Pod到集群内部访问kubernetics服务

[英]Accessing kubernetics service from outside pod but within the cluster

Am running several services on same port within my kubernetes cluster; 我在kubernetes集群中的同一端口上运行多个服务; so its like ser1, ser2, ser3 all using same port 8080. I can access these services from inside a pod as <serv-name>:8080 but can I also access them in same way from one of the host nodes ie outside a container but from one of the cluster nodes ? 所以它像ser1,ser2,ser3都使用相同的端口8080。我可以从Pod内部以<serv-name>:8080访问这些服务,但是我也可以从主机节点之一(即容器外部)以相同的方式访问它们但是从群集节点之一?

I tried looking around but did not find any relevant discussion on this. 我尝试环顾四周,但未找到任何相关讨论。 Pls if someone may suggest. 请有人建议。

my sample config 我的样本配置

apiVersion: v1
kind: Service
metadata:
  name: svc1
  namespace: sample
  labels:
    app: svc1
spec:
  selector:
    app: app1
  ports:
  - name: psvc1
    port: 8080
    targetPort: 9090
    protocol: TCP

as Dries said, using cluster IP we can access the service from node. 正如Dries所说,使用群集IP,我们可以从节点访问服务。

kubectl run nginx --image=nginx --port=80 --expose=true

kubectl  get svc
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1        <none>        443/TCP   9d
nginx        ClusterIP   10.103.206.246   <none>        80/TCP    52m


# curl 10.103.206.246:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>

暂无
暂无

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

相关问题 无论如何从 kubernetics 集群重新加载已删除的 pod - Anyway to reload the deleted pods from kubernetics cluster 从 pod 到 Kubernetes 集群外的服务时,源 IP(记录在服务端,集群外)? - Source IP(recorded at service end, outside cluster) when talking from pod to a service outside Kubernetes cluster? 如何从 kube 集群外部调用服务中的特定 pod - How can I call a specific pod, in a service, from outside the kube cluster kubernetes:服务端点可从群集内而不是外部获得 - kubernetes: Service endpoints available from within cluster, not outside 从集群外部,无法访问 MyApp(客户端 --&gt;<nodeip> :<nodeport> --&gt; 服务 --&gt; Pod --&gt; MyApp)</nodeport></nodeip> - From outside the cluster, unable to reach MyApp (client --> <nodeIP>:<nodePort> --> Service --> Pod --> MyApp) 从本地开发 kubernetes 集群中的 pod 内连接到 docker compose 服务的最佳便携方式 - Best portable way to connect from within a pod in a local dev kubernetes cluster to docker compose service Helm、Kube.netes、如何配置Pod访问集群外的服务? - Helm, Kubernetes, how to configure Pod to access a service outside the cluster? 从 pod 内访问副本集信息 - Accessing replica set information from within the pod 无法从Pod内以cidr 10.0.x.0 / 24与网络中的计算机(k8s群集外部)通信 - Unable to communicate to a machine in the network(outside of the k8s cluster) with cidr 10.0.x.0/24 from within the pod 我的集群中的 pod 可以获取服务中的 pod 列表吗? - Can a pod within my cluster get a list of pods in a service?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM