我们使用Istio0.7和Istio入口控制器来处理外部世界的要求。我们使用"ClusterIP“类型服务的”外部We“属性来公开kubernetes之外的入口控制器。
Istio侵入控制器Yaml:
apiVersion: v1
kind: Service
metadata:
name: istio-ingress-3
namespace: istio-system
labels:
istio: ingress
spec:
ports:
- port: 80
name: http
- port: 443
name: https
externalIPs:
- 192.168.X.X
selector:
istio: ingress-3
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: istio-ingress-3
namespace: istio-system
spec:
replicas: 1
template:
metadata:
labels:
istio: ingress-3
annotations:
sidecar.istio.io/inject: "false"
spec:
nodeSelector:
kubernetes.io/hostname: node3.example.com
serviceAccountName: istio-ingress-service-account
containers:
- name: istio-ingress
image: docker.io/istio/proxy:0.7.1
args:
- proxy
- ingress
- --discoveryAddress
- istio-pilot:8080 #--controlPlaneAuthPolicy
- --discoveryRefreshDelay
- '1s' #discoveryRefreshDelay
- --drainDuration
- '45s' #drainDuration
- --parentShutdownDuration
- '1m0s' #parentShutdownDuration
- --connectTimeout
- '10s' #connectTimeout
- --serviceCluster
- istio-ingress
- --zipkinAddress
- zipkin:9411
- --statsdUdpAddress
- istio-mixer:9125
- --proxyAdminPort
- "15000"
- --controlPlaneAuthPolicy
- NONE #--controlPlaneAuthPolicy
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
- containerPort: 443
env:
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
volumeMounts:
- name: istio-certs
mountPath: /etc/certs
readOnly: true
- name: ingress-certs
mountPath: /etc/istio/ingress-certs
readOnly: true
volumes:
- name: istio-certs
secret:
secretName: istio.istio-ingress-service-account
optional: true
- name: ingress-certs
secret:
secretName: istio-ingress-certs
optional: true问题是每次我们在触发请求后检查入口控制器的日志时,它都会给出与外部ip (主机ip)中相同的ip。但是我们需要客户端原始信息,比如客户端原始IP。
您预期会发生的事情:
我们想要的是原始客户端IP,而不是externalIP ie (192.168.X.X)中给出的IP。
附加信息
我在互联网上检查了一下,发现使用"externalTrafficPolicy: Local“标志我们可以保留客户端ip,但是这个标志只在NodePort类型的服务中有效。而且我们不想使用NodePort服务,因为如果我们使用它,它将为主机的所有接口打开入口控制器,这个接口是私有的,也是公共的。
Kubernetes版本
客户端版本: GitCommit:"d4ab47518836c750f9949b9e0d387f20fb92260b",{主:“1”,小调:“10”,GitVersion:"v1.10.1",version.Info GitTreeState:“干净”,BuildDate:"2018-04-12T14:26:04Z",GoVersion:"go1.9.3",编译器:“gc”,平台:“linux/amd64 64”}服务器版本:version.Info{主:“1”,次要:“10”,GitVersion:"v1.10.3+coreos.0",GitCommit:"f1b890dbbf11abe58280b3ffe17d67749f5ae70e",GitTreeState:“干净”,BuildDate:"2018-05-21T17:27:17Z",GoVersion:"go1.9.3",编译器:“gc”,平台:“linux/amd64 64”}
OS (例如来自/etc/os发行版)
NAME="Container by CoreOS“ID=coreos VERSION=1745.5.0 VERSION_ID=1745.5.0 BUILD_ID=2018-05-31-0701 PRETTY_NAME=
内核(例如,命名为-a)
node1.example.com 4.14.44-coreos-r1 #1 SMP清华5月31日06:04:02 UTC x86_64 Intel(R) Xeon(R) CPU L5640 @ 2.27GHz GenuineIntel GNU/Linux
有人能帮我们吗?
发布于 2018-06-13 05:38:20
基于这个GitHub问题,看起来Istio很聪明,可以在其上游请求中包含X-Forwarded-For报头,因此我希望目标Pod需要更新以参考该报头,而不是$HTTP_REMOTE或它现在用于获取IP的任何机制。
https://stackoverflow.com/questions/50816090
复制相似问题