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

Service with NodePort always gets a new port after 'fabric8:apply' #894

Closed
rhuss opened this issue Mar 22, 2017 · 7 comments
Closed

Service with NodePort always gets a new port after 'fabric8:apply' #894

rhuss opened this issue Mar 22, 2017 · 7 comments
Assignees
Labels
target/4.0 PR for targeted to 4.0.x
Projects
Milestone

Comments

@rhuss
Copy link
Contributor

rhuss commented Mar 22, 2017

Actually this happens always, but can have two causes, both resulting in the existing service and the service to apply to be considered different here. The difference is always in the MetaData as checked here

  • When exposecontroller is used, then the exposecontroller adds two extra annotation (timestamp and a version). This make the annotation part different as these field obviously are missing from kubernetes.yml and so a replacement of the service happens
  • When no exposecontroller is used and no namespace is set directly in kubernetes.yml, then both objects are also considered to be different, since the namespace gets set to the default namespace by kubernetes (so that this field is never empty).

The second issue can be easily solved by ignoring the namespace if set to null when doing the comparisation.

For the first issue, I can't see any easy solution. @davsclaus @jstrachan @rawlingsj @iocanel any idea how to fix this (without hardcoding the exposecontroller annotations into this check ?)

@rhuss
Copy link
Contributor Author

rhuss commented Mar 22, 2017

Just found out that there is a fabric8.deploy.ignoreServices for fabric8:apply which is a workaround when doing a redeployment.

@davsclaus
Copy link
Member

So this confuses the hell of out of people getting started with k8s and want to use the fmp plugin to deploy their java apps.

Having to add NodePort or LoadBalancer is a bit annoying as its not as easy to figure out.

I wonder if there is something we can do to make the fmp plugin lean and mean OOTB when you add it with the "setup" goal so it works in local development mode for developers.

@samolisov
Copy link
Contributor

I get the same problem using fmp on Windows with minikube. So, the NodePort parameter isn't generated by fmp, so k8s generate new port number for every apply. I also tried using the exposecontroller, but the controller also binds my service on new ports. The fabric8.deploy.ignoreServices helps 'to save' ports after the first deploy, but the question is how to get the port number for integration tests?

I'm working on the following scenario: a Java EE application is deployed on docker inside k8s and exposes a number of REST services; there are integration tests that make requests to the services and analysing the responses. Yet I must know the port the docker container is exposed on to implement the scenario. I'm sure, I'm not the first who asks so, but no answer has been googled.

Thanks!

@rhuss rhuss added this to Planned in fmp 4.x via automation Jul 23, 2018
@rohanKanojia rohanKanojia added this to the Sprint 153 milestone Aug 1, 2018
@rohanKanojia
Copy link
Member

@rhuss : This doesn't seem like a refactoring issue. Do you want to pick this also or shall I pick this ?

@rohanKanojia rohanKanojia self-assigned this Aug 1, 2018
rohanKanojia added a commit to rohanKanojia/fabric8-maven-plugin that referenced this issue Aug 17, 2018
… 'fabric8:apply'

+ Added solution for case when no exposecontroller is used. Don't compare
  when one of the attributes is null
@rohanKanojia
Copy link
Member

@rhuss : Do you have any other solution in mind that I can try for the former case? since we are not using fabric8 dependency anymore?

@rohanKanojia rohanKanojia modified the milestones: Sprint 153, Sprint 154 Aug 23, 2018
@rhuss
Copy link
Contributor Author

rhuss commented Aug 24, 2018

What's about this: When we detect that a service with a certain name already exists, we don't exchange it but patch it durin apply ? Could be a good strategy for any other object, too.

Otherwise, when we try to detect whether a serivce hase been exchanged we probably shouldn't take care about meta data. Or, when only meta data is changed (annotations, labels), we just update that metadata.

wdyt ?

@rohanKanojia
Copy link
Member

rohanKanojia commented Aug 24, 2018

@rhuss : Right now I'm not sure... how would we maintain what items we need to patch in a specific resource? Okay, let me think about it. The solution sounds good but I have to think a bit about implementation.

rohanKanojia added a commit to rohanKanojia/fabric8-maven-plugin that referenced this issue Aug 27, 2018
… 'fabric8:apply'

+ Added solution for case when no exposecontroller is used. Don't compare
  when one of the attributes is null
rohanKanojia added a commit to rohanKanojia/fabric8-maven-plugin that referenced this issue Aug 27, 2018
… 'fabric8:apply'

+ Whenever we detect that a resource with a certain name exists, edit()
  instead of doing replace()
@rhuss rhuss moved this from Planned to In Progress in fmp 4.x Sep 7, 2018
@rhuss rhuss closed this as completed in fa0f043 Sep 11, 2018
rhuss added a commit that referenced this issue Sep 11, 2018
Fix #894: Service with NodePort always gets a new port after 'fabric8:apply'
fmp 4.x automation moved this from In Progress to Done Sep 11, 2018
@rhuss rhuss added the target/4.0 PR for targeted to 4.0.x label Sep 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
target/4.0 PR for targeted to 4.0.x
Projects
No open projects
fmp 4.x
  
Done
Development

No branches or pull requests

4 participants