Matteo Scandolo | a428586 | 2020-12-01 18:10:10 -0800 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2017 The Kubernetes Authors. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package v1 |
| 18 | |
| 19 | import ( |
| 20 | "k8s.io/api/core/v1" |
| 21 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 22 | "k8s.io/apimachinery/pkg/util/intstr" |
| 23 | ) |
| 24 | |
| 25 | // +genclient |
| 26 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 27 | |
| 28 | // NetworkPolicy describes what network traffic is allowed for a set of Pods |
| 29 | type NetworkPolicy struct { |
| 30 | metav1.TypeMeta `json:",inline"` |
| 31 | // Standard object's metadata. |
| 32 | // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata |
| 33 | // +optional |
| 34 | metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 35 | |
| 36 | // Specification of the desired behavior for this NetworkPolicy. |
| 37 | // +optional |
| 38 | Spec NetworkPolicySpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` |
| 39 | } |
| 40 | |
| 41 | // Policy Type string describes the NetworkPolicy type |
| 42 | // This type is beta-level in 1.8 |
| 43 | type PolicyType string |
| 44 | |
| 45 | const ( |
| 46 | // PolicyTypeIngress is a NetworkPolicy that affects ingress traffic on selected pods |
| 47 | PolicyTypeIngress PolicyType = "Ingress" |
| 48 | // PolicyTypeEgress is a NetworkPolicy that affects egress traffic on selected pods |
| 49 | PolicyTypeEgress PolicyType = "Egress" |
| 50 | ) |
| 51 | |
| 52 | // NetworkPolicySpec provides the specification of a NetworkPolicy |
| 53 | type NetworkPolicySpec struct { |
| 54 | // Selects the pods to which this NetworkPolicy object applies. The array of |
| 55 | // ingress rules is applied to any pods selected by this field. Multiple network |
| 56 | // policies can select the same set of pods. In this case, the ingress rules for |
| 57 | // each are combined additively. This field is NOT optional and follows standard |
| 58 | // label selector semantics. An empty podSelector matches all pods in this |
| 59 | // namespace. |
| 60 | PodSelector metav1.LabelSelector `json:"podSelector" protobuf:"bytes,1,opt,name=podSelector"` |
| 61 | |
| 62 | // List of ingress rules to be applied to the selected pods. Traffic is allowed to |
| 63 | // a pod if there are no NetworkPolicies selecting the pod |
| 64 | // (and cluster policy otherwise allows the traffic), OR if the traffic source is |
| 65 | // the pod's local node, OR if the traffic matches at least one ingress rule |
| 66 | // across all of the NetworkPolicy objects whose podSelector matches the pod. If |
| 67 | // this field is empty then this NetworkPolicy does not allow any traffic (and serves |
| 68 | // solely to ensure that the pods it selects are isolated by default) |
| 69 | // +optional |
| 70 | Ingress []NetworkPolicyIngressRule `json:"ingress,omitempty" protobuf:"bytes,2,rep,name=ingress"` |
| 71 | |
| 72 | // List of egress rules to be applied to the selected pods. Outgoing traffic is |
| 73 | // allowed if there are no NetworkPolicies selecting the pod (and cluster policy |
| 74 | // otherwise allows the traffic), OR if the traffic matches at least one egress rule |
| 75 | // across all of the NetworkPolicy objects whose podSelector matches the pod. If |
| 76 | // this field is empty then this NetworkPolicy limits all outgoing traffic (and serves |
| 77 | // solely to ensure that the pods it selects are isolated by default). |
| 78 | // This field is beta-level in 1.8 |
| 79 | // +optional |
| 80 | Egress []NetworkPolicyEgressRule `json:"egress,omitempty" protobuf:"bytes,3,rep,name=egress"` |
| 81 | |
| 82 | // List of rule types that the NetworkPolicy relates to. |
| 83 | // Valid options are "Ingress", "Egress", or "Ingress,Egress". |
| 84 | // If this field is not specified, it will default based on the existence of Ingress or Egress rules; |
| 85 | // policies that contain an Egress section are assumed to affect Egress, and all policies |
| 86 | // (whether or not they contain an Ingress section) are assumed to affect Ingress. |
| 87 | // If you want to write an egress-only policy, you must explicitly specify policyTypes [ "Egress" ]. |
| 88 | // Likewise, if you want to write a policy that specifies that no egress is allowed, |
| 89 | // you must specify a policyTypes value that include "Egress" (since such a policy would not include |
| 90 | // an Egress section and would otherwise default to just [ "Ingress" ]). |
| 91 | // This field is beta-level in 1.8 |
| 92 | // +optional |
| 93 | PolicyTypes []PolicyType `json:"policyTypes,omitempty" protobuf:"bytes,4,rep,name=policyTypes,casttype=PolicyType"` |
| 94 | } |
| 95 | |
| 96 | // NetworkPolicyIngressRule describes a particular set of traffic that is allowed to the pods |
| 97 | // matched by a NetworkPolicySpec's podSelector. The traffic must match both ports and from. |
| 98 | type NetworkPolicyIngressRule struct { |
| 99 | // List of ports which should be made accessible on the pods selected for this |
| 100 | // rule. Each item in this list is combined using a logical OR. If this field is |
| 101 | // empty or missing, this rule matches all ports (traffic not restricted by port). |
| 102 | // If this field is present and contains at least one item, then this rule allows |
| 103 | // traffic only if the traffic matches at least one port in the list. |
| 104 | // +optional |
| 105 | Ports []NetworkPolicyPort `json:"ports,omitempty" protobuf:"bytes,1,rep,name=ports"` |
| 106 | |
| 107 | // List of sources which should be able to access the pods selected for this rule. |
| 108 | // Items in this list are combined using a logical OR operation. If this field is |
| 109 | // empty or missing, this rule matches all sources (traffic not restricted by |
| 110 | // source). If this field is present and contains at least one item, this rule |
| 111 | // allows traffic only if the traffic matches at least one item in the from list. |
| 112 | // +optional |
| 113 | From []NetworkPolicyPeer `json:"from,omitempty" protobuf:"bytes,2,rep,name=from"` |
| 114 | } |
| 115 | |
| 116 | // NetworkPolicyEgressRule describes a particular set of traffic that is allowed out of pods |
| 117 | // matched by a NetworkPolicySpec's podSelector. The traffic must match both ports and to. |
| 118 | // This type is beta-level in 1.8 |
| 119 | type NetworkPolicyEgressRule struct { |
| 120 | // List of destination ports for outgoing traffic. |
| 121 | // Each item in this list is combined using a logical OR. If this field is |
| 122 | // empty or missing, this rule matches all ports (traffic not restricted by port). |
| 123 | // If this field is present and contains at least one item, then this rule allows |
| 124 | // traffic only if the traffic matches at least one port in the list. |
| 125 | // +optional |
| 126 | Ports []NetworkPolicyPort `json:"ports,omitempty" protobuf:"bytes,1,rep,name=ports"` |
| 127 | |
| 128 | // List of destinations for outgoing traffic of pods selected for this rule. |
| 129 | // Items in this list are combined using a logical OR operation. If this field is |
| 130 | // empty or missing, this rule matches all destinations (traffic not restricted by |
| 131 | // destination). If this field is present and contains at least one item, this rule |
| 132 | // allows traffic only if the traffic matches at least one item in the to list. |
| 133 | // +optional |
| 134 | To []NetworkPolicyPeer `json:"to,omitempty" protobuf:"bytes,2,rep,name=to"` |
| 135 | } |
| 136 | |
| 137 | // NetworkPolicyPort describes a port to allow traffic on |
| 138 | type NetworkPolicyPort struct { |
| 139 | // The protocol (TCP, UDP, or SCTP) which traffic must match. If not specified, this |
| 140 | // field defaults to TCP. |
| 141 | // +optional |
| 142 | Protocol *v1.Protocol `json:"protocol,omitempty" protobuf:"bytes,1,opt,name=protocol,casttype=k8s.io/api/core/v1.Protocol"` |
| 143 | |
| 144 | // The port on the given protocol. This can either be a numerical or named port on |
| 145 | // a pod. If this field is not provided, this matches all port names and numbers. |
| 146 | // +optional |
| 147 | Port *intstr.IntOrString `json:"port,omitempty" protobuf:"bytes,2,opt,name=port"` |
| 148 | } |
| 149 | |
| 150 | // IPBlock describes a particular CIDR (Ex. "192.168.1.1/24","2001:db9::/64") that is allowed |
| 151 | // to the pods matched by a NetworkPolicySpec's podSelector. The except entry describes CIDRs |
| 152 | // that should not be included within this rule. |
| 153 | type IPBlock struct { |
| 154 | // CIDR is a string representing the IP Block |
| 155 | // Valid examples are "192.168.1.1/24" or "2001:db9::/64" |
| 156 | CIDR string `json:"cidr" protobuf:"bytes,1,name=cidr"` |
| 157 | // Except is a slice of CIDRs that should not be included within an IP Block |
| 158 | // Valid examples are "192.168.1.1/24" or "2001:db9::/64" |
| 159 | // Except values will be rejected if they are outside the CIDR range |
| 160 | // +optional |
| 161 | Except []string `json:"except,omitempty" protobuf:"bytes,2,rep,name=except"` |
| 162 | } |
| 163 | |
| 164 | // NetworkPolicyPeer describes a peer to allow traffic to/from. Only certain combinations of |
| 165 | // fields are allowed |
| 166 | type NetworkPolicyPeer struct { |
| 167 | // This is a label selector which selects Pods. This field follows standard label |
| 168 | // selector semantics; if present but empty, it selects all pods. |
| 169 | // |
| 170 | // If NamespaceSelector is also set, then the NetworkPolicyPeer as a whole selects |
| 171 | // the Pods matching PodSelector in the Namespaces selected by NamespaceSelector. |
| 172 | // Otherwise it selects the Pods matching PodSelector in the policy's own Namespace. |
| 173 | // +optional |
| 174 | PodSelector *metav1.LabelSelector `json:"podSelector,omitempty" protobuf:"bytes,1,opt,name=podSelector"` |
| 175 | |
| 176 | // Selects Namespaces using cluster-scoped labels. This field follows standard label |
| 177 | // selector semantics; if present but empty, it selects all namespaces. |
| 178 | // |
| 179 | // If PodSelector is also set, then the NetworkPolicyPeer as a whole selects |
| 180 | // the Pods matching PodSelector in the Namespaces selected by NamespaceSelector. |
| 181 | // Otherwise it selects all Pods in the Namespaces selected by NamespaceSelector. |
| 182 | // +optional |
| 183 | NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty" protobuf:"bytes,2,opt,name=namespaceSelector"` |
| 184 | |
| 185 | // IPBlock defines policy on a particular IPBlock. If this field is set then |
| 186 | // neither of the other fields can be. |
| 187 | // +optional |
| 188 | IPBlock *IPBlock `json:"ipBlock,omitempty" protobuf:"bytes,3,rep,name=ipBlock"` |
| 189 | } |
| 190 | |
| 191 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 192 | |
| 193 | // NetworkPolicyList is a list of NetworkPolicy objects. |
| 194 | type NetworkPolicyList struct { |
| 195 | metav1.TypeMeta `json:",inline"` |
| 196 | // Standard list metadata. |
| 197 | // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata |
| 198 | // +optional |
| 199 | metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 200 | |
| 201 | // Items is a list of schema objects. |
| 202 | Items []NetworkPolicy `json:"items" protobuf:"bytes,2,rep,name=items"` |
| 203 | } |
| 204 | |
| 205 | // +genclient |
| 206 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 207 | |
| 208 | // Ingress is a collection of rules that allow inbound connections to reach the |
| 209 | // endpoints defined by a backend. An Ingress can be configured to give services |
| 210 | // externally-reachable urls, load balance traffic, terminate SSL, offer name |
| 211 | // based virtual hosting etc. |
| 212 | type Ingress struct { |
| 213 | metav1.TypeMeta `json:",inline"` |
| 214 | // Standard object's metadata. |
| 215 | // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata |
| 216 | // +optional |
| 217 | metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 218 | |
| 219 | // Spec is the desired state of the Ingress. |
| 220 | // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status |
| 221 | // +optional |
| 222 | Spec IngressSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` |
| 223 | |
| 224 | // Status is the current state of the Ingress. |
| 225 | // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status |
| 226 | // +optional |
| 227 | Status IngressStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` |
| 228 | } |
| 229 | |
| 230 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 231 | |
| 232 | // IngressList is a collection of Ingress. |
| 233 | type IngressList struct { |
| 234 | metav1.TypeMeta `json:",inline"` |
| 235 | // Standard object's metadata. |
| 236 | // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata |
| 237 | // +optional |
| 238 | metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 239 | |
| 240 | // Items is the list of Ingress. |
| 241 | Items []Ingress `json:"items" protobuf:"bytes,2,rep,name=items"` |
| 242 | } |
| 243 | |
| 244 | // IngressSpec describes the Ingress the user wishes to exist. |
| 245 | type IngressSpec struct { |
| 246 | // IngressClassName is the name of the IngressClass cluster resource. The |
| 247 | // associated IngressClass defines which controller will implement the |
| 248 | // resource. This replaces the deprecated `kubernetes.io/ingress.class` |
| 249 | // annotation. For backwards compatibility, when that annotation is set, it |
| 250 | // must be given precedence over this field. The controller may emit a |
| 251 | // warning if the field and annotation have different values. |
| 252 | // Implementations of this API should ignore Ingresses without a class |
| 253 | // specified. An IngressClass resource may be marked as default, which can |
| 254 | // be used to set a default value for this field. For more information, |
| 255 | // refer to the IngressClass documentation. |
| 256 | // +optional |
| 257 | IngressClassName *string `json:"ingressClassName,omitempty" protobuf:"bytes,4,opt,name=ingressClassName"` |
| 258 | |
| 259 | // DefaultBackend is the backend that should handle requests that don't |
| 260 | // match any rule. If Rules are not specified, DefaultBackend must be specified. |
| 261 | // If DefaultBackend is not set, the handling of requests that do not match any |
| 262 | // of the rules will be up to the Ingress controller. |
| 263 | // +optional |
| 264 | DefaultBackend *IngressBackend `json:"defaultBackend,omitempty" protobuf:"bytes,1,opt,name=defaultBackend"` |
| 265 | |
| 266 | // TLS configuration. Currently the Ingress only supports a single TLS |
| 267 | // port, 443. If multiple members of this list specify different hosts, they |
| 268 | // will be multiplexed on the same port according to the hostname specified |
| 269 | // through the SNI TLS extension, if the ingress controller fulfilling the |
| 270 | // ingress supports SNI. |
| 271 | // +listType=atomic |
| 272 | // +optional |
| 273 | TLS []IngressTLS `json:"tls,omitempty" protobuf:"bytes,2,rep,name=tls"` |
| 274 | |
| 275 | // A list of host rules used to configure the Ingress. If unspecified, or |
| 276 | // no rule matches, all traffic is sent to the default backend. |
| 277 | // +listType=atomic |
| 278 | // +optional |
| 279 | Rules []IngressRule `json:"rules,omitempty" protobuf:"bytes,3,rep,name=rules"` |
| 280 | } |
| 281 | |
| 282 | // IngressTLS describes the transport layer security associated with an Ingress. |
| 283 | type IngressTLS struct { |
| 284 | // Hosts are a list of hosts included in the TLS certificate. The values in |
| 285 | // this list must match the name/s used in the tlsSecret. Defaults to the |
| 286 | // wildcard host setting for the loadbalancer controller fulfilling this |
| 287 | // Ingress, if left unspecified. |
| 288 | // +listType=atomic |
| 289 | // +optional |
| 290 | Hosts []string `json:"hosts,omitempty" protobuf:"bytes,1,rep,name=hosts"` |
| 291 | // SecretName is the name of the secret used to terminate TLS traffic on |
| 292 | // port 443. Field is left optional to allow TLS routing based on SNI |
| 293 | // hostname alone. If the SNI host in a listener conflicts with the "Host" |
| 294 | // header field used by an IngressRule, the SNI host is used for termination |
| 295 | // and value of the Host header is used for routing. |
| 296 | // +optional |
| 297 | SecretName string `json:"secretName,omitempty" protobuf:"bytes,2,opt,name=secretName"` |
| 298 | } |
| 299 | |
| 300 | // IngressStatus describe the current state of the Ingress. |
| 301 | type IngressStatus struct { |
| 302 | // LoadBalancer contains the current status of the load-balancer. |
| 303 | // +optional |
| 304 | LoadBalancer v1.LoadBalancerStatus `json:"loadBalancer,omitempty" protobuf:"bytes,1,opt,name=loadBalancer"` |
| 305 | } |
| 306 | |
| 307 | // IngressRule represents the rules mapping the paths under a specified host to |
| 308 | // the related backend services. Incoming requests are first evaluated for a host |
| 309 | // match, then routed to the backend associated with the matching IngressRuleValue. |
| 310 | type IngressRule struct { |
| 311 | // Host is the fully qualified domain name of a network host, as defined by RFC 3986. |
| 312 | // Note the following deviations from the "host" part of the |
| 313 | // URI as defined in RFC 3986: |
| 314 | // 1. IPs are not allowed. Currently an IngressRuleValue can only apply to |
| 315 | // the IP in the Spec of the parent Ingress. |
| 316 | // 2. The `:` delimiter is not respected because ports are not allowed. |
| 317 | // Currently the port of an Ingress is implicitly :80 for http and |
| 318 | // :443 for https. |
| 319 | // Both these may change in the future. |
| 320 | // Incoming requests are matched against the host before the |
| 321 | // IngressRuleValue. If the host is unspecified, the Ingress routes all |
| 322 | // traffic based on the specified IngressRuleValue. |
| 323 | // |
| 324 | // Host can be "precise" which is a domain name without the terminating dot of |
| 325 | // a network host (e.g. "foo.bar.com") or "wildcard", which is a domain name |
| 326 | // prefixed with a single wildcard label (e.g. "*.foo.com"). |
| 327 | // The wildcard character '*' must appear by itself as the first DNS label and |
| 328 | // matches only a single label. You cannot have a wildcard label by itself (e.g. Host == "*"). |
| 329 | // Requests will be matched against the Host field in the following way: |
| 330 | // 1. If Host is precise, the request matches this rule if the http host header is equal to Host. |
| 331 | // 2. If Host is a wildcard, then the request matches this rule if the http host header |
| 332 | // is to equal to the suffix (removing the first label) of the wildcard rule. |
| 333 | // +optional |
| 334 | Host string `json:"host,omitempty" protobuf:"bytes,1,opt,name=host"` |
| 335 | // IngressRuleValue represents a rule to route requests for this IngressRule. |
| 336 | // If unspecified, the rule defaults to a http catch-all. Whether that sends |
| 337 | // just traffic matching the host to the default backend or all traffic to the |
| 338 | // default backend, is left to the controller fulfilling the Ingress. Http is |
| 339 | // currently the only supported IngressRuleValue. |
| 340 | // +optional |
| 341 | IngressRuleValue `json:",inline,omitempty" protobuf:"bytes,2,opt,name=ingressRuleValue"` |
| 342 | } |
| 343 | |
| 344 | // IngressRuleValue represents a rule to apply against incoming requests. If the |
| 345 | // rule is satisfied, the request is routed to the specified backend. Currently |
| 346 | // mixing different types of rules in a single Ingress is disallowed, so exactly |
| 347 | // one of the following must be set. |
| 348 | type IngressRuleValue struct { |
| 349 | // +optional |
| 350 | HTTP *HTTPIngressRuleValue `json:"http,omitempty" protobuf:"bytes,1,opt,name=http"` |
| 351 | } |
| 352 | |
| 353 | // HTTPIngressRuleValue is a list of http selectors pointing to backends. |
| 354 | // In the example: http://<host>/<path>?<searchpart> -> backend where |
| 355 | // where parts of the url correspond to RFC 3986, this resource will be used |
| 356 | // to match against everything after the last '/' and before the first '?' |
| 357 | // or '#'. |
| 358 | type HTTPIngressRuleValue struct { |
| 359 | // A collection of paths that map requests to backends. |
| 360 | // +listType=atomic |
| 361 | Paths []HTTPIngressPath `json:"paths" protobuf:"bytes,1,rep,name=paths"` |
| 362 | } |
| 363 | |
| 364 | // PathType represents the type of path referred to by a HTTPIngressPath. |
| 365 | type PathType string |
| 366 | |
| 367 | const ( |
| 368 | // PathTypeExact matches the URL path exactly and with case sensitivity. |
| 369 | PathTypeExact = PathType("Exact") |
| 370 | |
| 371 | // PathTypePrefix matches based on a URL path prefix split by '/'. Matching |
| 372 | // is case sensitive and done on a path element by element basis. A path |
| 373 | // element refers to the list of labels in the path split by the '/' |
| 374 | // separator. A request is a match for path p if every p is an element-wise |
| 375 | // prefix of p of the request path. Note that if the last element of the |
| 376 | // path is a substring of the last element in request path, it is not a |
| 377 | // match (e.g. /foo/bar matches /foo/bar/baz, but does not match |
| 378 | // /foo/barbaz). If multiple matching paths exist in an Ingress spec, the |
| 379 | // longest matching path is given priority. |
| 380 | // Examples: |
| 381 | // - /foo/bar does not match requests to /foo/barbaz |
| 382 | // - /foo/bar matches request to /foo/bar and /foo/bar/baz |
| 383 | // - /foo and /foo/ both match requests to /foo and /foo/. If both paths are |
| 384 | // present in an Ingress spec, the longest matching path (/foo/) is given |
| 385 | // priority. |
| 386 | PathTypePrefix = PathType("Prefix") |
| 387 | |
| 388 | // PathTypeImplementationSpecific matching is up to the IngressClass. |
| 389 | // Implementations can treat this as a separate PathType or treat it |
| 390 | // identically to Prefix or Exact path types. |
| 391 | PathTypeImplementationSpecific = PathType("ImplementationSpecific") |
| 392 | ) |
| 393 | |
| 394 | // HTTPIngressPath associates a path with a backend. Incoming urls matching the |
| 395 | // path are forwarded to the backend. |
| 396 | type HTTPIngressPath struct { |
| 397 | // Path is matched against the path of an incoming request. Currently it can |
| 398 | // contain characters disallowed from the conventional "path" part of a URL |
| 399 | // as defined by RFC 3986. Paths must begin with a '/'. When unspecified, |
| 400 | // all paths from incoming requests are matched. |
| 401 | // +optional |
| 402 | Path string `json:"path,omitempty" protobuf:"bytes,1,opt,name=path"` |
| 403 | |
| 404 | // PathType determines the interpretation of the Path matching. PathType can |
| 405 | // be one of the following values: |
| 406 | // * Exact: Matches the URL path exactly. |
| 407 | // * Prefix: Matches based on a URL path prefix split by '/'. Matching is |
| 408 | // done on a path element by element basis. A path element refers is the |
| 409 | // list of labels in the path split by the '/' separator. A request is a |
| 410 | // match for path p if every p is an element-wise prefix of p of the |
| 411 | // request path. Note that if the last element of the path is a substring |
| 412 | // of the last element in request path, it is not a match (e.g. /foo/bar |
| 413 | // matches /foo/bar/baz, but does not match /foo/barbaz). |
| 414 | // * ImplementationSpecific: Interpretation of the Path matching is up to |
| 415 | // the IngressClass. Implementations can treat this as a separate PathType |
| 416 | // or treat it identically to Prefix or Exact path types. |
| 417 | // Implementations are required to support all path types. |
| 418 | PathType *PathType `json:"pathType,omitempty" protobuf:"bytes,3,opt,name=pathType"` |
| 419 | |
| 420 | // Backend defines the referenced service endpoint to which the traffic |
| 421 | // will be forwarded to. |
| 422 | Backend IngressBackend `json:"backend" protobuf:"bytes,2,opt,name=backend"` |
| 423 | } |
| 424 | |
| 425 | // IngressBackend describes all endpoints for a given service and port. |
| 426 | type IngressBackend struct { |
| 427 | // Service references a Service as a Backend. |
| 428 | // This is a mutually exclusive setting with "Resource". |
| 429 | // +optional |
| 430 | Service *IngressServiceBackend `json:"service,omitempty" protobuf:"bytes,4,opt,name=service"` |
| 431 | |
| 432 | // Resource is an ObjectRef to another Kubernetes resource in the namespace |
| 433 | // of the Ingress object. If resource is specified, a service.Name and |
| 434 | // service.Port must not be specified. |
| 435 | // This is a mutually exclusive setting with "Service". |
| 436 | // +optional |
| 437 | Resource *v1.TypedLocalObjectReference `json:"resource,omitempty" protobuf:"bytes,3,opt,name=resource"` |
| 438 | } |
| 439 | |
| 440 | // IngressServiceBackend references a Kubernetes Service as a Backend. |
| 441 | type IngressServiceBackend struct { |
| 442 | // Name is the referenced service. The service must exist in |
| 443 | // the same namespace as the Ingress object. |
| 444 | Name string `json:"name" protobuf:"bytes,1,opt,name=name"` |
| 445 | |
| 446 | // Port of the referenced service. A port name or port number |
| 447 | // is required for a IngressServiceBackend. |
| 448 | Port ServiceBackendPort `json:"port,omitempty" protobuf:"bytes,2,opt,name=port"` |
| 449 | } |
| 450 | |
| 451 | // ServiceBackendPort is the service port being referenced. |
| 452 | type ServiceBackendPort struct { |
| 453 | // Name is the name of the port on the Service. |
| 454 | // This is a mutually exclusive setting with "Number". |
| 455 | // +optional |
| 456 | Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"` |
| 457 | |
| 458 | // Number is the numerical port number (e.g. 80) on the Service. |
| 459 | // This is a mutually exclusive setting with "Name". |
| 460 | // +optional |
| 461 | Number int32 `json:"number,omitempty" protobuf:"bytes,2,opt,name=number"` |
| 462 | } |
| 463 | |
| 464 | // +genclient |
| 465 | // +genclient:nonNamespaced |
| 466 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 467 | |
| 468 | // IngressClass represents the class of the Ingress, referenced by the Ingress |
| 469 | // Spec. The `ingressclass.kubernetes.io/is-default-class` annotation can be |
| 470 | // used to indicate that an IngressClass should be considered default. When a |
| 471 | // single IngressClass resource has this annotation set to true, new Ingress |
| 472 | // resources without a class specified will be assigned this default class. |
| 473 | type IngressClass struct { |
| 474 | metav1.TypeMeta `json:",inline"` |
| 475 | // Standard object's metadata. |
| 476 | // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata |
| 477 | // +optional |
| 478 | metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 479 | |
| 480 | // Spec is the desired state of the IngressClass. |
| 481 | // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status |
| 482 | // +optional |
| 483 | Spec IngressClassSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` |
| 484 | } |
| 485 | |
| 486 | // IngressClassSpec provides information about the class of an Ingress. |
| 487 | type IngressClassSpec struct { |
| 488 | // Controller refers to the name of the controller that should handle this |
| 489 | // class. This allows for different "flavors" that are controlled by the |
| 490 | // same controller. For example, you may have different Parameters for the |
| 491 | // same implementing controller. This should be specified as a |
| 492 | // domain-prefixed path no more than 250 characters in length, e.g. |
| 493 | // "acme.io/ingress-controller". This field is immutable. |
| 494 | Controller string `json:"controller,omitempty" protobuf:"bytes,1,opt,name=controller"` |
| 495 | |
| 496 | // Parameters is a link to a custom resource containing additional |
| 497 | // configuration for the controller. This is optional if the controller does |
| 498 | // not require extra parameters. |
| 499 | // +optional |
| 500 | Parameters *v1.TypedLocalObjectReference `json:"parameters,omitempty" protobuf:"bytes,2,opt,name=parameters"` |
| 501 | } |
| 502 | |
| 503 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 504 | |
| 505 | // IngressClassList is a collection of IngressClasses. |
| 506 | type IngressClassList struct { |
| 507 | metav1.TypeMeta `json:",inline"` |
| 508 | // Standard list metadata. |
| 509 | // +optional |
| 510 | metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 511 | |
| 512 | // Items is the list of IngressClasses. |
| 513 | Items []IngressClass `json:"items" protobuf:"bytes,2,rep,name=items"` |
| 514 | } |