Skip to content

FileNotFoundError when attempting to generate code for Gateway API CRDs #4512

@vincentburesi-es

Description

@vincentburesi-es

I am attempting to generate the code for multiple new CRDs, my goal is to use the client to dynamically generate resources for Gateway API and kgateway.

Describe the bug
I initially followed this tutorial.

First issue I had was that the ghcr.io/kubernetes-client/java/crd-model-gen:v1.0.6 suggested image relied on an outdated docker version:

Error response from daemon: client version 1.40 is too old. Minimum supported API version is 1.44, please upgrade your client to a newer version

I am on Linux Mint with docker 29.1.4 which uses the 1.52 API version which require 1.44 as showed in docker version output.
I fixed this issue by cloning the project, editing client-java-contrib/Dockerfile from docker:stable to docker:latest and rebuilding the image with docker build --tag local-crd-model-gen ..

So the commands I am running are now:

mkdir -p /tmp/java && cd /tmp/java
docker run --rm \
       -v /var/run/docker.sock:/var/run/docker.sock \
       -v "$(pwd)":"$(pwd)" \
       -it \
       --network host \
       local-crd-model-gen \
       /generate.sh \
       https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.4.1/experimental-install.yaml \
       -n io.k8s.networking.gateway \
       -p io.k8s.networking.gateway \
       -o "$(pwd)"

Given output is:

Creating cluster "crd-model-gen" ...
 ✓ Ensuring node image (kindest/node:v1.25.3) 🖼
 ✓ Preparing nodes 📦  
 ✓ Writing configuration 📜
 ✓ Starting control-plane 🕹️ 
 ✓ Installing CNI 🔌 
 ✓ Installing StorageClass 💾 
Set kubectl context to "kind-crd-model-gen"
You can now use your cluster with:

kubectl cluster-info --context kind-crd-model-gen

Have a nice day! 👋
Verifying CRD installation..
Deleting cluster "crd-model-gen" ...
KUBERNETES_CRD_GROUP_PREFIX: 
OPENAPI_MODEL_LENGTH: 2
PACKAGE_NAME: 
GENERATE_APIS: false
CLIENT_VERSION: 5.0-SNAPSHOT
OUTPUT_DIR: /gen
HIDE_GENERATION_TIMESTAMP: false
LIBRARY: okhttp-gson

rendering settings file to /tmp/settings
reading input openapi specs
--- Building docker image kubernetes-java-client-gen-with-openapi-generator:v1...
[+] Building 0.4s (13/13) FINISHED                                                                                                                            docker:default
 => [internal] load build definition from Dockerfile                                                                                                                    0.0s
 => => transferring dockerfile: 1.88kB                                                                                                                                  0.0s
 => [internal] load metadata for docker.io/library/maven:3.9.6-eclipse-temurin-11                                                                                       0.3s
 => [internal] load .dockerignore                                                                                                                                       0.0s
 => => transferring context: 2B                                                                                                                                         0.0s
 => [1/8] FROM docker.io/library/maven:3.9.6-eclipse-temurin-11@sha256:b3573fcc754a04d96c00a4bb932a5c723493ebbb3d5676e0adaa59d386a5448c                                 0.0s
 => [internal] load build context                                                                                                                                       0.0s
 => => transferring context: 112.11kB                                                                                                                                   0.0s
 => CACHED [2/8] RUN apt-get update && apt-get -y install git python3-pip && pip install urllib3==1.24.2                                                                0.0s
 => CACHED [3/8] RUN mkdir /source &&     cd /source &&     mkdir openapi-generator &&     cd openapi-generator &&     git init &&     git remote add origin https://g  0.0s
 => CACHED [4/8] RUN chmod -R go+rwx /root && umask 0 && cd /source/openapi-generator &&     mvn install -DskipTests -Dmaven.test.skip=true -pl modules/openapi-genera  0.0s
 => CACHED [5/8] COPY openapi-generator/generate_client_in_container.sh /generate_client.sh                                                                             0.0s
 => CACHED [6/8] COPY preprocess_spec.py /                                                                                                                              0.0s
 => CACHED [7/8] COPY custom_objects_spec.json /                                                                                                                        0.0s
 => CACHED [8/8] COPY java.xml /generation_params.xml                                                                                                                   0.0s
 => exporting to image                                                                                                                                                  0.0s
 => => exporting layers                                                                                                                                                 0.0s
 => => writing image sha256:d63b354f39443c75b7984c85e8cca75eb1311ffcded55ef7292bb2c168db43ca                                                                            0.0s
 => => naming to docker.io/library/kubernetes-java-client-gen-with-openapi-generator:v1                                                                                 0.0s
--- Running generator inside container...
/source/openapi-generator /
/
--- Downloading and pre-processing OpenAPI spec
Traceback (most recent call last):
  File "//preprocess_spec.py", line 592, in <module>
    sys.exit(main())
  File "//preprocess_spec.py", line 568, in main
    with open(unprocessed_spec, 'r') as content:
FileNotFoundError: [Errno 2] No such file or directory: '/output_dir/swagger.json.unprocessed'

This error is similar to Issue 1497, except I am on an up to date Linux Mint 22 with no specific configuration that I am aware of.

Details of used versions

Client Version
NA, this is about the CRD code generation, I built the docker image from the latest master commit (5a74f7b)

Kubernetes Version
kubectl version output on the container:

Client Version: v1.28.2
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Error from server (NotFound): the server could not find the requested resource

Java Version
NA

To Reproduce
Specified in the bug description

Expected behavior
No error

KubeConfig
NA

Server (please complete the following information):

  • OS: Linux Mint 22
  • Environment docker:latest container
  • Cloud NA (CRD generation)

Additional context
docker version output on the container built from the ghcr.io/kubernetes-client/java/crd-model-gen:v1.0.6 image:

Client: Docker Engine - Community
 Version:           19.03.14
 API version:       1.40
 Go version:        go1.13.15
 Git commit:        5eb3275
 Built:             Tue Dec  1 19:14:24 2020
 OS/Arch:           linux/amd64
 Experimental:      false
Error response from daemon: client version 1.40 is too old. Minimum supported API version is 1.44, please upgrade your client to a newer version

docker version output on the container built from the Dockerfile:

Client:
 Version:           29.1.4
 API version:       1.52
 Go version:        go1.25.5
 Git commit:        0e6fee6
 Built:             Thu Jan  8 19:55:48 2026
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          29.1.4
  API version:      1.52 (minimum version 1.44)
  Go version:       go1.25.5
  Git commit:       08440b6
  Built:            Thu Jan  8 19:57:04 2026
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v2.2.1
  GitCommit:        dea7da592f5d1d2b7755e3a161be07f43fad8f75
 runc:
  Version:          1.3.4
  GitCommit:        v1.3.4-0-gd6d73eb8
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker version output on the host machine:

Client: Docker Engine - Community
 Version:           29.1.4
 API version:       1.52
 Go version:        go1.25.5
 Git commit:        0e6fee6
 Built:             Thu Jan  8 19:57:04 2026
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          29.1.4
  API version:      1.52 (minimum version 1.44)
  Go version:       go1.25.5
  Git commit:       08440b6
  Built:            Thu Jan  8 19:57:04 2026
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v2.2.1
  GitCommit:        dea7da592f5d1d2b7755e3a161be07f43fad8f75
 runc:
  Version:          1.3.4
  GitCommit:        v1.3.4-0-gd6d73eb8
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions