Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server.port lookup fails for complex values #2444

Closed
ajeans opened this issue Nov 13, 2023 · 1 comment · Fixed by #2455
Closed

server.port lookup fails for complex values #2444

ajeans opened this issue Nov 13, 2023 · 1 comment · Fixed by #2455
Assignees
Labels
bug Something isn't working
Milestone

Comments

@ajeans
Copy link

ajeans commented Nov 13, 2023

Describe the bug

I have a spring-boot app with the following application.yml (top only):

 server:
  port: ${APP_SERVER_PORT:8080}

And I am using the spring boot generator which tries to find the HTTP port from the config: https://eclipse.dev/jkube/docs/kubernetes-maven-plugin/#generator-spring-boot

When running

./mvnw k8s:resource

And a jkube configuration like the following:

            <plugin>
                <groupId>org.eclipse.jkube</groupId>
                <artifactId>kubernetes-maven-plugin</artifactId>
                <version>${jkube.version}</version>
                <configuration>
                    <generator>
                        <config>
                            <spring-boot>
                                <name>docker.io/library/${project.artifactId}:${project.version}</name>
                            </spring-boot>
                        </config>
                    </generator>
                </configuration>
            </plugin>

With maven 3.9.4 (outdated values in the form ;) ), I get the following error in the output

[INFO] --- k8s:1.15.0:resource (default-cli) @ microservice-app ---
[INFO] k8s: Using Dockerfile: /Volumes/Workspace/b2c/template-springboot-microservice/microservice-app/Dockerfile
[INFO] k8s: Using Docker Context Directory: /Volumes/Workspace/b2c/template-springboot-microservice/microservice-app
[INFO] k8s: Using resource templates from /Volumes/Workspace/b2c/template-springboot-microservice/microservice-app/src/main/jkube
[INFO] k8s: jkube-controller: Adding a default Deployment
[ERROR] k8s: jkube-healthcheck-spring-boot: Error while reading the spring-boot configuration: java.lang.NumberFormatException: For input string: "${APP_SERVER_PORT:8080}"
[ERROR] k8s: jkube-healthcheck-spring-boot: Error while reading the spring-boot configuration: java.lang.NumberFormatException: For input string: "${APP_SERVER_PORT:8080}"
[INFO] k8s: jkube-revision-history: Adding revision history limit to 2
[INFO] k8s: validating /Volumes/Workspace/b2c/template-springboot-microservice/microservice-app/target/classes/META-INF/jkube/kubernetes/microservice-app-deployment.yml resource

Thanks!

Eclipse JKube version

1.15.0

Component

Kubernetes Maven Plugin

Apache Maven version

other (please specify in additional context)

Gradle version

None

Steps to reproduce

  1. Create a standard maven spring-boot project with a variable as the server.port value in the application.yml file
  2. Configure the jkube maven with the spring boot generator
  3. Run ./mvnw k8s:resource

Expected behavior

I would expect:

  • best option: the detection code looks into the variable and picks the default value (8080 in this case)
  • worst option: the detection code fails gracefully and picks the default

Runtime

other (please specify in additional context)

Kubernetes API Server version

1.25.3

Environment

macOS

Eclipse JKube Logs

[INFO] --- k8s:1.15.0:resource (default-cli) @ microservice-app ---
[INFO] k8s: Using Dockerfile: /Volumes/Workspace/b2c/template-springboot-microservice/microservice-app/Dockerfile
[INFO] k8s: Using Docker Context Directory: /Volumes/Workspace/b2c/template-springboot-microservice/microservice-app
[INFO] k8s: Using resource templates from /Volumes/Workspace/b2c/template-springboot-microservice/microservice-app/src/main/jkube
[INFO] k8s: jkube-controller: Adding a default Deployment
[ERROR] k8s: jkube-healthcheck-spring-boot: Error while reading the spring-boot configuration: java.lang.NumberFormatException: For input string: "${APP_SERVER_PORT:8080}"
[ERROR] k8s: jkube-healthcheck-spring-boot: Error while reading the spring-boot configuration: java.lang.NumberFormatException: For input string: "${APP_SERVER_PORT:8080}"
[INFO] k8s: jkube-revision-history: Adding revision history limit to 2
[INFO] k8s: validating /Volumes/Workspace/b2c/template-springboot-microservice/microservice-app/target/classes/META-INF/jkube/kubernetes/microservice-app-deployment.yml resource

Sample Reproducer Project

No response

Additional context

No response

@ajeans ajeans added the bug Something isn't working label Nov 13, 2023
@manusa
Copy link
Member

manusa commented Nov 13, 2023

I think there was already an issue for something similar, but I can't seem to find it now.

Anyway, I guess this is a common use case and we might want to tackle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants