Skip to content
Merged
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
2 changes: 2 additions & 0 deletions api/types/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,8 @@ const (
DiscoveryAppInsecureSkipVerify = TeleportNamespace + "/insecure-skip-verify"
// DiscoveryAppIgnore specifies if a Kubernetes service should be ignored by discovery service.
DiscoveryAppIgnore = TeleportNamespace + "/ignore"
// DiscoveryPublicAddr specifies the public address for a discovered app created from a Kubernetes service.
DiscoveryPublicAddr = TeleportNamespace + "/public-addr"

// ReqAnnotationApproveSchedulesLabel is the request annotation key at which schedules are stored for access plugins.
ReqAnnotationApproveSchedulesLabel = "/schedules"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,11 @@ annotations:
value: "Bearer {{internal.jwt}}"
```

### `teleport.dev/public-addr`

Controls the public address for the Teleport app we create if needed.

```yaml
annotations:
teleport.dev/public-addr: "custom.teleport.dev"
```
5 changes: 5 additions & 0 deletions lib/services/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func NewApplicationFromKubeService(service corev1.Service, clusterName, protocol
URI: appURI,
Rewrite: rewriteConfig,
InsecureSkipVerify: getTLSInsecureSkipVerify(service.GetAnnotations()),
PublicAddr: getPublicAddr(service.GetAnnotations()),
})
if err != nil {
return nil, trace.Wrap(err, "could not create an app from Kubernetes service")
Expand Down Expand Up @@ -239,6 +240,10 @@ func getAppRewriteConfig(annotations map[string]string) (*types.Rewrite, error)
return &rw, nil
}

func getPublicAddr(annotations map[string]string) string {
return annotations[types.DiscoveryPublicAddr]
}

func getTLSInsecureSkipVerify(annotations map[string]string) bool {
val := annotations[types.DiscoveryAppInsecureSkipVerify]
if val == "" {
Expand Down
4 changes: 3 additions & 1 deletion lib/srv/discovery/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ func TestDiscoveryKubeServices(t *testing.T) {

appProtocolHTTP := "http"
mockKubeServices := []*corev1.Service{
newMockKubeService("service1", "ns1", "", map[string]string{"test-label": "testval"}, nil,
newMockKubeService("service1", "ns1", "", map[string]string{"test-label": "testval"}, map[string]string{types.DiscoveryPublicAddr: "custom.example.com"},
[]corev1.ServicePort{{Port: 42, Name: "http", Protocol: corev1.ProtocolTCP}}),
newMockKubeService("service2", "ns2", "", map[string]string{
"test-label": "testval",
Expand Down Expand Up @@ -1580,6 +1580,8 @@ func mustConvertKubeServiceToApp(t *testing.T, discoveryGroup, protocol string,
port.Name = ""
app, err := services.NewApplicationFromKubeService(*kubeService, discoveryGroup, protocol, port)
require.NoError(t, err)
require.Equal(t, kubeService.Annotations[types.DiscoveryPublicAddr], app.GetPublicAddr())

app.GetStaticLabels()[types.TeleportInternalDiscoveryGroupName] = discoveryGroup
app.GetStaticLabels()[types.OriginLabel] = types.OriginDiscoveryKubernetes
return app
Expand Down