Skip to content

Commit 69811e7

Browse files
mattmoorknative-prow-robot
authored andcommitted
Implement Targetable. (knative#2068)
* Implement Targetable. This makes us stop populating LegacyTargetable and start populating Targetable. * Preserve .status.domainInternal for now.
1 parent efb015a commit 69811e7

17 files changed

+784
-81
lines changed

Gopkg.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ required = [
3434
[[constraint]]
3535
name = "github.com/knative/pkg"
3636
# HEAD as of 2018-09-20
37-
revision = "a133825579436877df315e7cb6d8aeba49b9f575"
37+
revision = "51f6214feeea1485dc8691a661d953fea1409402"
3838

3939
[[constraint]]
4040
name = "github.com/knative/caching"

docs/spec/spec.md

+14-6
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,13 @@ status:
7878
# along with a cluster-specific prefix (here, mydomain.com).
7979
domain: my-service.default.mydomain.com
8080

81-
# domainInternal: A DNS name for the default (traffic-split) route which can
82-
# be accessed without leaving the cluster environment.
83-
domainInternal: my-service.default.svc.cluster.local
81+
targetable: # knative/pkg/apis/duck/v1alpha1.Targetable
82+
# domainInternal: A DNS name for the default (traffic-split) route which can
83+
# be accessed without leaving the cluster environment.
84+
domainInternal: my-service.default.svc.cluster.local
85+
86+
# DEPRECATED: see targetable.domainInternal (above)
87+
domainInternal: ...
8488

8589
traffic:
8690
# current rollout status list. configurationName references
@@ -390,9 +394,13 @@ status:
390394
# along with a cluster-specific prefix (here, mydomain.com).
391395
domain: myservice.default.mydomain.com
392396

393-
# domainInternal: A DNS name for the default (traffic-split) route which can
394-
# be accessed without leaving the cluster environment.
395-
domainInternal: myservice.default.svc.cluster.local
397+
targetable: # knative/pkg/apis/duck/v1alpha1.Targetable
398+
# domainInternal: A DNS name for the default (traffic-split) route which can
399+
# be accessed without leaving the cluster environment.
400+
domainInternal: myservice.default.svc.cluster.local
401+
402+
# DEPRECATED: see targetable.domainInternal (above)
403+
domainInternal: ...
396404

397405
# current rollout status list. configurationName references
398406
# are dereferenced to latest revision

pkg/apis/serving/v1alpha1/route_types.go

+9
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ var _ kmeta.OwnerRefable = (*Route)(nil)
5959
// Check that Route implements the Conditions duck type.
6060
var _ = duck.VerifyType(&Route{}, &duckv1alpha1.Conditions{})
6161

62+
// Check that Route implements the [Legacy]Targetable duck type.
63+
var _ = duck.VerifyType(&Route{}, &duckv1alpha1.LegacyTargetable{})
64+
var _ = duck.VerifyType(&Route{}, &duckv1alpha1.Targetable{})
65+
6266
// Check that Route implements the Generation duck type.
6367
var emptyGenRoute duckv1alpha1.Generation
6468
var _ = duck.VerifyType(&Route{}, &emptyGenRoute)
@@ -129,9 +133,14 @@ type RouteStatus struct {
129133
// DomainInternal holds the top-level domain that will distribute traffic over the provided
130134
// targets from inside the cluster. It generally has the form
131135
// {route-name}.{route-namespace}.svc.cluster.local
136+
// DEPRECATED: Use Targetable instead.
132137
// +optional
133138
DomainInternal string `json:"domainInternal,omitempty"`
134139

140+
// Targetable holds the information needed for a Route to be the target of an event.
141+
// +optional
142+
Targetable *duckv1alpha1.Targetable `json:"targetable,omitempty"`
143+
135144
// Traffic holds the configured traffic distribution.
136145
// These entries will always contain RevisionName references.
137146
// When ConfigurationName appears in the spec, this will hold the

pkg/apis/serving/v1alpha1/service_types.go

+10
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ var _ duckv1alpha1.ConditionsAccessor = (*ServiceStatus)(nil)
6565
// Check that Service implements the Conditions duck type.
6666
var _ = duck.VerifyType(&Service{}, &duckv1alpha1.Conditions{})
6767

68+
// Check that Route implements the [Legacy]Targetable duck type.
69+
var _ = duck.VerifyType(&Service{}, &duckv1alpha1.LegacyTargetable{})
70+
var _ = duck.VerifyType(&Service{}, &duckv1alpha1.Targetable{})
71+
6872
// Check that Service implements the Generation duck type.
6973
var emptyGenService duckv1alpha1.Generation
7074
var _ = duck.VerifyType(&Service{}, &emptyGenService)
@@ -139,9 +143,14 @@ type ServiceStatus struct {
139143
// DomainInternal holds the top-level domain that will distribute traffic over the provided
140144
// targets from inside the cluster. It generally has the form
141145
// {route-name}.{route-namespace}.svc.cluster.local
146+
// DEPRECATED: Use Targetable instead.
142147
// +optional
143148
DomainInternal string `json:"domainInternal,omitempty"`
144149

150+
// Targetable holds the information needed for a Route to be the target of an event.
151+
// +optional
152+
Targetable *duckv1alpha1.Targetable `json:"targetable,omitempty"`
153+
145154
// From RouteStatus.
146155
// Traffic holds the configured traffic distribution.
147156
// These entries will always contain RevisionName references.
@@ -215,6 +224,7 @@ func (ss *ServiceStatus) PropagateConfigurationStatus(cs ConfigurationStatus) {
215224
func (ss *ServiceStatus) PropagateRouteStatus(rs RouteStatus) {
216225
ss.Domain = rs.Domain
217226
ss.DomainInternal = rs.DomainInternal
227+
ss.Targetable = rs.Targetable
218228
ss.Traffic = rs.Traffic
219229

220230
rc := rs.GetCondition(RouteConditionReady)

pkg/apis/serving/v1alpha1/zz_generated.deepcopy.go

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/reconciler/v1alpha1/route/reconcile_resources.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"k8s.io/apimachinery/pkg/api/equality"
2828
apierrs "k8s.io/apimachinery/pkg/api/errors"
2929

30+
duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1"
3031
"github.com/knative/serving/pkg/apis/serving/v1alpha1"
3132
"github.com/knative/serving/pkg/reconciler/v1alpha1/route/resources"
3233
resourcenames "github.com/knative/serving/pkg/reconciler/v1alpha1/route/resources/names"
@@ -98,8 +99,11 @@ func (c *Reconciler) reconcilePlaceholderService(ctx context.Context, route *v1a
9899
}
99100
}
100101
}
101-
// Update the route's domain internal field
102+
// Update the information that makes us Targetable.
102103
route.Status.DomainInternal = resourcenames.K8sServiceFullname(route)
104+
route.Status.Targetable = &duckv1alpha1.Targetable{
105+
DomainInternal: resourcenames.K8sServiceFullname(route),
106+
}
103107

104108
// TODO(mattmoor): This is where we'd look at the state of the Service and
105109
// reflect any necessary state into the Route.

0 commit comments

Comments
 (0)