aledbf / kube-keepalived-vip

Kubernetes Virtual IP address/es using keepalived
Apache License 2.0
188 stars 75 forks source link

[issue-may-be] port or targetPort #99

Closed panpan0000 closed 5 years ago

panpan0000 commented 5 years ago

in pkg/controller/main.go func: getServices

since the real_server in /etc/keepalived/keepalived.conf is POD IP, instead of cluster IP, so we should use Spec.TargetPorts instead of Spec.Ports ? since TargetPort is the container's port, and Port is the cluster IP port.(https://kubernetes.io/docs/concepts/services-networking/service/)

for _, servicePort := range s.Spec.Ports {

}
aledbf commented 5 years ago

Closing. No, the definition in the configmap is about ports, no targetPorts. We lookup targetPorts in the getEndpoints function

panpan0000 commented 5 years ago

oh, sorry for that. My bad

panpan0000 commented 5 years ago

Hmm... @aledbf , sorry I think I should point to this one:

svcs = append(svcs, vip{
    Name:     ...
    IP:        ...
    Port:      int(servicePort.Port),  // --> here, should it be servicePort.TargetPort ?
    LVSMethod: ...,
    Backends:  ..,
    Protocol:  ...,
})

https://github.com/aledbf/kube-keepalived-vip/blob/master/pkg/controller/main.go#L238