Skip to content

L4 protocol policy needs to have always port #2292

@eloycoto

Description

@eloycoto

Hi,

I figured this week that if you have a policy that only allows TCP, it didn't work. You need to specify always the port too.

Example pod manifest:

https://raw.githubusercontent.com/cilium/cilium/master/examples/minikube/demo.yaml

Example policy:

{
  "apiVersion": "cilium.io/v2",
  "kind": "CiliumNetworkPolicy",
  "metadata": {
    "name": "Protocolonly",
    "test": ""
  },
  "specs": [
    {
      "EndpointSelector": {
        "matchlabels": {
          "id": "app1"
        }
      },
      "Ingress": [
        {
          "FromEndpoints": [
            {}
          ],
          "ToPorts": [
            {
              "Ports": [
                {
                  "protocol": "TCP"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

CNP Describe:

root@k8s1:/home/vagrant# kubectl describe cnp protocolonly 
Name:           protocolonly 
Namespace:      default      
Labels:         <none>       
Annotations:    kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"cilium.io/v2","kind":"CiliumNetworkPolicy","metadata":{"annotations":{},"name":"protocolonly","namespace":"default","test":""},"specs":[...
API Version:    cilium.io/v2 
Kind:           CiliumNetworkPolicy                        
Metadata:                    
  Cluster Name:              
  Creation Timestamp:   2017-12-08T12:05:08Z               
  Generation:           0    
  Resource Version:     3383 
  Self Link:            /apis/cilium.io/v2/namespaces/default/ciliumnetworkpolicies/protocolonly                       
  UID:                  08a75379-dc10-11e7-b129-080027900c72                                                           
Specs:                       
  Endpoint Selector:         
    Match Labels:            
      Any : Id: app1         
  Ingress:                   
    From Endpoints:          
    To Ports:                
      Ports:                 
        Port:                
        Protocol:       TCP  
Status:                      
  Nodes:                     
    K 8 S 1:                 
      Error:            Invalid CiliumNetworkPolicy specs: Port must be specified                                      
      Last Updated:     2017-12-08T12:05:08.092627427Z     
Events:                 <none>                             

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/datapathImpacts bpf/ or low-level forwarding details, including map management and monitor messages.area/k8sImpacts the kubernetes API, or kubernetes -> cilium internals translation layers.priority/lowThis is considered nice to have.staleThe stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions