|
| 1 | +--- |
| 2 | +apiVersion: "k8s.cni.cncf.io/v1" |
| 3 | +kind: NetworkAttachmentDefinition |
| 4 | +metadata: |
| 5 | + namespace: default |
| 6 | + name: macvlan1-simple |
| 7 | +spec: |
| 8 | + config: '{ |
| 9 | + "cniVersion": "0.3.1", |
| 10 | + "name": "macvlan1-simple", |
| 11 | + "plugins": [ |
| 12 | + { |
| 13 | + "type": "macvlan", |
| 14 | + "mode": "bridge", |
| 15 | + "ipam":{ |
| 16 | + "type":"host-local", |
| 17 | + "subnet":"2.2.6.0/24", |
| 18 | + "rangeStart":"2.2.6.8", |
| 19 | + "rangeEnd":"2.2.6.67" |
| 20 | + } |
| 21 | + }] |
| 22 | + }' |
| 23 | +--- |
| 24 | +# namespace for MultiNetworkPolicy |
| 25 | +apiVersion: v1 |
| 26 | +kind: Namespace |
| 27 | +metadata: |
| 28 | + name: test-port-range |
| 29 | +--- |
| 30 | +# Pods |
| 31 | +apiVersion: v1 |
| 32 | +kind: Pod |
| 33 | +metadata: |
| 34 | + name: pod-a |
| 35 | + namespace: test-port-range |
| 36 | + annotations: |
| 37 | + k8s.v1.cni.cncf.io/networks: default/macvlan1-simple |
| 38 | + labels: |
| 39 | + app: test-port-range |
| 40 | + name: pod-a |
| 41 | +spec: |
| 42 | + containers: |
| 43 | + - name: netcat-tcp-5555 |
| 44 | + image: ghcr.io/k8snetworkplumbingwg/multi-networkpolicy-iptables:e2e-test |
| 45 | + command: ["nc", "-klp", "5555"] |
| 46 | + securityContext: |
| 47 | + privileged: true |
| 48 | + - name: netcat-tcp-6666 |
| 49 | + image: ghcr.io/k8snetworkplumbingwg/multi-networkpolicy-iptables:e2e-test |
| 50 | + command: ["nc", "-klp", "6666"] |
| 51 | + securityContext: |
| 52 | + privileged: true |
| 53 | +--- |
| 54 | +apiVersion: v1 |
| 55 | +kind: Pod |
| 56 | +metadata: |
| 57 | + name: pod-b |
| 58 | + namespace: test-port-range |
| 59 | + annotations: |
| 60 | + k8s.v1.cni.cncf.io/networks: default/macvlan1-simple |
| 61 | + labels: |
| 62 | + app: test-port-range |
| 63 | + name: pod-b |
| 64 | +spec: |
| 65 | + containers: |
| 66 | + - name: netcat-tcp-5555 |
| 67 | + image: ghcr.io/k8snetworkplumbingwg/multi-networkpolicy-iptables:e2e-test |
| 68 | + command: ["nc", "-klp", "5555"] |
| 69 | + securityContext: |
| 70 | + privileged: true |
| 71 | + - name: netcat-tcp-6666 |
| 72 | + image: ghcr.io/k8snetworkplumbingwg/multi-networkpolicy-iptables:e2e-test |
| 73 | + command: ["nc", "-klp", "6666"] |
| 74 | + securityContext: |
| 75 | + privileged: true |
| 76 | +--- |
| 77 | +# MultiNetworkPolicies |
| 78 | +apiVersion: k8s.cni.cncf.io/v1beta1 |
| 79 | +kind: MultiNetworkPolicy |
| 80 | +metadata: |
| 81 | + name: test-multinetwork-policy-simple-1 |
| 82 | + namespace: test-port-range |
| 83 | + annotations: |
| 84 | + k8s.v1.cni.cncf.io/policy-for: default/macvlan1-simple |
| 85 | +spec: |
| 86 | + podSelector: |
| 87 | + matchLabels: |
| 88 | + name: pod-a |
| 89 | + policyTypes: |
| 90 | + - Egress |
| 91 | + - Ingress |
| 92 | + egress: |
| 93 | + - ports: |
| 94 | + - port: 5000 |
| 95 | + endPort: 5900 |
| 96 | + ingress: |
| 97 | + - ports: |
| 98 | + - port: 6000 |
| 99 | + endPort: 6900 |
0 commit comments