Skip to content

Commit

Permalink
Merge pull request #20258 from danwinship/auto-egress-ip-master
Browse files Browse the repository at this point in the history
Auto-assign egress IPs from EgressCIDRs
  • Loading branch information
openshift-merge-robot authored Jul 20, 2018
2 parents 410706e + e029a84 commit dfe0224
Show file tree
Hide file tree
Showing 40 changed files with 1,376 additions and 541 deletions.
4 changes: 3 additions & 1 deletion api/docs/apis-network.openshift.io/v1.HostSubnet.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ Expand or mouse-over a field for more information about it.
++++
<pre>
<div style="margin-left:13px;"><span title="(string) APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources">apiVersion</span>:
</div><details><summary><span title="(array) EgressIPs is the list of automatic egress IP addresses currently hosted by this node">egressIPs</span>:
</div><details><summary><span title="(array) EgressCIDRs is the list of CIDR ranges available for automatically assigning egress IPs to this node from. If this field is set then EgressIPs should be treated as read-only.">egressCIDRs</span>:
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
</div></details><details><summary><span title="(array) EgressIPs is the list of automatic egress IP addresses currently hosted by this node. If EgressCIDRs is empty, this can be set by hand; if EgressCIDRs is set then the master will overwrite the value here with its own allocation of egress IPs.">egressIPs</span>:
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
</div></details><div style="margin-left:13px;"><span title="(string) Host is the name of the node. (This is the same as the object&#39;s name, but both fields must be set.)">host</span>:
</div><div style="margin-left:13px;"><span title="(string) HostIP is the IP address to be used as a VTEP by other nodes in the overlay network">hostIP</span>:
Expand Down
4 changes: 3 additions & 1 deletion api/docs/oapi/v1.HostSubnet.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ Expand or mouse-over a field for more information about it.
++++
<pre>
<div style="margin-left:13px;"><span title="(string) APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources">apiVersion</span>:
</div><details><summary><span title="(array) EgressIPs is the list of automatic egress IP addresses currently hosted by this node">egressIPs</span>:
</div><details><summary><span title="(array) EgressCIDRs is the list of CIDR ranges available for automatically assigning egress IPs to this node from. If this field is set then EgressIPs should be treated as read-only.">egressCIDRs</span>:
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
</div></details><details><summary><span title="(array) EgressIPs is the list of automatic egress IP addresses currently hosted by this node. If EgressCIDRs is empty, this can be set by hand; if EgressCIDRs is set then the master will overwrite the value here with its own allocation of egress IPs.">egressIPs</span>:
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
</div></details><div style="margin-left:13px;"><span title="(string) Host is the name of the node. (This is the same as the object&#39;s name, but both fields must be set.)">host</span>:
</div><div style="margin-left:13px;"><span title="(string) HostIP is the IP address to be used as a VTEP by other nodes in the overlay network">hostIP</span>:
Expand Down
10 changes: 9 additions & 1 deletion api/protobuf-spec/github_com_openshift_api_network_v1.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion api/swagger-spec/oapi-v1.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion api/swagger-spec/openshift-openapi-spec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pkg/network/apis/network/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ type HostSubnet struct {
HostIP string
Subnet string

EgressIPs []string
EgressIPs []string
EgressCIDRs []string
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
2 changes: 2 additions & 0 deletions pkg/network/apis/network/v1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/network/apis/network/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ func ValidateHostSubnet(hs *networkapi.HostSubnet) field.ErrorList {
}
}

for i, egressCIDR := range hs.EgressCIDRs {
if _, err := validateCIDRv4(egressCIDR); err != nil {
allErrs = append(allErrs, field.Invalid(field.NewPath("egressCIDRs").Index(i), egressCIDR, err.Error()))
}
}

return allErrs
}

Expand Down
33 changes: 33 additions & 0 deletions pkg/network/apis/network/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,39 @@ func TestValidateHostSubnet(t *testing.T) {
},
expectedErrors: 2,
},
{
name: "Good one with EgressCIDRs",
hs: &networkapi.HostSubnet{
ObjectMeta: metav1.ObjectMeta{
Name: "abc.def.com",
},
Host: "abc.def.com",
HostIP: "10.20.30.40",
Subnet: "8.8.8.0/24",
EgressCIDRs: []string{
"192.168.1.99/32",
"192.168.2.0/24",
},
},
expectedErrors: 0,
},
{
name: "Malformed EgressCIDRs",
hs: &networkapi.HostSubnet{
ObjectMeta: metav1.ObjectMeta{
Name: "abc.def.com",
},
Host: "abc.def.com",
HostIP: "10.20.30.40",
Subnet: "8.8.8.0/24",
EgressCIDRs: []string{
"192.168.1.99",
"bob/32",
"1234::5678/64",
},
},
expectedErrors: 3,
},
{
name: "IPv6 subnet",
hs: &networkapi.HostSubnet{
Expand Down
5 changes: 5 additions & 0 deletions pkg/network/apis/network/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dfe0224

Please sign in to comment.