• 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
..
api Loading commit data...
apis Loading commit data...
auth Loading commit data...
capabilities Loading commit data...
client Loading commit data...
cloudprovider Loading commit data...
controller Loading commit data...
credentialprovider Loading commit data...
features Loading commit data...
fieldpath Loading commit data...
generated Loading commit data...
kubeapiserver Loading commit data...
kubectl Loading commit data...
kubelet Loading commit data...
kubemark Loading commit data...
master Loading commit data...
printers Loading commit data...
probe Loading commit data...
proxy Loading commit data...
quota Loading commit data...
registry Loading commit data...
routes Loading commit data...
scheduler Loading commit data...
security Loading commit data...
securitycontext Loading commit data...
serviceaccount Loading commit data...
ssh Loading commit data...
util Loading commit data...
version Loading commit data...
volume Loading commit data...
watch/json Loading commit data...
windows/service Loading commit data...
.import-restrictions Loading commit data...
BUILD Loading commit data...
OWNERS Loading commit data...