Skip to content

Unable to extract images if CRDs deconstruct image fields #24

Description

@james-mchugh

For charts with CRDs that deconstruct image fields, it is currently not possible to reconstruct the image using JSONPath.

For example, the nvidia gpu-operators chart includes ClusterPolicy resources with image fields:

apiVersion: nvidia.com/v1
kind: ClusterPolicy
metadata:
  name: cluster-policy
  labels:
    app.kubernetes.io/name: gpu-operator
    helm.sh/chart: gpu-operator-v26.3.2
    app.kubernetes.io/instance: release-name
    app.kubernetes.io/version: "v26.3.2"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: "gpu-operator"
spec:
  hostPaths:
    rootFS: /
    driverInstallDir: /run/nvidia/driver
  operator:
    runtimeClass: nvidia
  daemonsets:
    labels:
      helm.sh/chart: gpu-operator-v26.3.2
      app.kubernetes.io/managed-by: gpu-operator
    tolerations: 
      - effect: NoSchedule
        key: nvidia.com/gpu
        operator: Exists
    priorityClassName: system-node-critical
    updateStrategy: RollingUpdate
    rollingUpdate:
      maxUnavailable: "1"
  validator:
    repository: nvcr.io/nvidia
    image: gpu-operator
    version: "v26.3.2"
    imagePullPolicy: IfNotPresent
    plugin:
      env: []
# ~~truncated~~

In this case the "validator" image is split between three fields, spec.validator.repository, spec.validator.image, and spec.validator.version.

I expected JSONPath to be able to handle this via an expression like so

crds:
  - kind: ClusterPolicy
    apiVersion: nvidia.com/v1
    imagePaths:
      - "{.spec.validator.repository}/{.spec.validator.image}:{.spec.validator.version}"

But this did not produce the expected output

$ helm package-images nvidia/gpu-operator -m airgap.yaml --dry-run                 
Processing ref "nvidia/gpu-operator"...
warning: skipping invalid image reference "/": could not parse reference: /
warning: skipping invalid image reference ":": could not parse reference: :
Discovered 5 unique image(s):
gpu-operator
nvcr.io/nvidia
nvcr.io/nvidia/gpu-operator:v26.3.2
registry.k8s.io/nfd/node-feature-discovery:v0.18.3
v26.3.2

It may be worth considering using something more flexible than JSONPath, like Go templating.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions