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