Skip to content

Commit

Permalink
Merge pull request #25638 from caseydavenport/cd-network-policy-api
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

Add NetworkPolicy API Resource

API implementation of #24154

Still to do:
- [x] Get it working (See comments)
- [x] Make sure user-facing comments are correct.
- [x] Update naming in response to #24154
- [x] kubectl / client support
- [x] Release note.

```release-note
Implement NetworkPolicy v1beta1 API object / client support.
```

Next Steps:
- UTs in separate PR.
- e2e test in separate PR.
- make `Ports` + `From` pointers to slices (TODOs in code - to be done when auto-gen is fixed)

CC @thockin 

[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/.github/PULL_REQUEST_TEMPLATE.md?pixel)]()
  • Loading branch information
k8s-merge-robot committed May 21, 2016
2 parents c05c1d2 + 47248f3 commit d06fe0c
Show file tree
Hide file tree
Showing 26 changed files with 7,312 additions and 589 deletions.
13 changes: 13 additions & 0 deletions contrib/completions/bash/kubectl
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ _kubectl_get()
must_have_one_noun+=("job")
must_have_one_noun+=("limitrange")
must_have_one_noun+=("namespace")
must_have_one_noun+=("networkpolicy")
must_have_one_noun+=("node")
must_have_one_noun+=("persistentvolume")
must_have_one_noun+=("persistentvolumeclaim")
Expand Down Expand Up @@ -451,6 +452,7 @@ _kubectl_get()
noun_aliases+=("limitranges")
noun_aliases+=("limits")
noun_aliases+=("namespaces")
noun_aliases+=("networkpolicies")
noun_aliases+=("no")
noun_aliases+=("nodes")
noun_aliases+=("ns")
Expand Down Expand Up @@ -652,6 +654,7 @@ _kubectl_describe()
must_have_one_noun+=("job")
must_have_one_noun+=("limitrange")
must_have_one_noun+=("namespace")
must_have_one_noun+=("networkpolicy")
must_have_one_noun+=("node")
must_have_one_noun+=("persistentvolume")
must_have_one_noun+=("persistentvolumeclaim")
Expand Down Expand Up @@ -680,6 +683,7 @@ _kubectl_describe()
noun_aliases+=("limitranges")
noun_aliases+=("limits")
noun_aliases+=("namespaces")
noun_aliases+=("networkpolicies")
noun_aliases+=("no")
noun_aliases+=("nodes")
noun_aliases+=("ns")
Expand Down Expand Up @@ -1268,6 +1272,7 @@ _kubectl_patch()
must_have_one_noun+=("job")
must_have_one_noun+=("limitrange")
must_have_one_noun+=("namespace")
must_have_one_noun+=("networkpolicy")
must_have_one_noun+=("node")
must_have_one_noun+=("persistentvolume")
must_have_one_noun+=("persistentvolumeclaim")
Expand Down Expand Up @@ -1303,6 +1308,7 @@ _kubectl_patch()
noun_aliases+=("limitranges")
noun_aliases+=("limits")
noun_aliases+=("namespaces")
noun_aliases+=("networkpolicies")
noun_aliases+=("no")
noun_aliases+=("nodes")
noun_aliases+=("ns")
Expand Down Expand Up @@ -1401,6 +1407,7 @@ _kubectl_delete()
must_have_one_noun+=("job")
must_have_one_noun+=("limitrange")
must_have_one_noun+=("namespace")
must_have_one_noun+=("networkpolicy")
must_have_one_noun+=("node")
must_have_one_noun+=("persistentvolume")
must_have_one_noun+=("persistentvolumeclaim")
Expand Down Expand Up @@ -1436,6 +1443,7 @@ _kubectl_delete()
noun_aliases+=("limitranges")
noun_aliases+=("limits")
noun_aliases+=("namespaces")
noun_aliases+=("networkpolicies")
noun_aliases+=("no")
noun_aliases+=("nodes")
noun_aliases+=("ns")
Expand Down Expand Up @@ -1530,6 +1538,7 @@ _kubectl_edit()
must_have_one_noun+=("job")
must_have_one_noun+=("limitrange")
must_have_one_noun+=("namespace")
must_have_one_noun+=("networkpolicy")
must_have_one_noun+=("node")
must_have_one_noun+=("persistentvolume")
must_have_one_noun+=("persistentvolumeclaim")
Expand Down Expand Up @@ -1565,6 +1574,7 @@ _kubectl_edit()
noun_aliases+=("limitranges")
noun_aliases+=("limits")
noun_aliases+=("namespaces")
noun_aliases+=("networkpolicies")
noun_aliases+=("no")
noun_aliases+=("nodes")
noun_aliases+=("ns")
Expand Down Expand Up @@ -2857,6 +2867,7 @@ _kubectl_label()
must_have_one_noun+=("job")
must_have_one_noun+=("limitrange")
must_have_one_noun+=("namespace")
must_have_one_noun+=("networkpolicy")
must_have_one_noun+=("node")
must_have_one_noun+=("persistentvolume")
must_have_one_noun+=("persistentvolumeclaim")
Expand Down Expand Up @@ -2892,6 +2903,7 @@ _kubectl_label()
noun_aliases+=("limitranges")
noun_aliases+=("limits")
noun_aliases+=("namespaces")
noun_aliases+=("networkpolicies")
noun_aliases+=("no")
noun_aliases+=("nodes")
noun_aliases+=("ns")
Expand Down Expand Up @@ -3095,6 +3107,7 @@ _kubectl_taint()
must_have_one_noun+=("job")
must_have_one_noun+=("limitrange")
must_have_one_noun+=("namespace")
must_have_one_noun+=("networkpolicy")
must_have_one_noun+=("node")
must_have_one_noun+=("persistentvolume")
must_have_one_noun+=("persistentvolumeclaim")
Expand Down
130 changes: 130 additions & 0 deletions pkg/apis/extensions/deep_copy_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ func init() {
DeepCopy_extensions_IngressSpec,
DeepCopy_extensions_IngressStatus,
DeepCopy_extensions_IngressTLS,
DeepCopy_extensions_NetworkPolicy,
DeepCopy_extensions_NetworkPolicyIngressRule,
DeepCopy_extensions_NetworkPolicyList,
DeepCopy_extensions_NetworkPolicyPeer,
DeepCopy_extensions_NetworkPolicyPort,
DeepCopy_extensions_NetworkPolicySpec,
DeepCopy_extensions_PodSecurityPolicy,
DeepCopy_extensions_PodSecurityPolicyList,
DeepCopy_extensions_PodSecurityPolicySpec,
Expand Down Expand Up @@ -484,6 +490,130 @@ func DeepCopy_extensions_IngressTLS(in IngressTLS, out *IngressTLS, c *conversio
return nil
}

func DeepCopy_extensions_NetworkPolicy(in NetworkPolicy, out *NetworkPolicy, c *conversion.Cloner) error {
if err := unversioned.DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err
}
if err := api.DeepCopy_api_ObjectMeta(in.ObjectMeta, &out.ObjectMeta, c); err != nil {
return err
}
if err := DeepCopy_extensions_NetworkPolicySpec(in.Spec, &out.Spec, c); err != nil {
return err
}
return nil
}

