Skip to content

Commit

Permalink
Allow setting service topology aware routing mode
Browse files Browse the repository at this point in the history
  • Loading branch information
domgoodwin committed Jan 19, 2024
1 parent 59c4401 commit a71b276
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,4 @@ spec:
| POD_TOPOLOGY_ZONE_MAX_SKEW | Empty, won't inject a zone constraint | Value of maxSkew for the zone constraint |
| POD_TOPOLOGY_HOSTNAME_MAX_SKEW_KEY | `kubernetes.io/hostname` | Topology key for the hostname constraint |
| POD_TOPOLOGY_HOSTNAME_MAX_SKEW | Empty, won't inject a hostname constraint | Value of maxSkew for the hostname constraint |

| SERVICE_TOPOLOGY_MODE | Empty, won't add the annotation | Value to set for topology-mode service annotation |
12 changes: 10 additions & 2 deletions controllers/externalservice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ package controllers
import (
"bytes"
"context"
"os"

"github.com/go-logr/logr"
egressv1 "github.com/monzo/egress-operator/api/v1"
appsv1 "k8s.io/api/apps/v1"
autoscalingv1 "k8s.io/api/autoscaling/v1"
corev1 "k8s.io/api/core/v1"
Expand All @@ -29,6 +29,8 @@ import (
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

egressv1 "github.com/monzo/egress-operator/api/v1"
)

const namespace = "egress-operator-system"
Expand Down Expand Up @@ -106,9 +108,15 @@ func labels(es *egressv1.ExternalService) map[string]string {
}

func annotations(es *egressv1.ExternalService) map[string]string {
return map[string]string{
annotations := map[string]string{
"egress.monzo.com/dns-name": es.Spec.DnsName,
}
// Allow setting the topology aware routing annotation
value, ok := os.LookupEnv("SERVICE_TOPOLOGY_MODE")
if ok && value != "" {
annotations["service.kubernetes.io/topology-mode"] = value
}
return annotations
}

func labelsToSelect(es *egressv1.ExternalService) map[string]string {
Expand Down

0 comments on commit a71b276

Please sign in to comment.