Skip to content
This repository was archived by the owner on Jan 27, 2021. It is now read-only.

Commit 17f760c

Browse files
vbeharkrancour
authored andcommitted
Support short DNS names (#41)
for the moment, Osiris only supports fully qualified DNS: `name.namespace.svc.cluster.local` But services can also be accessed using a "short" DNS: `name.namespace` This PR adds support for activating a deployment when a request comes with a "short" name
1 parent 472cbec commit 17f760c

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

pkg/deployments/activator/index.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ func (a *activator) updateIndex() {
2020
for _, svc := range a.services {
2121
if deploymentName, ok :=
2222
svc.Annotations["osiris.deislabs.io/deployment"]; ok {
23-
svcDNSName :=
24-
fmt.Sprintf("%s.%s.svc.cluster.local", svc.Name, svc.Namespace)
23+
svcShortDNSName := fmt.Sprintf("%s.%s", svc.Name, svc.Namespace)
24+
svcFullDNSName := fmt.Sprintf("%s.svc.cluster.local", svcShortDNSName)
2525
// Determine the "default" ingress port. When a request arrives at the
2626
// activator via an ingress conroller, the request's host header won't
2727
// indicate a port. After activation is complete, the activator needs to
@@ -98,8 +98,9 @@ func (a *activator) updateIndex() {
9898
}
9999
// If the port is 80, also index by hostname/IP sans port number...
100100
if port.Port == 80 {
101-
// kube-dns name
102-
appsByHost[svcDNSName] = app
101+
// kube-dns names
102+
appsByHost[svcShortDNSName] = app
103+
appsByHost[svcFullDNSName] = app
103104
// cluster IP
104105
appsByHost[svc.Spec.ClusterIP] = app
105106
// external IPs
@@ -128,8 +129,9 @@ func (a *activator) updateIndex() {
128129
if fmt.Sprintf("%d", port.Port) == tlsDefaultPort {
129130
// Now index by hostname:tls. Note that there's no point in indexing
130131
// by IP:tls because SNI server name will never be an IP.
131-
// kube-dns name
132-
appsByHost[fmt.Sprintf("%s:tls", svcDNSName)] = app
132+
// kube-dns names
133+
appsByHost[fmt.Sprintf("%s:tls", svcShortDNSName)] = app
134+
appsByHost[fmt.Sprintf("%s:tls", svcFullDNSName)] = app
133135
// Honor all annotations of the form
134136
// ^osiris\.deislabs\.io/loadBalancerHostname(?:-\d+)?$
135137
for k, v := range svc.Annotations {
@@ -139,8 +141,9 @@ func (a *activator) updateIndex() {
139141
}
140142
}
141143
// Now index by hostname/IP:port...
142-
// kube-dns name
143-
appsByHost[fmt.Sprintf("%s:%d", svcDNSName, port.Port)] = app
144+
// kube-dns names
145+
appsByHost[fmt.Sprintf("%s:%d", svcShortDNSName, port.Port)] = app
146+
appsByHost[fmt.Sprintf("%s:%d", svcFullDNSName, port.Port)] = app
144147
// cluster IP
145148
appsByHost[fmt.Sprintf("%s:%d", svc.Spec.ClusterIP, port.Port)] = app
146149
// external IPs

0 commit comments

Comments
 (0)