Skip to content

Commit 496ac78

Browse files
authored
feat(supervisor): optional ndots override for runner pods (#3441)
Adds `KUBERNETES_POD_DNS_NDOTS_OVERRIDE_ENABLED` flag (off by default) that overrides the cluster default and sets `dnsConfig.options.ndots` on runner pods (defaulting to 2, configurable via `KUBERNETES_POD_DNS_NDOTS`). Kubernetes defaults pods to `ndots: 5`, so any name with fewer than 5 dots, including typical external domains like `api.example.com`, is first walked through every entry in the cluster search list (`<ns>.svc.cluster.local`, `svc.cluster.local`, `cluster.local`) before being tried as-is, turning one resolution into 4+ CoreDNS queries (×2 with A+AAAA). Using a lower `ndots` value reduces DNS query amplification in the `cluster.local` zone.
1 parent f7aefb7 commit 496ac78

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
area: supervisor
3+
type: feature
4+
---
5+
6+
Add `KUBERNETES_POD_DNS_NDOTS_OVERRIDE_ENABLED` flag (off by default) that overrides the cluster default and sets `dnsConfig.options.ndots` on runner pods (defaulting to 2, configurable via `KUBERNETES_POD_DNS_NDOTS`). Kubernetes defaults pods to `ndots: 5`, so any name with fewer than 5 dots — including typical external domains like `api.example.com` — is first walked through every entry in the cluster search list (`<ns>.svc.cluster.local`, `svc.cluster.local`, `cluster.local`) before being tried as-is, turning one resolution into 4+ CoreDNS queries (×2 with A+AAAA). Using a lower `ndots` value reduces DNS query amplification in the `cluster.local` zone.
7+
8+
Note: before enabling, make sure no code path relies on search-list expansion for names with dots ≥ the configured value — those names will hit their as-is form first and could resolve externally before falling back to the cluster search path.

apps/supervisor/src/env.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@ const Env = z
121121

122122
KUBERNETES_MEMORY_OVERHEAD_GB: z.coerce.number().min(0).optional(), // Optional memory overhead to add to the limit in GB
123123
KUBERNETES_SCHEDULER_NAME: z.string().optional(), // Custom scheduler name for pods
124+
125+
// Pod DNS config — override the cluster default ndots to `KUBERNETES_POD_DNS_NDOTS`.
126+
// Default k8s ndots is 5: any name with fewer than 5 dots (e.g. `api.example.com`, 2 dots) is first walked
127+
// through every entry in the cluster search list (`<ns>.svc.cluster.local`, `svc.cluster.local`, `cluster.local`)
128+
// before being tried as-is, turning one resolution into 4+ CoreDNS queries (×2 with A+AAAA).
129+
// Overriding the default can be useful to cut CoreDNS query amplification for external domains.
130+
// Note: before enabling, make sure no code path relies on search-list expansion for names with dots ≥ the value
131+
// set here — those names will now hit their as-is form first and could resolve externally before falling back.
132+
KUBERNETES_POD_DNS_NDOTS_OVERRIDE_ENABLED: BoolEnv.default(false),
133+
KUBERNETES_POD_DNS_NDOTS: z.coerce.number().int().min(1).max(15).default(2),
124134
// Large machine affinity settings - large-* presets prefer a dedicated pool
125135
KUBERNETES_LARGE_MACHINE_AFFINITY_ENABLED: BoolEnv.default(false),
126136
KUBERNETES_LARGE_MACHINE_AFFINITY_POOL_LABEL_KEY: z
@@ -189,7 +199,9 @@ const Env = z
189199
if (!validEffects.includes(effect)) {
190200
ctx.addIssue({
191201
code: z.ZodIssueCode.custom,
192-
message: `Invalid toleration effect "${effect}" in "${entry}". Must be one of: ${validEffects.join(", ")}`,
202+
message: `Invalid toleration effect "${effect}" in "${entry}". Must be one of: ${validEffects.join(
203+
", "
204+
)}`,
193205
});
194206
return z.NEVER;
195207
}

apps/supervisor/src/workloadManager/kubernetes.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,13 @@ export class KubernetesWorkloadManager implements WorkloadManager {
321321
},
322322
}
323323
: {}),
324+
...(env.KUBERNETES_POD_DNS_NDOTS_OVERRIDE_ENABLED
325+
? {
326+
dnsConfig: {
327+
options: [{ name: "ndots", value: `${env.KUBERNETES_POD_DNS_NDOTS}` }],
328+
},
329+
}
330+
: {}),
324331
};
325332
}
326333

0 commit comments

Comments
 (0)