# probe-sandboxed: the sandboxed probe. Identical to probe-standard in every field
# the measurement or the egress NetworkPolicy could depend on, differing only in the
# one line below.
#
#   runtimeClassName: isolated-sandbox
#
# That line makes the pod's containers run inside a Nitro sandbox of their own: a
# hardware-isolated lightweight VM with its own kernel. There is no node selector,
# toleration or sidecar: the RuntimeClass carries the scheduling constraints, and
# Auto Mode brings up a sandbox-capable node if none is available. The pod's DNS
# traffic leaves through the sandbox network path, which is where the per-sandbox
# query-rate limit sits, so this is the pod that reaches the limit.
apiVersion: v1
kind: Pod
metadata:
  name: probe-sandboxed
  namespace: sandbox-limits
  labels:
    app: dns-probe            # the SAME label the policy selects on probe-standard
  annotations:
    karpenter.sh/do-not-disrupt: "true"   # keep consolidation from evicting this bare pod mid-run
spec:
  runtimeClassName: isolated-sandbox   # <-- the only field that differs from probe-standard
  # Hardened to clear ASH/checkov CKV_K8S_20,22,23,28,29,30,31,37,38,40.
  # Identical on every probe pod and the sink, so it does not change the
  # one-line difference between the pods. The probe uses ordinary UDP/TCP
  # sockets and reads world-readable files only, so a non-root UID and
  # dropped capabilities do not change the measured limit.
  automountServiceAccountToken: false
  securityContext:
    runAsNonRoot: true
    runAsUser: 10001
    runAsGroup: 10001
    seccompProfile:
      type: RuntimeDefault
  containers:
    - name: probe
      image: public.ecr.aws/docker/library/python:3.12-slim
      imagePullPolicy: IfNotPresent
      securityContext:
        allowPrivilegeEscalation: false
        capabilities:
          drop: ["ALL"]
        readOnlyRootFilesystem: true
      volumeMounts:
        # readOnlyRootFilesystem needs a writable /tmp: the container does
        # `touch /tmp/ready` and the readiness probe `cat /tmp/ready`.
        - name: tmp
          mountPath: /tmp
      command: ["/bin/sh", "-c"]
      args:
        - |
          touch /tmp/ready
          exec sleep infinity
      readinessProbe:
        exec:
          command: ["cat", "/tmp/ready"]
        initialDelaySeconds: 2
        periodSeconds: 3
        failureThreshold: 40
      resources:
        requests:
          cpu: "1"
          memory: 768Mi
        limits:
          cpu: "1"
          memory: 768Mi
  volumes:
    - name: tmp
      emptyDir: {}
