首页 文章

Kubernetes Metallb:Nginx pod没有使用本地流量策略,第2层模式接收流量

提问于
浏览
0

发生了什么:我将我的nginx服务的externalTrafficPolicy更改为Local,现在我的nginx pod不再接收流量

你期望发生什么:nginx pod将继续获得流量,但源ip完好无损 . 使用第2层模式

环境:

MetalLB版本:0.7.1 Kubernetes版本:最新操作系统(例如来自/ etc / os-release):centos7内核(例如uname -a):Linux K8SM1 3.10.0-862.3.2.el7.x86_64#1 SMP Mon 5月21日23:36:36 UTC 2018 x86_64 x86_64 x86_64 GNU / Linux

我有一个nginx pod,它在端口80上侦听UDP,并将UDP数据包重定向到192.168.122.206:8080我有一个简单的udp服务器,它监听192.168.122.206:8080 . 这工作正常,但我需要知道数据包的原始源IP和端口,所以我将服务的流量策略更改为本地 . 现在,pod似乎没有获得流量 . 我正在运行单节点裸机群集 . 我已经尝试过做“kubectl logs pod-name”,但没有任何显示,让我相信pod根本没有获得流量 . 我确保我的UDP数据包被发送到nginx服务和端口80的外部ip .

我构建图像的nginx.conf:

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
    worker_connections 1024;
}

stream {
server {
        listen 80 udp;
        proxy_pass 192.168.122.206:8080;
    }
}

我的nginx部署和服务

apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: asvilla/custom_nginx2:first
        ports:
        - name: http
          containerPort: 80

---
apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  externalTrafficPolicy: Local
  ports:
  - name: http
    port: 80
    protocol: UDP
    targetPort: 80
  selector:
    app: nginx
  type: LoadBalance

我已经将我的pod和容器日志的详细程度设置为9.当我发送数据包时,它们没有显示任何新内容 . 我还将“kubectl describe service nginx”的详细程度设置为9,并且在发送数据包时没有显示任何新内容 . 我最好的猜测是kube-proxy出了什么问题?此外,我的主人是我唯一的节点可能会影响某些事情,虽然当我设置它时我没有弄它并允许调度程序将其视为工作节点 .

1 回答

  • 0

    由于您已经指出 Service 通过UDP协议路由网络流量,我想这也应该允许Nginx Deployment ,添加 protocol: UDP 参数:

    apiVersion: apps/v1beta2
    kind: Deployment
    metadata:
      name: nginx
    spec:
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: asvilla/custom_nginx2:first
            ports:
            - name: http
              containerPort: 80
              protocol: UDP
    

相关问题