Skip to content

Add Downward API volume fieldRef support for pod metadata files#530

Open
Copilot wants to merge 6 commits intomainfrom
copilot/add-downward-api-volume-support
Open

Add Downward API volume fieldRef support for pod metadata files#530
Copilot wants to merge 6 commits intomainfrom
copilot/add-downward-api-volume-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 9, 2026

InterLink already resolved Downward API fieldRef for env vars, but volume-based Downward API metadata files were incomplete. This PR extends volume handling so pods can mount metadata files from both projected and direct downwardAPI volumes with Kubernetes-standard field paths.

  • Downward API field path coverage

    • Added field resolution for volume items:
      • metadata.name, metadata.namespace, metadata.uid
      • metadata.labels, metadata.annotations
      • spec.nodeName, spec.serviceAccountName
      • status.podIP, status.hostIP
    • Kept unsupported selectors as non-fatal (logged and skipped), matching existing behavior.
  • Direct downwardAPI volume support

    • Added handling for volumes[].downwardAPI in remoteExecutionHandleVolumes (previously only projected sources were handled for this path).
    • Populates ProjectedVolumeMaps for downstream execution in the same way as other projected sources.
  • Deterministic metadata file rendering

    • Implemented stable serialization for metadata.labels / metadata.annotations as newline-delimited key="value" entries with sorted keys for deterministic output.
  • Targeted unit coverage

    • Added tests validating:
      • all newly supported fieldRef mappings for projected Downward API sources
      • end-to-end handling of direct downwardAPI volumes
volumes:
  - name: podinfo
    downwardAPI:
      items:
        - path: pod-name
          fieldRef: { fieldPath: metadata.name }
        - path: labels
          fieldRef: { fieldPath: metadata.labels }
        - path: annotations
          fieldRef: { fieldPath: metadata.annotations }

@netlify
Copy link
Copy Markdown

netlify Bot commented May 9, 2026

Deploy Preview for interlink-dev canceled.

Name Link
🔨 Latest commit 17ef1f1
🔍 Latest deploy log https://app.netlify.com/projects/interlink-dev/deploys/69ff6b2d051aca000822a2e9

Copilot AI changed the title [WIP] Add support for Downward API volumes Add Downward API volume fieldRef support for pod metadata files May 9, 2026
Copilot AI requested a review from dciangot May 9, 2026 10:00
@dciangot
Copy link
Copy Markdown
Member

dciangot commented May 9, 2026

@copilot lint action is failing

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 9, 2026

@copilot lint action is failing

Fixed. The lint failure was due to staticcheck QF1012 in formatDownwardAPIMetadataMap; I updated the string building to satisfy lint without changing behavior. Addressed in commit d379093.

@dciangot dciangot marked this pull request as ready for review May 9, 2026 17:05
Copilot AI review requested due to automatic review settings May 9, 2026 17:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends InterLink’s Downward API handling for volume-mounted metadata files by resolving additional fieldRef paths and adding support for direct volumes[].downwardAPI (not only projected sources). It also makes label/annotation rendering deterministic to avoid non-reproducible output from map iteration.

Changes:

  • Refactors Downward API volume item processing into shared helpers and adds support for more fieldRef paths (incl. labels/annotations, node/service account, pod/host IPs).
  • Adds handling for direct DownwardAPI volumes in remoteExecutionHandleVolumes by populating ProjectedVolumeMaps.
  • Adds unit tests covering the new field paths and the direct downwardAPI volume path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/virtualkubelet/execute.go Adds shared Downward API resolution helpers and new handling for direct DownwardAPI volumes.
pkg/virtualkubelet/execute_test.go Adds tests for the expanded fieldRef mapping and direct downwardAPI volumes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/virtualkubelet/execute.go
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Diego Ciangottini <diego.ciangottini@gmail.com>
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.

Add support for Downward API volumes (fieldRef in volume mounts)

3 participants