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

k8s conversion code handles 1.7 clusters #531

Merged
merged 1 commit into from
Sep 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/backend/k8s/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,23 @@ func (c Converter) NetworkPolicyToPolicy(np *extensions.NetworkPolicy) (*model.K
types := []string{}
if ingress {
types = append(types, "ingress")
} else if len(inboundRules) > 0 {
log.Warn("K8s PolicyTypes don't include 'ingress', but NetworkPolicy has ingress rules.")
}
if egress {
types = append(types, "egress")
} else if len(outboundRules) > 0 {
// Egress was introduced at the same time as policyTypes. It shouldn't be possible to
// receive a NetworkPolicy with an egress rule but without "egress" specified in its types,
// but we'll warn about it anyway.
log.Warn("K8s PolicyTypes don't include 'egress', but NetworkPolicy has egress rules.")
}

// If no types were specified in the policy, then we're running on a cluster that doesn't
// include support for that field in the API. In that case, the correct behavior is for the policy
// to apply to only ingress traffic.
if len(types) == 0 {
types = append(types, "ingress")
}

// Build and return the KVPair.
return &model.KVPair{
Key: model.PolicyKey{
Expand Down
Loading