/
route_types.go
163 lines (131 loc) · 5.89 KB
/
route_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
Copyright 2018 The Knative Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"
duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1"
"knative.dev/pkg/kmeta"
v1 "knative.dev/serving/pkg/apis/serving/v1"
)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Route is responsible for configuring ingress over a collection of Revisions.
// Some of the Revisions a Route distributes traffic over may be specified by
// referencing the Configuration responsible for creating them; in these cases
// the Route is additionally responsible for monitoring the Configuration for
// "latest ready" revision changes, and smoothly rolling out latest revisions.
// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#route
type Route struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// Spec holds the desired state of the Route (from the client).
// +optional
Spec RouteSpec `json:"spec,omitempty"`
// Status communicates the observed state of the Route (from the controller).
// +optional
Status RouteStatus `json:"status,omitempty"`
}
// Verify that Route adheres to the appropriate interfaces.
var (
// Check that Route may be validated and defaulted.
_ apis.Validatable = (*Route)(nil)
_ apis.Defaultable = (*Route)(nil)
// Check that Route can be converted to higher versions.
_ apis.Convertible = (*Route)(nil)
// Check that we can create OwnerReferences to a Route.
_ kmeta.OwnerRefable = (*Route)(nil)
)
// TrafficTarget holds a single entry of the routing table for a Route.
type TrafficTarget struct {
// Name is optionally used to expose a dedicated hostname for referencing this
// target exclusively. It has the form: {name}.${route.status.domain}
// +optional
DeprecatedName string `json:"name,omitempty"`
// We inherit most of our fields by inlining the v1 type.
// Ultimately all non-v1 fields will be deprecated.
v1.TrafficTarget `json:",inline"`
}
// RouteSpec holds the desired state of the Route (from the client).
type RouteSpec struct {
// DeprecatedGeneration was used prior in Kubernetes versions <1.11
// when metadata.generation was not being incremented by the api server
//
// This property will be dropped in future Knative releases and should
// not be used - use metadata.generation
//
// Tracking issue: https://github.com/knative/serving/issues/643
//
// +optional
DeprecatedGeneration int64 `json:"generation,omitempty"`
// Traffic specifies how to distribute traffic over a collection of Knative Serving Revisions and Configurations.
// +optional
Traffic []TrafficTarget `json:"traffic,omitempty"`
}
const (
// RouteConditionReady is set when the service is configured
// and has available backends ready to receive traffic.
RouteConditionReady = apis.ConditionReady
// RouteConditionAllTrafficAssigned is set to False when the
// service is not configured properly or has no available
// backends ready to receive traffic.
RouteConditionAllTrafficAssigned apis.ConditionType = "AllTrafficAssigned"
// RouteConditionIngressReady is set to False when the
// Ingress fails to become Ready.
RouteConditionIngressReady apis.ConditionType = "IngressReady"
// RouteConditionCertificateProvisioned is set to False when the
// Knative Certificates fail to be provisioned for the Route.
RouteConditionCertificateProvisioned apis.ConditionType = "CertificateProvisioned"
)
// RouteStatusFields holds all of the non-duckv1.Status status fields of a Route.
// These are defined outline so that we can also inline them into Service, and more easily
// copy them.
type RouteStatusFields struct {
// URL holds the url that will distribute traffic over the provided traffic targets.
// It generally has the form http[s]://{route-name}.{route-namespace}.{cluster-level-suffix}
// +optional
URL *apis.URL `json:"url,omitempty"`
// DeprecatedDomain holds the top-level domain that will distribute traffic over the provided targets.
// It generally has the form {route-name}.{route-namespace}.{cluster-level-suffix}
// +optional
DeprecatedDomain string `json:"domain,omitempty"`
// DeprecatedDomainInternal holds the top-level domain that will distribute traffic over the provided
// targets from inside the cluster. It generally has the form
// {route-name}.{route-namespace}.svc.{cluster-domain-name}
// DEPRECATED: Use Address instead.
// +optional
DeprecatedDomainInternal string `json:"domainInternal,omitempty"`
// Address holds the information needed for a Route to be the target of an event.
// +optional
Address *duckv1alpha1.Addressable `json:"address,omitempty"`
// Traffic holds the configured traffic distribution.
// These entries will always contain RevisionName references.
// When ConfigurationName appears in the spec, this will hold the
// LatestReadyRevisionName that we last observed.
// +optional
Traffic []TrafficTarget `json:"traffic,omitempty"`
}
// RouteStatus communicates the observed state of the Route (from the controller).
type RouteStatus struct {
duckv1.Status `json:",inline"`
RouteStatusFields `json:",inline"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// RouteList is a list of Route resources
type RouteList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Route `json:"items"`
}