Skip to content

Add k8s test: init container can reach HTTPS endpoints (CA trust store)#7239

Open
knusbaum wants to merge 3 commits into
mainfrom
knusbaum/k8s-init-https-cert-test
Open

Add k8s test: init container can reach HTTPS endpoints (CA trust store)#7239
knusbaum wants to merge 3 commits into
mainfrom
knusbaum/k8s-init-https-cert-test

Conversation

@knusbaum

Copy link
Copy Markdown
Contributor

Motivation

Adds a k8s_lib_injection test asserting the init container can complete a TLS-verified HTTPS request — i.e. the image ships a working CA trust store. Init images carry CA certs so admission-controller wrappers that dial HTTPS from inside the init container (e.g. bank-vaults' vault-env) keep working.

There was no coverage for this. It becomes important now because DataDog/libdatadog-build#235 moves the dd-lib-*-init images off busybox to a FROM scratch + statically-linked dash/toybox/curl base — the kind of base change where a cert store can silently regress. This test guards against that.

What it does

  • New helper run_https_probe_pod() (tests/k8s_lib_injection/utils.py): runs a one-shot pod from the init image doing curl -fsS https://app.datadoghq.com (verification on, no -k), waits for the pod phase, and always cleans the pod up.
  • New test TestK8sLibInjection::test_k8s_init_container_https_egress: asserts the probe pod reaches Succeeded. A missing/invalid CA store makes curl exit non-zero → pod Failed → test fails.

The test is fully isolated (its own throwaway pod, separate test_* method) so a cert regression fails only this test, not the injection/traces assertions. It reuses the existing scenarios + @features.k8s_admission_controller; no manifest changes.

How this was tested

  • Verified the same probe manually against the toybox+dash init image built by libdatadog-build#235's CI (registry.ddbuild.io/ssi/dd-lib-js-init:<sha>): curl https://… → HTTP 200, ssl_verify_result=0, CAfile /etc/ssl/certs/ca-certificates.crt.
  • Both edited files parse; hand-formatted to the repo ruff style (could not run ./format.sh in this environment — CI --check will confirm).

Companion to DataDog/libdatadog-build#235 (init images busybox -> scratch +
dash/toybox/curl). Asserts the init image can complete a TLS-verified HTTPS
request via a throwaway probe pod, guarding the CA trust store against
regression on the base-image change.
@knusbaum knusbaum requested a review from a team as a code owner June 30, 2026 16:30
@github-actions

Copy link
Copy Markdown
Contributor

CODEOWNERS have been resolved as:

tests/k8s_lib_injection/test_k8s_lib_injection.py                       @DataDog/injection-platform
tests/k8s_lib_injection/utils.py                                        @DataDog/injection-platform

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jun 30, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

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

knusbaum added 2 commits June 30, 2026 12:33
context.scenario is typed as the base Scenario; access the init image through a
helper that asserts isinstance(K8sScenario) (mirrors get_cluster_info's narrowing).
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.

1 participant