Jkube: NodePorts not created when jkube/service.yml is defined

Created on 23 Oct 2020  ·  4Comments  ·  Source: eclipse/jkube

Description

if a jkube/service.yml is defined to declare some extra configuration (e.g: expose other ports) in the service and jkube.enricher.jkube-service.type property is defined as NodePort, then that ports are not created in the final service created.

If that file does not exist then default ports are exposed successfully, but the application does not work because the additional ports are not declared.

Info

  • Eclipse JKube version : kubernetes-maven-plugin:1.0.0
  • Maven version (mvn -v) :
❯ mvn -v
Maven home: /home/rmarting/Software/apache-maven-3.6.3
Java version: 11.0.8, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.8.10-2.fc32.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.8.15-201.fc32.x86_64", arch: "amd64", family: "unix"
  • Kubernetes / Red Hat OpenShift setup and version :
❯ minikube version
minikube version: v1.14.0
commit: b09ee50ec047410326a85435f4d99026f9c4f5c4
  • If it's a bug, how to reproduce :

1.- Create a service.yml in the jkube folder as:

spec:
  ports:
    - name: http
      port: 8181
      protocol: TCP
      targetPort: 8181

2.- Deploy the application with:

mvn clean package k8s:build k8s:resource k8s:apply

3.- Check that any nodePort was declared:

❯ kubectl get svc <service-name> -o jsonpath='{.spec.ports[].nodePort}'

4.- Remove the service.yml and repeat the deployment as in step 3.
5.- Check that nodePort was declared successfully:

❯ kubectl get svc <service-name> -o jsonpath='{.spec.ports[].nodePort}'
31026

However the ports declared are not the needed for the application:

❯ kubectl get svc kafka-clients-quarkus-sample -o yaml
...
  ports:
  - name: http
    nodePort: 31026
    port: 8080
    protocol: TCP
    targetPort: 8080

Sample GitHub Repository: https://github.com/rmarting/kafka-clients-quarkus-sample/tree/feature/b-g-deployment-strategy

bug

All 4 comments

Probably the property is lost when merging the fragment, we'll check.

As a quick workaround, maybe you can try to redefine your service.yml fragment as:

spec:
  type: ${jkube.enricher.jkube-service.type}
  ports:
    - name: http
      port: 8181
      protocol: TCP
      targetPort: 8181

And provide the default value in your pom.xml properties section. Then you can override the value in the mvn CLI invocation -Djkube.enricher.jkube-service.type=NodePort.

@manusa The workaround works perfectly and the service now is created with the NodePorts definitions. Thank you so much.

:tada: Great to hear!
I'm working on a fix right now for the root-cause, hopefully this will be released on Tuesday, stay tuned ;)

Was this page helpful?
0 / 5 - 0 ratings