Skip to content

ipvs not update correctly when service update #716

@chinglinwen

Description

@chinglinwen

Step to reproduce

  1. create service with port 80 and wrong targetPort 8001
  2. apply
  3. change targetPort to 8000 ( correct port )
  4. apply
  5. see if service is ok ( service is not ok )

// there maybe other combination to concern too
not provide targetPort, update service port what will happen
provide both port and targetPort, update one of them, what will happen

kubectl apply -f fstest.yaml

[wen@234 k8snew ~]$ kubectl get svc -n t
NAME   TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
fs     ClusterIP   10.110.95.160   <none>        80/TCP    5s
[wen@234 k8snew ~]$ 
[wen@234 k8snew ~]$ kubectl get ep -n t
NAME   ENDPOINTS         AGE
fs     10.11.3.17:8001   48s
[wen@234 k8snew ~]$ 8pods fs
t                fs-699cc6b596-ngxjw                           1/1     Running   0          53s     10.11.3.17      172.31.81.111   <none>           <none>
[wen@234 k8snew ~]$ 

[root@online-node-81-111 ~]# ipvsadm -Ln |grep -A 3 10.110.95.160
TCP  10.110.95.160:80 rr persistent 10800
  -> 10.11.3.17:8001              Masq    1      0          0         
UDP  10.96.0.10:53 rr
  -> 10.11.0.193:53               Masq    1      0          237       
[root@online-node-81-111 ~]# curl 10.110.95.160
curl: (7) Failed connect to 10.110.95.160:80; Connection refused

// should have one entry below

[root@online-node-81-111 ~]# ipvsadm -Ln |grep -A 3 10.110.95.160
TCP  10.110.95.160:80 rr persistent 10800
  -> 10.11.3.17:8000              Masq    1      0          0         
  -> 10.11.3.17:8001              Masq    1      0          0         
UDP  10.96.0.10:53 rr
[root@online-node-81-111 ~]# curl 10.110.95.160
curl: (7) Failed connect to 10.110.95.160:80; Connection refused  // this should be ok
[root@online-node-81-111 ~]# curl 10.11.3.17:8000
<pre>
</pre>
[root@online-node-81-111 ~]# curl 10.11.3.17:8001
curl: (7) Failed connect to 10.11.3.17:8001; Connection refused
[root@online-node-81-111 ~]#
apiVersion: v1
kind: Namespace
metadata:
  name: t
---
# Service
apiVersion: v1
kind: Service
metadata:
  name: fs
  namespace: t
spec:
  ports:
  - name: web
    targetPort: 8001
    port: 80
  selector:
    app: fs
  sessionAffinity: ClientIP

# Deployment
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: fs
  namespace: t
  labels:
    app: fs
spec:
  replicas: 1
  selector:
    matchLabels:
      app: fs
  template:
    metadata:
      labels:
        app: fs
    spec:
      nodeSelector:
        func: "monitor"
      containers:
        - name: fs
          image: chinglinwen/fs
          ports:
          - containerPort: 8000

version

Running /usr/local/bin/kube-router version v0.2.5, built on 2019-02-01T04:01:01+0000, go1.10.8
CentOS Linux release 7.4.1708 (Core)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions