Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add way to config when unsatisfiable for topology spread #38

Merged
merged 1 commit into from
Jan 4, 2024
Merged
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
12 changes: 10 additions & 2 deletions controllers/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func deployment(es *egressv1.ExternalService, configHash string) *appsv1.Deploym
if topologyEnable == "true" {
zoneSkew, zoneEnabled := os.LookupEnv("POD_TOPOLOGY_ZONE_MAX_SKEW")
zoneKey, zoneKeyFound := os.LookupEnv("POD_TOPOLOGY_ZONE_MAX_SKEW_KEY")
zoneWhenUnsatisfiable, zoneWhenUnsatisfiableFound := os.LookupEnv("POD_TOPOLOGY_ZONE_WHEN_UNSATISFIABLE")
if zoneEnabled {
maxSkew, err := strconv.Atoi(zoneSkew)
if err != nil {
Expand All @@ -107,15 +108,19 @@ func deployment(es *egressv1.ExternalService, configHash string) *appsv1.Deploym
if !zoneKeyFound {
zoneKey = "topology.kubernetes.io/zone"
}
if !zoneWhenUnsatisfiableFound {
zoneWhenUnsatisfiable = string(corev1.ScheduleAnyway)
}
podTopologySpread = append(podTopologySpread, corev1.TopologySpreadConstraint{
TopologyKey: zoneKey,
WhenUnsatisfiable: corev1.ScheduleAnyway,
WhenUnsatisfiable: corev1.UnsatisfiableConstraintAction(zoneWhenUnsatisfiable),
MaxSkew: int32(maxSkew),
LabelSelector: labelSelector,
})
}
hostnameSkew, hostnameEnabled := os.LookupEnv("POD_TOPOLOGY_HOSTNAME_MAX_SKEW")
hostnameKey, hostnameKeyFound := os.LookupEnv("POD_TOPOLOGY_HOSTNAME_MAX_SKEW_KEY")
hostnameWhenUnsatisfiable, hostnameWhenUnsatisfiableFound := os.LookupEnv("POD_TOPOLOGY_HOSTNAME_WHEN_UNSATISFIABLE")
if hostnameEnabled {
maxSkew, err := strconv.Atoi(hostnameSkew)
if err != nil {
Expand All @@ -125,9 +130,12 @@ func deployment(es *egressv1.ExternalService, configHash string) *appsv1.Deploym
if !hostnameKeyFound {
hostnameKey = "kubernetes.io/hostname"
}
if !hostnameWhenUnsatisfiableFound {
hostnameWhenUnsatisfiable = string(corev1.ScheduleAnyway)
}
podTopologySpread = append(podTopologySpread, corev1.TopologySpreadConstraint{
TopologyKey: hostnameKey,
WhenUnsatisfiable: corev1.ScheduleAnyway,
WhenUnsatisfiable: corev1.UnsatisfiableConstraintAction(hostnameWhenUnsatisfiable),
MaxSkew: int32(maxSkew),
LabelSelector: labelSelector,
})
Expand Down
Loading