Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

[nginx-ingress-controller] Add cidr whitelist support #1144

Merged
merged 2 commits into from
Jun 14, 2016

Conversation

aledbf
Copy link
Contributor

@aledbf aledbf commented Jun 6, 2016

fixes #1141

@aledbf aledbf force-pushed the ip-whitelisting branch from 34c774f to 76e4ee7 Compare June 9, 2016 22:00
@aledbf aledbf changed the title WIP: [nginx-ingress-controller] Add cidr whitelist support [nginx-ingress-controller] Add cidr whitelist support Jun 9, 2016
@aledbf
Copy link
Contributor Author

aledbf commented Jun 9, 2016

ping @bprashanth

return nil, ErrMissingWhitelist
}

ipnet, err := sets.ParseIPNets(val)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this handle a command seperated list of cidrs? if not suggest making it like a similar annotation we already have for service.type=lb: https://github.com/kubernetes/kubernetes.github.io/pull/632/files. In fact can we call the same: https://github.com/kubernetes/kubernetes/blob/dae5ac482861382e18b1e7b2943b1b7f333c6a2a/pkg/api/service/annotations.go

Copy link
Contributor Author

@aledbf aledbf Jun 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes https://github.com/kubernetes/kubernetes/blob/master/pkg/util/net/sets/ipnet.go#L26

EDIT: thanks for the question about the list. Fixed and test added

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you include that as a comment/in the doc somewhere and change the name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the name?

which name?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the annotation, to match what we already have in the l4 loadbalancer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's deprecated because it's turning into a field with the same name kubernetes/website#632

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@aledbf aledbf force-pushed the ip-whitelisting branch 2 times, most recently from 5beb58d to c6d2f23 Compare June 11, 2016 03:32
@sander-su
Copy link

@aledbf would you also put in aliasing via configmap like I mentioned in the issue?
So a configmap (controller wide) properties would be
whilelist.alias.corporate: 52.0.0.0/16, 190.36.45.160/23
whitelist.alias.internal: 10.0.0.0/16

And than an additional annotation on the ingres would reference these like
Annotation.whitelist.aliases: corporate, internal

These would then be added to the cidr whitelisting per ingres option.

Otherwise if our corporate outbound ip changes I have to adjust all ingress configs and with aliases only one configmap property.

If this is already on planning nothing said but did not see it in the commits and thus not completely fixes the issue.

@aledbf
Copy link
Contributor Author

aledbf commented Jun 13, 2016

@sander-su already included https://github.com/kubernetes/contrib/pull/1144/files#diff-3a0f10ad1be4fb0972021177f2cb9e9aR236
But the behavior is to replace the global value, not append

@sander-su
Copy link

sander-su commented Jun 13, 2016

@aledbf
Ok, so just to check.
When putting something in the configmap it will be used for the whole ingresscontroller and ingres on it?

Then to validate something else, could be my misunderstanding. An ingress controller handeles ingresess from all namespaces, right? (seen this behaviour in 0.61) An ingres can only forward incomming traffic to the services of the ns it belongs to, although the controller could be in another ns.
How can I limit access to certain services and not to other? Cannot make 2 controllers because every ingress is deployed on both.

Furthermore, we need to specify which alias for which ingres.
As we use aws some devs ops use clientvpn/stepstone and thus have internal vpc ip. Site to site vpn to our corporate network is not desired. I want to whitelist some services to corporate use only. So devs would use monitoring, no kubernetes authz because only dev, so no proxy. Also project external hire.
Corporate is needed for extra security and easy access when distributing accounts is difficult.
Hence I need the differiantation between public, internal, corporate.

What are your thoughts?

@aledbf
Copy link
Contributor Author

aledbf commented Jun 13, 2016

When putting something in the configmap it will be used for the whole ingresscontroller and ingres on it?

Yes

An ingress controller handeles ingresess from all namespaces, right?

This is the default. You can specify one namespace to restrict where the controller should look for Ingress rules.

@aledbf
Copy link
Contributor Author

aledbf commented Jun 13, 2016

Hence I need the differiantation between public, internal, corporate.

Currently there's no way to express this with Ingress. I think you can have one controller for each environment, but even with that you need different ingress rules

@sander-su
Copy link

If I can restrict an ingress controller to a namespace for rules this would be suficient.
Devops monitoring/jenkins could be in kube-system and corporate only would get its own ns.

Which setting restrict the controller to one (or multiple?) ns for its rules. Cannot find it easily.

Think it would be good to name this in the documentation.

@sander-su
Copy link

And thanks for resolving the issue this quick ;)

@aledbf
Copy link
Contributor Author

aledbf commented Jun 13, 2016

Which setting restrict the controller to one (or multiple?) ns for its rules. Cannot find it easily.

It's an argument
--watch-namespace="": Namespace to watch for Ingress. Default is to watch all namespaces

Just in case only is possible to watch all the namespaces or one (no multiple)

Think it would be good to name this in the documentation.

Good point. I will add a section for this in #1130.

@sander-su
Copy link

sander-su commented Jun 13, 2016

One more, regarding the discussion on the issue. (And one for the docs)
So for now only sourceip filtering is added? (For me for now sufficient but cant speak for anyone else)
No filtering by x-header?

@aledbf
Copy link
Contributor Author

aledbf commented Jun 13, 2016

So for now only sourceip filtering is added?

Yes.

Please open an issue with your use case to use a different source

@sander-su
Copy link

sander-su commented Jun 13, 2016

Not needed.
but good to mention in the docs that if you are using aws/elb it must be combined with proxy protocol for it to work.

@sander-su
Copy link

sander-su commented Jun 13, 2016

Load-balancer-source-ranges is a bit misleading though. I would interpreted it as i need to specify the range of my load balancer here. But I whitelist the ip of the traffic comming into the loadbalancer by using proxy protocol.
Whitelist-source-range would be more clear i think.

@bprashanth
Copy link

I would interpreted it as i need to specify the range of my load balancer here

I would interpret it as I need to specify the source range of my loadbalancer here. I don't particularly have a strong preference about including/leaving out the whitelist prefix. If it makes things that much clearer to a majority of users, we can do it. It might lead to confusion because people don't get how it ties in with loadbalancer-source-ranges upstream, but we can fix that with documentation hopefully.

@aledbf aledbf force-pushed the ip-whitelisting branch from c6d2f23 to 64f4cfe Compare June 13, 2016 18:21
@bprashanth
Copy link

LGTM thanks

@bprashanth bprashanth merged commit 6c87fed into kubernetes-retired:master Jun 14, 2016
@aledbf aledbf deleted the ip-whitelisting branch June 16, 2016 15:08
aledbf pushed a commit to aledbf/contrib that referenced this pull request Nov 10, 2016
[nginx-ingress-controller] Add cidr whitelist support
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ingress/controllers/nginx] ip whitelisting
5 participants