Skip to content

Commit

Permalink
Add usesNAT flag to control nonMasqueradeCIDR check for custom CNI ne…
Browse files Browse the repository at this point in the history
…tworking
  • Loading branch information
adammw committed May 7, 2019
1 parent a8a1f7e commit 1251f77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/apis/kops/networking.go
Expand Up @@ -52,6 +52,7 @@ type ExternalNetworkingSpec struct {
// but this is useful for arbitrary network modes or for modes that don't need additional configuration.
type CNINetworkingSpec struct {
UsesSecondaryIP bool `json:"usesSecondaryIP,omitempty"`
UsesNAT bool `json:"usesNAT,omitempty"`
}

// KopeioNetworkingSpec declares that we want Kopeio networking
Expand Down
6 changes: 5 additions & 1 deletion pkg/apis/kops/validation/legacy.go
Expand Up @@ -196,7 +196,11 @@ func ValidateCluster(c *kops.Cluster, strict bool) *field.Error {
return field.Invalid(fieldSpec.Child("NonMasqueradeCIDR"), nonMasqueradeCIDRString, "Cluster had an invalid NonMasqueradeCIDR")
}

if networkCIDR != nil && subnet.Overlap(nonMasqueradeCIDR, networkCIDR) && c.Spec.Networking != nil && c.Spec.Networking.AmazonVPC == nil && c.Spec.Networking.LyftVPC == nil {
if networkCIDR != nil && subnet.Overlap(nonMasqueradeCIDR, networkCIDR) &&
c.Spec.Networking != nil &&
(c.Spec.Networking.CNI == nil || c.Spec.Networking.CNI.UsesNAT) &&
c.Spec.Networking.AmazonVPC == nil &&
c.Spec.Networking.LyftVPC == nil {

return field.Invalid(fieldSpec.Child("NonMasqueradeCIDR"), nonMasqueradeCIDRString, fmt.Sprintf("NonMasqueradeCIDR %q cannot overlap with NetworkCIDR %q", nonMasqueradeCIDRString, c.Spec.NetworkCIDR))
}
Expand Down

0 comments on commit 1251f77

Please sign in to comment.