Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions config/config-domain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ metadata:
namespace: knative-serving
data:
# These are example settings of domain.
# example.org will be used for routes having app=prod.
# example.org: |
# example.com will be used for routes having app=external.
# example.com: |
# selector:
# app: prod
# app: external

# Default value for domain, for routes that does not have app=prod labels.
# Although it will match all routes, it is the least-specific rule so it
# will only be used if no other domain matches.
example.com: |
# This is the default value for domain, for routes that does not have
# app=external labels. This is the least-specific rule and acts as a default.
# The 'svc.cluster.local' default provides a DNS name which works inside the
# cluster. If you want your cluster to be public, you'll need to follow the
# instructions here:
# https://github.com/knative/docs/blob/master/serving/using-a-custom-domain.md#publish-your-domain
svc.cluster.local: |
6 changes: 2 additions & 4 deletions pkg/controller/route/resources/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ func MakeK8sService(route *v1alpha1.Route) *corev1.Service {
},
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{{
Name: PortName,
Port: PortNumber,
}},
Type: corev1.ServiceTypeExternalName,
ExternalName: "knative-ingressgateway.istio-system.svc.cluster.local",
},
}
}
6 changes: 4 additions & 2 deletions pkg/controller/route/resources/virtual_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ func makeVirtualServiceSpec(u *v1alpha1.Route, targets map[string][]traffic.Revi
// Traffic originates from outside of the cluster would be of the form "*.domain", or "domain"
fmt.Sprintf("*.%s", domain),
domain,
// Traffic from inside the cluster will use the FQDN of the Route's headless Service.
names.K8sServiceFullname(u),
},
}
if domain != names.K8sServiceFullname(u) {
// Add a local alias for the k8s Service in the svc.cluster.local DNS space.
spec.Hosts = append(spec.Hosts, names.K8sServiceFullname(u))
}
names := []string{}
for name := range targets {
names = append(names, name)
Expand Down