• Kubernetes Submit Queue's avatar
    Merge pull request #61689 from Lion-Wei/kubectl-np · 44ede98e
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue (batch tested with PRs 62510, 61689). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.
    
    Extend kubectl describe for networkPolicy
    
    **What this PR does / why we need it**:
    Recently `networkpolicy` was allowed podSelector and namespaceSelector to be specified together in a NetworkPolicyPeer, so we need to extend `kubectl describe` for networkpolicy.
    
    **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
    Fixes kubernetes/kubectl#376
    
    **Special notes for your reviewer**:
    Here is the example output of `kubectl describe networkpolicies`:
    NetworkPolicy file:
    ```yaml
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: test-network-policy
      namespace: default
    spec:
      podSelector:
        matchLabels:
          role: db
      ingress:
      - from:
        - namespaceSelector:
            matchLabels:
              project: myproject
          podSelector:
            matchLabels:
              role: frontend
        ports:
        - protocol: TCP
          port: 6379
      egress:
      - to:
        - namespaceSelector:
            matchLabels:
              project: myproject
          podSelector:
            matchLabels:
              role: frontend
        ports:
        - protocol: TCP
          port: 6379
    ```
    describe:
    ```shell
    # ./kubectl describe netpol test-network-policy
    Name:         test-network-policy
    Namespace:    default
    Created on:   2018-03-26 15:20:11 +0800 CST
    Labels:       <none>
    Annotations:  <none>
    Spec:
      PodSelector:     role=db
      Allowing ingress traffic:
        To Port: 6379/TCP
        From NamespaceSelector: project=myproject
             PodSelector: role=frontend
      Allowing egress traffic:
        To Port: 6379/TCP
        To NamespaceSelector: project=myproject
           PodSelector: role=frontend
      Policy Types: Ingress, Egress
    
    ```
    
    **Release note**:
    ```release-note
    NONE
    ```
    44ede98e
Name
Last commit
Last update
..
internalversion Loading commit data...
storage Loading commit data...
.import-restrictions Loading commit data...
BUILD Loading commit data...
OWNERS Loading commit data...
customcolumn.go Loading commit data...
customcolumn_flags.go Loading commit data...
customcolumn_flags_test.go Loading commit data...
customcolumn_test.go Loading commit data...
flags.go Loading commit data...
humanreadable.go Loading commit data...
humanreadable_flags.go Loading commit data...
humanreadable_flags_test.go Loading commit data...
humanreadable_test.go Loading commit data...
interface.go Loading commit data...
json.go Loading commit data...
json_yaml_flags.go Loading commit data...
json_yaml_flags_test.go Loading commit data...
jsonpath.go Loading commit data...
jsonpath_flags.go Loading commit data...
jsonpath_flags_test.go Loading commit data...
kube_template_flags.go Loading commit data...
name.go Loading commit data...
name_flags.go Loading commit data...
name_flags_test.go Loading commit data...
printers.go Loading commit data...
tabwriter.go Loading commit data...
template.go Loading commit data...
template_flags.go Loading commit data...
template_flags_test.go Loading commit data...
template_test.go Loading commit data...
versioned.go Loading commit data...