[英]Can I get response of curl through POD IP address (instead of host address) while using nginx ingress
I am using nginx ingress controller
below is the ingress rule file for 2 services:我正在使用nginx ingress controller
下面是 2 个服务的入口规则文件:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
namespace: kube-system
annotations:
kubernetes.io/ingress.class: nginx
kubernetes.io/ingress.allow-http: "false"
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
tls:
- hosts:
- rewrite.bar.com.com
secretName: ingress-tls
rules:
- host: rewrite.bar.com.com
- http:
paths:
- path: /my-service-1/(.*)
pathType: Prefix
backend:
service:
name: my-service-1
port:
number: 36995
- path: /my-service-2/(.*)
pathType: Prefix
backend:
service:
name: my-service-2
port:
number: 32243
Now using below command through shell of service-2 I can curl to the service-1 api endpoint, here I need to pass host ('wire.com') which is TLS enabled as well,现在通过 service-2 的 shell 使用以下命令我可以 curl 到 service-1 api 端点,这里我需要传递主机('wire.com')
curl --resolve wire.com:443:10.22.148.179 https://wire.com:32243/GetData
Above curl using host address give me response successfully, no issue here!以上 curl 使用主机地址给我回复成功,这里没有问题!
Now I am using IP address of the POD instead of host address, but this won't give me response, it's always give error like curl: (52) Empty reply from server
.现在我使用的是 POD 的 IP 地址而不是主机地址,但这不会给我响应,它总是给出像curl: (52) Empty reply from server
之类的错误。 Here 10.22.148.179
is my ingress public IP address and 10.2.0.58
is my POD IP address.这里10.22.148.179
是我的入口公共 IP 地址, 10.2.0.58
是我的 POD IP 地址。
curl --resolve enabledservices-dev-aks.honeywell.com:443:10.22.148.179 http//10.2.0.58:32243/GetData
My goal to hit the POD/service api end point through IP address, is this possible with context of Ingress integrated?我的目标是通过 IP 地址到达 POD/服务 api 端点,这可能与 Ingress 集成的上下文有关吗?
Moving this from comments to answer.将此从评论转移到答案。
The issue was curl request and HTTP protocol used while the server is serving by HTTPS.问题是在服务器由 HTTPS 提供服务时使用了 curl 请求和 HTTP 协议。 This is the reason of (52) Empty reply from server
error.这是(52) Empty reply from server
error 的原因。
Request by curl should be done by specifying the protocol like: curl 的请求应通过指定如下协议来完成:
curl https://test.example.com:8888
Ingress
is used as a single entry point to the cluster so all inside services can be exposed internally in the cluster using cluster-ip
service type - see kubernetes service types . Ingress
用作集群的单个入口点,因此可以使用cluster-ip
服务类型在集群内部公开所有内部服务 - 请参阅kubernetes 服务类型。
If any inside service/pod is required to be tested from inside the cluster, request should be executed from the cluster to be able to hit a cluster-ip
since cluster-ip
is only accessible within the cluster.如果需要从集群内部测试任何内部服务/pod,则应从集群执行请求以便能够命中cluster-ip
,因为cluster-ip
只能在集群内访问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.