简体   繁体   中英

JHipster registry and cloud foundry (Pivotal)

I'm trying to deploy jhipster registry to cloud foundry, however its profiles are being overridden by spring cloud configs 'cloud' profile. I'm unable to get the service running on its normal port of 8761, its constantly defaulting to port 8080. Does anyone know how to override these properties and get it set up successfully?

The Java buildpack should not override your Spring profiles, but it will append to them. You might want to double check how you are setting profiles to make sure that they are being applied correctly.

The Spring Auto-reconfiguration Framework adds the cloud profile to any existing Spring profiles such as those defined in the SPRING_PROFILES_ACTIVE environment variable.

https://github.com/cloudfoundry/java-buildpack/blob/master/docs/framework-spring_auto_reconfiguration.md

That said, you can disable this Spring auto reconfiguration behavior by setting the following env variable:

cf set-env <your-app> JBP_CONFIG_SPRING_AUTO_RECONFIGURATION '{ enabled: false }'

As far as the port, 8080 is the default port used by all applications deployed to Cloud Foundry. If you have HTTP(S) traffic that needs to be routed to your application, it will come through port 8080.

That said, you have a couple options here:

  1. The first option is to just have your app start listening on port 8080. In this way, traffic to any routes that you have mapped to your application will be delivered to your app. For example: if you have registry.example.com mapped to your app, then going to https://registry.example.com/ will result in traffic hitting your app. Port 8080 is internal only and external users don't see it . This exposes your app publicly, so you need to secure things appropriately.

  2. The second option is to map an internal route to your registry . This would basically work the same as above, except that you would not be able to access the registry externally. That would potentially offer a more secure install, but it would also make it so that you cannot easily access the JHipster Registry UI. I'm mentioning this as an option, but it's probably not a good one unless you really need to hide the registry. Don't forget that if you use internal routes, you need to apply network policy to open ports between your registry and service apps. By default, no ports are open.


In regards to JHipster Registry. I did a test and was able to deploy it using these steps (this is by no means a complete set of instructions for using JHipster's Registry, just a minimal set to get a test up and running, please refer to JHipster docs for more details).

Instructions to test:

  1. Run git clone https://github.com/jhipster/jhipster-registry & git checkout v6.1.0 . This will check out the latest release at the time (pick whatever version you want).
  2. Edit src/main/resources/config/application-prod.yml , change the password from admin to something else. You don't have to do this, but you really should, especially if deploying with public routes.
  3. Deploy. As described, here run jhipster cloudfoundry , answer the questions to deploy & make sure you pick a unique app name (first question). Wait for a bit as it deploys.
  4. Registry should be running now. Grab the URL to it.

To complete the test, you need a service app:

  1. Create a micro service app using jhipster app . Answer all the questions, it really doesn't matter for this test as the app isn't going to do anything, so I just picked a minimal install (no db, nothing fancy).
  2. As described here we need to edit two files. Edit src/main/resources/config/bootstrap-prod.yml . Change the spring.cloud.config.uri property to point to your app on PWS. Ex: https://admin:${jhipster.registry.password}@your-registry-name-goes-here.cfapps.io/config .
  3. And edit 'src/main/resources/config/application-prod.yml . Change the . Change the eureka.client.service-url.defaultZone to point to your app on PWS. Ex: to point to your app on PWS. Ex: http://admin :${jhipster.registry.password}@your-registry-name-goes-here.cfapps.io/eureka/`
  4. Deploy. As described, here run jhipster cloudfoundry , answer the questions to deploy & make sure you pick a unique app name (first question). Wait for a bit as it deploys.

Once the app deploys, you should be able to go to your registry and see it has your service registered. If you wait a minute or so and it doesn't register, you'll need to look at the service app to see what happened.

For reference, these instructions are using the first option I described above.

Hope that helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM