Skip to content

noderesources: exempt annotated pods from max-pod-count cap#142

Draft
eakman-datadog wants to merge 9 commits into
v1.34.9-ddfrom
ea/max-pod-count-exemption-v1.34
Draft

noderesources: exempt annotated pods from max-pod-count cap#142
eakman-datadog wants to merge 9 commits into
v1.34.9-ddfrom
ea/max-pod-count-exemption-v1.34

Conversation

@eakman-datadog

@eakman-datadog eakman-datadog commented Jul 1, 2026

Copy link
Copy Markdown

Datadog: NOT FROM UPSTREAM K8s.

The purpose of this draft PR is to display testing evidence for a custom patch on 1.34 I'm working on.

I tested the PR using kind

Get the current number of pods on the kind node and fill it to the max with filler pods

➜  kubernetes git:(ea/max-pod-count-exemption-v1.34) ✗ CURRENT=$(kubectl get pods -A --field-selector spec.nodeName=pod-exemption-worker --no-headers | wc -l | tr -d ' ')
➜  kubernetes git:(ea/max-pod-count-exemption-v1.34) ✗ REPLICAS=$((10 - CURRENT))
➜  kubernetes git:(ea/max-pod-count-exemption-v1.34) ✗ kubectl apply -f - <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
  name: filler
spec:
  replicas: $REPLICAS
  selector:
    matchLabels:
      app: filler
  template:
    metadata:
      labels:
        app: filler
    spec:
      nodeSelector:
        kubernetes.io/hostname: pod-exemption-worker
      tolerations:
        - operator: Exists
      containers:
        - name: pause
          image: registry.k8s.io/pause:3.9
          resources:
            requests:
              cpu: 1m
              memory: 1Mi
EOF
deployment.apps/filler created
➜  kubernetes git:(ea/max-pod-count-exemption-v1.34) ✗ kubectl rollout status deployment/filler --timeout=60s
deployment "filler" successfully rolled out

Test that non-exempt pods are not scheduled

➜  kubernetes git:(ea/max-pod-count-exemption-v1.34) ✗ kubectl run canary --image=registry.k8s.io/pause:3.9 \
  --overrides='{"spec":{"nodeSelector":{"kubernetes.io/hostname":"pod-exemption-worker"}}}'
pod/canary created
➜  kubernetes git:(ea/max-pod-count-exemption-v1.34) ✗ kubectl describe pod canary | grep -A5 Events
Events:
  Type     Reason            Age   From               Message
  ----     ------            ----  ----               -------
  Warning  FailedScheduling  10s   default-scheduler  0/2 nodes are available: 1 Too many pods, 1 node(s) had untolerated taint(s). no new claims to deallocate, preemption: 0/2 nodes are available: 1 No preemption victims found for incoming pod, 1 Preemption is not helpful for scheduling.
➜  kubernetes git:(ea/max-pod-count-exemption-v1.34) ✗ k delete pod canary
pod "canary" deleted from default namespace

Test that exempt pods get scheduled

➜  kubernetes git:(ea/max-pod-count-exemption-v1.34) ✗ kubectl apply -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
  name: exempt
  annotations:
    kubelet.datadoghq.com/exclude-from-max-pods: "true"
spec:
  hostNetwork: true
  nodeSelector:
    kubernetes.io/hostname: pod-exemption-worker
  containers:
    - name: pause
      image: registry.k8s.io/pause:3.9
EOF
pod/exempt created
➜  kubernetes git:(ea/max-pod-count-exemption-v1.34) ✗ kubectl wait pod/exempt --for=condition=Ready --timeout=30s
pod/exempt condition met
➜  kubernetes git:(ea/max-pod-count-exemption-v1.34) ✗ k get pod exempt -o wide
NAME     READY   STATUS    RESTARTS   AGE   IP           NODE                   NOMINATED NODE   READINESS GATES
exempt   1/1     Running   0          24s   172.18.0.3   pod-exemption-worker   <none>           <none>

nyodas and others added 9 commits June 24, 2026 10:05
Datadog: **NOT FROM UPSTREAM K8S**. From Lyft: lyft@266a18a

This commit is the combination of multiple commits we've done to cherry pick and bring lyft sidecars across the ages.

datadog:patch
Origin: lyft@266a18a
Drop-After: never (Datadog-maintained Lyft sidecar support)
datadog:patch
Origin: #87
Drop-After: never (Datadog-specific flowcontrol fix)
This should allow build to have fips crypto enabled when we build with CGO_ENABLED=1

datadog:patch
Origin: Datadog internal
Drop-After: never (Datadog FIPS/boringcrypto build requirement)
…IgnoredDuringExecution

Signed-off-by: xyz-li <hui0787411@163.com>

datadog:patch
Origin: kubernetes#129315 (closed, never merged)
Drop-After: never (upstream PR closed without merge)
Origin: #98
Drop-After: never (Datadog-specific resourcequota behavior)
datadog:patch
Upstream-PR: kubernetes#133654
Drop-After: v1.36.0 (expected merge in 1.36)
When a token's kid is absent from the cached JWKS, go-oidc v2 only
refetches if the HTTP cache TTL has expired. EKS sets max-age=604800
(7 days), so new signing keys added by AWS within that window are
never picked up, causing CCM and other workloads whose tokens are
signed with the new key to fail with "failed to verify id token
signature" until the apiserver is restarted.

Fix: discard the cache-TTL guard in verify(). If a kid is not found
in the local cache, always attempt a remote fetch. Subsequent tokens
signed with cached (old) keys continue to verify without a network
roundtrip; only an unknown kid triggers a refetch.

datadog:patch
Origin: coreos/go-oidc#259
Drop-After: kubernetes#134454
Built on top of the GBI Ubuntu base image:
registry.ddbuild.io/images/base/gbi-ubuntu_2404:release@sha256:de9ff286f1a8bde796fc2b4afde9134079d74d90abe8b7b615212838e8fc01fd
Datadog: **NOT FROM UPSTREAM K8s**.

Adds a pod-count exemption for pods carrying the annotation
kubelet.datadoghq.com/exclude-from-max-pods="true" (literal value,
case-sensitive, fail-closed). To be exempt the pod must also be host networked.
Exempt pods bypass the v1.ResourcePods / Allocatable.Pods check in fitsRequest
but are subject to all other scheduler and kubelet admission checks unchanged.

The exemption is resolved once at PreFilter time via isExcludedFromMaxPodCount
(pod_count_exemption.go) and flows through the shared AdmissionCheck seam,
so both the scheduler filter path and the kubelet admission path honour it
without a kubelet-specific branch.

datadog:patch
@datadog-official

datadog-official Bot commented Jul 1, 2026

Copy link
Copy Markdown

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

DataDog/kubernetes | goreleaser-snapshot   View in Datadog   GitLab

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: bd3f76b | Docs | Datadog PR Page | Give us feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants