-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add support for named port, better docs for TLS nginx Ingress #766
Conversation
ping @bprashanth |
In case of services with namedPorts the Ingress controller add an annotation to the service
|
} | ||
svc.ObjectMeta.Annotations[namedPortAnnotation] = string(data) | ||
glog.Infof("updating service %v with new named port mappings", svc.Name) | ||
_, err := lbc.client.Services(svc.Namespace).Update(svc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if this update fails? (eg: resource version conflict). And if it passes, will we actuallly just come back in this function and relist pods again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requeue added in case of error during update
I'm ok with the pod list if we can restrict it to just when the user has the named targetport.Other stuff looks fine. |
ad9af5c
to
4a8a8a4
Compare
It seems something with this has broken generating a correct nginx.conf for me. My nginx.conf ends up with something like:
It's like it's not finding the ports for the
I'm double checking to make sure my local patched ok and to see if I can figure something out in the mean time but wanted to mention it in case the cause was something obvious. I don't see any errors in the log. |
Just an update - if I change the
|
@bprashanth any plan to integrate this pull request? |
Yeah I'll make another pass sometime today since it looks like Manual updated the commits after my last comment. |
for i := range svc.Spec.Ports { | ||
servicePort := &svc.Spec.Ports[i] | ||
|
||
_, err := strconv.Atoi(servicePort.TargetPort.StrVal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you bail early (before pod list) if none of these ports is a string?
If we can't selectively list only when there's a named port, I'd suggest setting up a pod watch, eg:
podStore.Store, podController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return e.client.Core().Pods(api.NamespaceAll).List(options)
},
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return e.client.Core().Pods(api.NamespaceAll).Watch(options)
},
},
&api.Pod{},
resyncPeriod(),
framework.ResourceEventHandlerFuncs{
AddFunc: addPod,
UpdateFunc: updatePod,
DeleteFunc: deletePod,
},
)
And then you have a local cache you can list for pods:
https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/replication/replication_controller.go#L542
51066e3
to
2f2cd62
Compare
@@ -541,9 +717,38 @@ func (lbc *loadBalancerController) createUpstreams(data []interface{}) map[strin | |||
} | |||
|
|||
for _, path := range rule.HTTP.Paths { | |||
name := fmt.Sprintf("%v-%v-%v", ing.GetNamespace(), path.Backend.ServiceName, path.Backend.ServicePort.IntValue()) | |||
name := fmt.Sprintf("%v-%v-%v", ing.GetNamespace(), path.Backend.ServiceName, path.Backend.ServicePort.String()) | |||
if _, ok := upstreams[name]; !ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we ditch the extra indent and continue when ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Sorry for the delay, my only reservation at this point is that checkSvcForUpdate is icky, I'd vastly prefer if it didn't update services. If you can either do as suggested or explain why we can't just handle this through the normal ingress sync routine, I'll be ok with it. |
@bprashanth testing doing the update in getEndpoints |
ping @bprashanth please review |
return val, ok | ||
} | ||
|
||
func (npm namedPortMapping) getMappings() map[string]string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a comment about what mappings, since the name is very general and it returns a map. Or rename the method.
So much better, thanks! |
@bprashanth done |
LGTM |
Just seen all of this new stuff today. Was trying to upgrade our old ingress (container version 0.2). When will a new container be build from this? It seems |
Thanks @bprashanth it is working now. |
Thank @simonswine and @aledbf, I just pushed the image :) |
Add support for named port, better docs for TLS nginx Ingress
fixes #743
fixes #781
fixes #858
fixes #871
closes #872
fixes #876