我们正在使用Istio 0.7和istio ingress控制器来处理外界的要求 . 我们使用“ClusterIP”类型服务的“externalIPs”属性来暴露kubernetes之外的入口控制器 .
Istio Ingress Controller 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
What you expected to happen:
我们想要原始客户端IP而不是外部IP中给出的IP即(192.168.X.X) .
Additional Information
我已在互联网上查看并发现使用“externalTrafficPolicy:Local”标志我们可以保留客户端IP,但此标志仅在NodePort类型服务中有效 . 我们不想使用NodePort服务,因为如果我们使用它,它将打开我们的入口控制器,用于私有和公共主机的所有接口 .
Kubernetes version
客户端版本:version.Info {Major:“1”,Minor:“10”,GitVersion:“v1.10.1”,GitCommit:“d4ab47518836c750f9949b9e0d387f20fb92260b”,GitTreeState:“clean”,BuildDate:“2018-04-12T14:26 :04Z“,GoVersion:”go1.9.3“,编译器:”gc“,平台:”linux / amd64“}服务器版本:version.Info {Major:”1“,Minor:”10“,GitVersion:”v1 . 10.3 coreos.0“,GitCommit:”f1b890dbbf11abe58280b3ffe17d67749f5ae70e“,GitTreeState:”clean“,BuildDate:”2018-05-21T17:27:17Z“,GoVersion:”go1.9.3“,编译:”gc“,平台:”linux / AMD64" }
OS (e.g. from /etc/os-release)
NAME =“CoreOS的容器Linux”ID = coreos VERSION = 1745.5.0 VERSION_ID = 1745.5.0 BUILD_ID = 2018-05-31-0701 PRETTY_NAME =“CoreOS 1745.5.0(流纹岩)的容器Linux”ANSI_COLOR =“38; 5; 75“HOME_URL =”https://coreos.com/“BUG_REPORT_URL =”https://issues.coreos.com“COREOS_BOARD =”amd64-usr“
Kernel (e.g. uname -a)
Linux node1.example.com 4.14.44-coreos-r1#1 SMP Thu May 31 06:04:02 UTC 2018 x86_64 Intel(R)Xeon(R)CPU L5640 @ 2.27GHz GenuineIntel GNU / Linux
有人可以帮助我们吗?
1 回答
基于this GitHub issue,似乎Istio足够聪明,可以在其上游请求中包含
X-Forwarded-For
标头,因此我希望目标Pod需要更新以查询该标头而不是$HTTP_REMOTE
或现在用于获取IP的任何机制 .