|
| 1 | +module k8sdispatcher { |
| 2 | + yang-version 1.1; |
| 3 | + namespace "http://polycube.network/k8sdispatcher"; |
| 4 | + prefix "k8sdispatcher"; |
| 5 | + |
| 6 | + import polycube-base { prefix "polycube-base"; } |
| 7 | + import polycube-standard-base { prefix "polycube-standard-base"; } |
| 8 | + |
| 9 | + import ietf-inet-types { prefix "inet"; } |
| 10 | + |
| 11 | + organization "Polycube open source project"; |
| 12 | + description "YANG data model for the Polycube K8s Dispatcher"; |
| 13 | + |
| 14 | + polycube-base:service-description "K8s Dispatcher Service"; |
| 15 | + polycube-base:service-version "2.0.0"; |
| 16 | + polycube-base:service-name "k8sdispatcher"; |
| 17 | + polycube-base:service-min-kernel-version "4.14.0"; |
| 18 | + |
| 19 | + typedef l4-proto { |
| 20 | + type enumeration { |
| 21 | + enum "TCP" { |
| 22 | + value 6; |
| 23 | + description "The TCP protocol type"; |
| 24 | + } |
| 25 | + enum "UDP" { |
| 26 | + value 17; |
| 27 | + description "The UDP protocol type"; |
| 28 | + } |
| 29 | + enum "ICMP" { |
| 30 | + value 1; |
| 31 | + description "The ICMP protocol type"; |
| 32 | + } |
| 33 | + } |
| 34 | + description "L4 protocol"; |
| 35 | + } |
| 36 | + |
| 37 | + uses "polycube-standard-base:standard-base-yang-module" { |
| 38 | + augment ports { |
| 39 | + leaf type { |
| 40 | + type enumeration { |
| 41 | + enum BACKEND { description "Port connected to the internal CNI topology"; } |
| 42 | + enum FRONTEND { description "Port connected to the node NIC"; } |
| 43 | + } |
| 44 | + description "Type of the K8s Dispatcher cube port (e.g. BACKEND or FRONTEND)"; |
| 45 | + mandatory true; |
| 46 | + polycube-base:init-only-config; |
| 47 | + } |
| 48 | + leaf ip { |
| 49 | + type inet:ipv4-address; |
| 50 | + description "IP address of the node interface (only for FRONTEND port)"; |
| 51 | + polycube-base:cli-example "10.10.1.1"; |
| 52 | + polycube-base:init-only-config; |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + leaf internal-src-ip { |
| 58 | + type inet:ipv4-address; |
| 59 | + description "Internal source IP address used for natting incoming packets directed to Kubernetes Services with a CLUSTER external traffic policy"; |
| 60 | + mandatory true; |
| 61 | + polycube-base:cli-example "10.10.1.1"; |
| 62 | + polycube-base:init-only-config; |
| 63 | + } |
| 64 | + |
| 65 | + leaf nodeport-range { |
| 66 | + type string; |
| 67 | + description "Port range used for NodePort Services"; |
| 68 | + default "30000-32767"; |
| 69 | + polycube-base:cli-example "30000-32767"; |
| 70 | + } |
| 71 | + |
| 72 | + list session-rule { |
| 73 | + key "direction src-ip dst-ip src-port dst-port proto"; |
| 74 | + description "Session entry related to a specific traffic direction"; |
| 75 | + config false; |
| 76 | + |
| 77 | + leaf direction { |
| 78 | + type enumeration { |
| 79 | + enum INGRESS { |
| 80 | + description "Direction of traffic going from the internal topology to the external world"; |
| 81 | + } |
| 82 | + enum EGRESS { |
| 83 | + description "Direction of traffic going from the external world to the internal CNI topology"; |
| 84 | + } |
| 85 | + } |
| 86 | + description "Session entry direction (e.g. INGRESS or EGRESS)"; |
| 87 | + } |
| 88 | + leaf src-ip { |
| 89 | + type inet:ipv4-address; |
| 90 | + description "Session entry source IP address"; |
| 91 | + } |
| 92 | + leaf dst-ip { |
| 93 | + type inet:ipv4-address; |
| 94 | + description "Session entry destination IP address"; |
| 95 | + } |
| 96 | + leaf src-port { |
| 97 | + type inet:port-number; |
| 98 | + description "Session entry source L4 port number"; |
| 99 | + } |
| 100 | + leaf dst-port { |
| 101 | + type inet:port-number; |
| 102 | + description "Session entry destination L4 port number"; |
| 103 | + } |
| 104 | + leaf proto { |
| 105 | + type l4-proto; |
| 106 | + description "Session entry L4 protocol"; |
| 107 | + polycube-base:cli-example "TCP, UDP, ICMP"; |
| 108 | + } |
| 109 | + |
| 110 | + leaf new-ip { |
| 111 | + type inet:ipv4-address; |
| 112 | + description "Translated IP address"; |
| 113 | + config false; |
| 114 | + } |
| 115 | + leaf new-port { |
| 116 | + type inet:port-number; |
| 117 | + description "Translated L4 port number"; |
| 118 | + config false; |
| 119 | + } |
| 120 | + leaf operation { |
| 121 | + type enumeration { |
| 122 | + enum XLATE_SRC { description "The source IP and port are replaced"; } |
| 123 | + enum XLATE_DST { description "The destination IP and port are replaced"; } |
| 124 | + } |
| 125 | + description "Operation applied on the original packet"; |
| 126 | + config false; |
| 127 | + } |
| 128 | + leaf originating-rule { |
| 129 | + type enumeration { |
| 130 | + enum POD_TO_EXT { |
| 131 | + description "Traffic related to communication between a Pod and the external world"; |
| 132 | + } |
| 133 | + enum NODEPORT_CLUSTER { |
| 134 | + description "Traffic related to communication involving a NodePort Service with having a CLUSTER external traffic policy"; |
| 135 | + } |
| 136 | + } |
| 137 | + description "Rule originating the session entry"; |
| 138 | + config false; |
| 139 | + } |
| 140 | + } |
| 141 | + |
| 142 | + list nodeport-rule { |
| 143 | + key "nodeport-port proto"; |
| 144 | + description "NodePort rule associated with a Kubernetes NodePort Service"; |
| 145 | + |
| 146 | + leaf nodeport-port { |
| 147 | + type inet:port-number; |
| 148 | + description "NodePort rule nodeport port number"; |
| 149 | + polycube-base:cli-example "30500"; |
| 150 | + } |
| 151 | + leaf proto { |
| 152 | + type l4-proto; |
| 153 | + description "NodePort rule L4 protocol"; |
| 154 | + polycube-base:cli-example "TCP, UDP, ICMP"; |
| 155 | + } |
| 156 | + |
| 157 | + leaf external-traffic-policy { |
| 158 | + type enumeration { |
| 159 | + enum LOCAL { description "Incoming traffic is allowed to be served only by local backends"; } |
| 160 | + enum CLUSTER { description "Incoming traffic is allowed to be served by any backend of the cluster"; } |
| 161 | + } |
| 162 | + default CLUSTER; |
| 163 | + description "The external traffic policy of the Kubernetes NodePort Service"; |
| 164 | + } |
| 165 | + leaf rule-name { |
| 166 | + type string; |
| 167 | + description "An optional name for the NodePort rule"; |
| 168 | + polycube-base:cli-example "my-nodeport-rule"; |
| 169 | + polycube-base:init-only-config; |
| 170 | + } |
| 171 | + } |
| 172 | +} |
| 173 | + |
0 commit comments