Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CNI_ARGS in static IPAM plugin #165

Merged
merged 8 commits into from
Sep 25, 2018

Conversation

s1061123
Copy link
Contributor

This change is to add CNI_ARGS support in static IPAM plugin.
When IP/SUBNET/GATEWAY are given in CNI_ARGS, static IPAM adds
these info in addition to config files.

To configure ip address only from CNI_ARGS, 'address' field in config
is changed to optional from required.

This change is to add CNI_ARGS support in static IPAM plugin.
When IP/SUBNET/GATEWAY are given in CNI_ARGS, static IPAM adds
these info in addition to config files.

To configure ip address only from CNI_ARGS, 'address' field in config
is changed to optional from required.
* `address` (string, required): CIDR notation IP address.
* `gateway` (string, optional): IP inside of "subnet" to designate as the gateway.
* `routes` (string, optional): list of routes add to the container namespace. Each route is a dictionary with "dst" and optional "gw" fields. If "gw" is omitted, value of "gateway" will be used.
* `dns` (string, optional): the dictionary with "nameservers", "domain" and "search".

## Supported arguments
The following [CNI_ARGS](https://github.com/containernetworking/cni/blob/master/SPEC.md#parameters) are supported:
Copy link
Member

Choose a reason for hiding this comment

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

Missing new line before this one. Please keep that in sync with rest of document.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

## Supported arguments
The following [CNI_ARGS](https://github.com/containernetworking/cni/blob/master/SPEC.md#parameters) are supported:

* `IP`: request a specific IP address from a subnet
Copy link
Member

Choose a reason for hiding this comment

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

Please remove from a subnet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@@ -38,8 +38,17 @@ static IPAM is very simple IPAM plugin that assigns IPv4 and IPv6 addresses stat
## Network configuration reference

* `type` (string, required): "static"
* `addresses` (array, required): an array of arrays of ip address objects:
* `addresses` (array, optional): an array of arrays of ip address objects:
Copy link
Member

Choose a reason for hiding this comment

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

That's incorrect even in master - it's an array of ip addresses, not an array of arrays.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@squeed
Copy link
Member

squeed commented Jul 25, 2018

Seems fine, except it adds a new runtime convention. others might care about this.

@s1061123
Copy link
Contributor Author

@squeed thank you for your comments. Let me clarify that your comment indicate to remove runtime convention, correct? I will remove runtime and update PR.

@s1061123
Copy link
Contributor Author

@squeed I've taken care of your comments. Could you please take a look into it?

@dcbw
Copy link
Member

dcbw commented Aug 29, 2018

@s1061123 thanks for the update, discussed this one during maintainer's meeting. Instead of having two variables for IP and SUBNET, could we instead combine them into just IP that would have a CIDR format eg "1.2.3.4/24"? You can give that to net.ParseCIDR() and you'll get both the IP address itself and the subnet mask out.

@s1061123
Copy link
Contributor Author

s1061123 commented Sep 3, 2018

@dcbw , OK, I got it. I just align with host-local and there is no additional meaning. So let me change it and update it again.

@s1061123 s1061123 changed the title Support CNI_ARGS in static IPAM plugin [WIP]Support CNI_ARGS in static IPAM plugin Sep 5, 2018
@s1061123
Copy link
Contributor Author

s1061123 commented Sep 5, 2018

@dcbw and other CNI committer, I need to modify a bit to support multiple ip address ("10.2.2.42/24" and "2001:db8::5/64"), hence I add "[WIP]".

Once finished. I will remove it.

@s1061123 s1061123 changed the title [WIP]Support CNI_ARGS in static IPAM plugin Support CNI_ARGS in static IPAM plugin Sep 6, 2018
@s1061123
Copy link
Contributor Author

s1061123 commented Sep 6, 2018

@dcbw , I updated the PR.

plugins/ipam/static/main.go Outdated Show resolved Hide resolved

for i := range n.IPAM.Addresses {
if n.IPAM.Addresses[i].Address.Contains(gwip) {
n.IPAM.Addresses[i].Gateway = gwip
Copy link
Member

Choose a reason for hiding this comment

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

I would parse GATEWAY before IP, and hten assign the gateways to each Address while parsing the IPs. We should also make sure that the GATEWAY array is the same length as the IP array.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In some case, there is no gateway corresponding to certain IP address, especially multiple interface case. So I'd like to parse IP first then match gateway if there exists. Is that okey to you?

Copy link
Member

Choose a reason for hiding this comment

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

@s1061123 yeah, you're right.

@dcbw dcbw merged commit 646dbba into containernetworking:master Sep 25, 2018
@s1061123 s1061123 deleted the dev/static-args branch November 28, 2018 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants