问题描述
我在Kubernetes中将服务公开为NodePort,并将会话亲和性应用于该服务。当客户端第一次连接到服务时,会话亲缘关系开始起作用并维护客户端的会话,但是在超时之后,当客户端再次使用服务再次连接时,会话亲和关系就不会起作用,这会导致不当行为。我正在使用minikube在AWS ec2实例上配置集群。 k8s版本是Major:“ 1”,Minor:“ 18”。实际上,我已经在节点端口上公开了服务web-svc,客户端通过AWS公共IP(例如AWS-instance-ip:NodePort)连接到该服务。客户端首先连接到UDP端口上,发送单个数据包进行授权,一旦被授权的Pod说POD-A插入一些iptables规则以允许特定的客户端,在授权客户端立即与服务建立TCP连接后,问题是此请求被发送到另一个播客说POD-B,因为我的copy == 3,而在POD-B上,iptables规则不适用于特定客户端。
当我完全删除kubectl delete -f my-deployment.yaml
之类的Deployment and Service并通过kubectl apply -f my-deployment.yaml
再次创建它时,我得到了预期的行为,UDP和TCP连接都将到达同一容器,但是在sessionAffinity提到超时时,客户端再次连接UDP和TCP连接不会进入同一吊舱。
Kube代理模式为IPVS
服务摘要:
apiVersion: v1
kind: Service
metadata:
name: web-svc
spec:
type: NodePort
selector:
app: web-app
externalTrafficPolicy: Local
sessionAffinity: "ClientIP"
sessionAffinityConfig:
clientIP:
timeoutSeconds: 240
ports:
- port: 30573
nodePort: 30573
name: tcp-30573
protocol: TCP
- port: 30375
nodePort: 30375
name: udp-30375
protocol: UDP
kube-proxy日志:
sudo kubectl logs kube-proxy-njwxl -n kube-system I0820 10:22:03.591026 1 node.go:136] Successfully retrieved node IP: 172.31.27.53 I0820 10:22:03.591320 1 server_others.go:259] Using ipvs Proxier. W0820 10:22:03.591341 1 server_others.go:436] detect-local-mode set to ClusterCIDR,but no cluster CIDR defined I0820 10:22:03.591346 1 server_others.go:447] detect-local-mode: ClusterCIDR,defaulting to no-op detect-local W0820 10:22:03.591667 1 proxier.go:429] IPVS scheduler not specified,use rr by default I0820 10:22:03.591989 1 server.go:583] Version: v1.18.3 I0820 10:22:03.592440 1 conntrack.go:52] Setting nf_conntrack_max to 131072 I0820 10:22:03.596529 1 config.go:133] Starting endpoints config controller I0820 10:22:03.596556 1 shared_informer.go:223] Waiting for caches to sync for endpoints config I0820 10:22:03.600578 1 config.go:315] Starting service config controller I0820 10:22:03.600600 1 shared_informer.go:223] Waiting for caches to sync for service config I0820 10:22:03.697978 1 shared_informer.go:230] Caches are synced for endpoints config I0820 10:22:03.700844 1 shared_informer.go:230] Caches are synced for service config
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)