blob: 63bf2d52a3d1fc00d15164913300c4432988ac7c [file] [log] [blame]
Zack Williamse940c7a2019-08-21 14:25:39 -07001/*
2Copyright 2019 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package v1beta1
18
19import (
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// Ingress is a collection of rules that allow inbound connections to reach the
29// endpoints defined by a backend. An Ingress can be configured to give services
30// externally-reachable urls, load balance traffic, terminate SSL, offer name
31// based virtual hosting etc.
32type Ingress struct {
33 metav1.TypeMeta `json:",inline"`
34 // Standard object's metadata.
35 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
36 // +optional
37 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
38
39 // Spec is the desired state of the Ingress.
40 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
41 // +optional
42 Spec IngressSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
43
44 // Status is the current state of the Ingress.
45 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
46 // +optional
47 Status IngressStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
48}
49
50// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
51
52// IngressList is a collection of Ingress.
53type IngressList struct {
54 metav1.TypeMeta `json:",inline"`
55 // Standard object's metadata.
56 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
57 // +optional
58 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
59
60 // Items is the list of Ingress.
61 Items []Ingress `json:"items" protobuf:"bytes,2,rep,name=items"`
62}
63
64// IngressSpec describes the Ingress the user wishes to exist.
65type IngressSpec struct {
66 // A default backend capable of servicing requests that don't match any
67 // rule. At least one of 'backend' or 'rules' must be specified. This field
68 // is optional to allow the loadbalancer controller or defaulting logic to
69 // specify a global default.
70 // +optional
71 Backend *IngressBackend `json:"backend,omitempty" protobuf:"bytes,1,opt,name=backend"`
72
73 // TLS configuration. Currently the Ingress only supports a single TLS
74 // port, 443. If multiple members of this list specify different hosts, they
75 // will be multiplexed on the same port according to the hostname specified
76 // through the SNI TLS extension, if the ingress controller fulfilling the
77 // ingress supports SNI.
78 // +optional
79 TLS []IngressTLS `json:"tls,omitempty" protobuf:"bytes,2,rep,name=tls"`
80
81 // A list of host rules used to configure the Ingress. If unspecified, or
82 // no rule matches, all traffic is sent to the default backend.
83 // +optional
84 Rules []IngressRule `json:"rules,omitempty" protobuf:"bytes,3,rep,name=rules"`
85 // TODO: Add the ability to specify load-balancer IP through claims
86}
87
88// IngressTLS describes the transport layer security associated with an Ingress.
89type IngressTLS struct {
90 // Hosts are a list of hosts included in the TLS certificate. The values in
91 // this list must match the name/s used in the tlsSecret. Defaults to the
92 // wildcard host setting for the loadbalancer controller fulfilling this
93 // Ingress, if left unspecified.
94 // +optional
95 Hosts []string `json:"hosts,omitempty" protobuf:"bytes,1,rep,name=hosts"`
96 // SecretName is the name of the secret used to terminate SSL traffic on 443.
97 // Field is left optional to allow SSL routing based on SNI hostname alone.
98 // If the SNI host in a listener conflicts with the "Host" header field used
99 // by an IngressRule, the SNI host is used for termination and value of the
100 // Host header is used for routing.
101 // +optional
102 SecretName string `json:"secretName,omitempty" protobuf:"bytes,2,opt,name=secretName"`
103 // TODO: Consider specifying different modes of termination, protocols etc.
104}
105
106// IngressStatus describe the current state of the Ingress.
107type IngressStatus struct {
108 // LoadBalancer contains the current status of the load-balancer.
109 // +optional
110 LoadBalancer v1.LoadBalancerStatus `json:"loadBalancer,omitempty" protobuf:"bytes,1,opt,name=loadBalancer"`
111}
112
113// IngressRule represents the rules mapping the paths under a specified host to
114// the related backend services. Incoming requests are first evaluated for a host
115// match, then routed to the backend associated with the matching IngressRuleValue.
116type IngressRule struct {
117 // Host is the fully qualified domain name of a network host, as defined
118 // by RFC 3986. Note the following deviations from the "host" part of the
119 // URI as defined in the RFC:
120 // 1. IPs are not allowed. Currently an IngressRuleValue can only apply to the
121 // IP in the Spec of the parent Ingress.
122 // 2. The `:` delimiter is not respected because ports are not allowed.
123 // Currently the port of an Ingress is implicitly :80 for http and
124 // :443 for https.
125 // Both these may change in the future.
126 // Incoming requests are matched against the host before the IngressRuleValue.
127 // If the host is unspecified, the Ingress routes all traffic based on the
128 // specified IngressRuleValue.
129 // +optional
130 Host string `json:"host,omitempty" protobuf:"bytes,1,opt,name=host"`
131 // IngressRuleValue represents a rule to route requests for this IngressRule.
132 // If unspecified, the rule defaults to a http catch-all. Whether that sends
133 // just traffic matching the host to the default backend or all traffic to the
134 // default backend, is left to the controller fulfilling the Ingress. Http is
135 // currently the only supported IngressRuleValue.
136 // +optional
137 IngressRuleValue `json:",inline,omitempty" protobuf:"bytes,2,opt,name=ingressRuleValue"`
138}
139
140// IngressRuleValue represents a rule to apply against incoming requests. If the
141// rule is satisfied, the request is routed to the specified backend. Currently
142// mixing different types of rules in a single Ingress is disallowed, so exactly
143// one of the following must be set.
144type IngressRuleValue struct {
145 //TODO:
146 // 1. Consider renaming this resource and the associated rules so they
147 // aren't tied to Ingress. They can be used to route intra-cluster traffic.
148 // 2. Consider adding fields for ingress-type specific global options
149 // usable by a loadbalancer, like http keep-alive.
150
151 // +optional
152 HTTP *HTTPIngressRuleValue `json:"http,omitempty" protobuf:"bytes,1,opt,name=http"`
153}
154
155// HTTPIngressRuleValue is a list of http selectors pointing to backends.
156// In the example: http://<host>/<path>?<searchpart> -> backend where
157// where parts of the url correspond to RFC 3986, this resource will be used
158// to match against everything after the last '/' and before the first '?'
159// or '#'.
160type HTTPIngressRuleValue struct {
161 // A collection of paths that map requests to backends.
162 Paths []HTTPIngressPath `json:"paths" protobuf:"bytes,1,rep,name=paths"`
163 // TODO: Consider adding fields for ingress-type specific global
164 // options usable by a loadbalancer, like http keep-alive.
165}
166
167// HTTPIngressPath associates a path regex with a backend. Incoming urls matching
168// the path are forwarded to the backend.
169type HTTPIngressPath struct {
170 // Path is an extended POSIX regex as defined by IEEE Std 1003.1,
171 // (i.e this follows the egrep/unix syntax, not the perl syntax)
172 // matched against the path of an incoming request. Currently it can
173 // contain characters disallowed from the conventional "path"
174 // part of a URL as defined by RFC 3986. Paths must begin with
175 // a '/'. If unspecified, the path defaults to a catch all sending
176 // traffic to the backend.
177 // +optional
178 Path string `json:"path,omitempty" protobuf:"bytes,1,opt,name=path"`
179
180 // Backend defines the referenced service endpoint to which the traffic
181 // will be forwarded to.
182 Backend IngressBackend `json:"backend" protobuf:"bytes,2,opt,name=backend"`
183}
184
185// IngressBackend describes all endpoints for a given service and port.
186type IngressBackend struct {
187 // Specifies the name of the referenced service.
188 ServiceName string `json:"serviceName" protobuf:"bytes,1,opt,name=serviceName"`
189
190 // Specifies the port of the referenced service.
191 ServicePort intstr.IntOrString `json:"servicePort" protobuf:"bytes,2,opt,name=servicePort"`
192}