func DeepCopy_extensions_NetworkPolicyIngressRule(in NetworkPolicyIngressRule, out *NetworkPolicyIngressRule, c *conversion.Cloner) error {
if in.Ports != nil {
in, out := in.Ports, &out.Ports
*out = make([]NetworkPolicyPort, len(in))
for i := range in {
if err := DeepCopy_extensions_NetworkPolicyPort(in[i], &(*out)[i], c); err != nil {
return err
}
}
} else {
out.Ports = nil
}
if in.From != nil {
in, out := in.From, &out.From
*out = make([]NetworkPolicyPeer, len(in))
for i := range in {
if err := DeepCopy_extensions_NetworkPolicyPeer(in[i], &(*out)[i], c); err != nil {
return err
}
}
} else {
out.From = nil
}
return nil
}

func DeepCopy_extensions_NetworkPolicyList(in NetworkPolicyList, out *NetworkPolicyList, c *conversion.Cloner) error {
if err := unversioned.DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err
}
if err := unversioned.DeepCopy_unversioned_ListMeta(in.ListMeta, &out.ListMeta, c); err != nil {
return err
}
if in.Items != nil {
in, out := in.Items, &out.Items
*out = make([]NetworkPolicy, len(in))
for i := range in {
if err := DeepCopy_extensions_NetworkPolicy(in[i], &(*out)[i], c); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}

func DeepCopy_extensions_NetworkPolicyPeer(in NetworkPolicyPeer, out *NetworkPolicyPeer, c *conversion.Cloner) error {
if in.PodSelector != nil {
in, out := in.PodSelector, &out.PodSelector
*out = new(unversioned.LabelSelector)
if err := unversioned.DeepCopy_unversioned_LabelSelector(*in, *out, c); err != nil {
return err
}
} else {
out.PodSelector = nil
}
if in.NamespaceSelector != nil {
in, out := in.NamespaceSelector, &out.NamespaceSelector
*out = new(unversioned.LabelSelector)
if err := unversioned.DeepCopy_unversioned_LabelSelector(*in, *out, c); err != nil {
return err
}
} else {
out.NamespaceSelector = nil
}
return nil
}

func DeepCopy_extensions_NetworkPolicyPort(in NetworkPolicyPort, out *NetworkPolicyPort, c *conversion.Cloner) error {
if in.Protocol != nil {
in, out := in.Protocol, &out.Protocol
*out = new(api.Protocol)
if newVal, err := c.DeepCopy(*in); err != nil {
return err
} else {
**out = newVal.(api.Protocol)
}
} else {
out.Protocol = nil
}
if in.Port != nil {
in, out := in.Port, &out.Port
*out = new(intstr.IntOrString)
if err := intstr.DeepCopy_intstr_IntOrString(*in, *out, c); err != nil {
return err
}
} else {
out.Port = nil
}
return nil
}

func DeepCopy_extensions_NetworkPolicySpec(in NetworkPolicySpec, out *NetworkPolicySpec, c *conversion.Cloner) error {
if err := unversioned.DeepCopy_unversioned_LabelSelector(in.PodSelector, &out.PodSelector, c); err != nil {
return err
}
if in.Ingress != nil {
in, out := in.Ingress, &out.Ingress
*out = make([]NetworkPolicyIngressRule, len(in))
for i := range in {
if err := DeepCopy_extensions_NetworkPolicyIngressRule(in[i], &(*out)[i], c); err != nil {
return err
}
}
} else {
out.Ingress = nil
}
return nil
}

func DeepCopy_extensions_PodSecurityPolicy(in PodSecurityPolicy, out *PodSecurityPolicy, c *conversion.Cloner) error {
if err := unversioned.DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/extensions/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func addKnownTypes(scheme *runtime.Scheme) {
&api.ExportOptions{},
&PodSecurityPolicy{},
&PodSecurityPolicyList{},
&NetworkPolicy{},
&NetworkPolicyList{},
)
}

Expand All @@ -93,3 +95,5 @@ func (obj *ReplicaSet) GetObjectKind() unversioned.ObjectKind {
func (obj *ReplicaSetList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *PodSecurityPolicy) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *PodSecurityPolicyList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *NetworkPolicy) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *NetworkPolicyList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
Loading

0 comments on commit d06fe0c

Please sign in to comment.