SpectoLabs / hoverfly

Lightweight service virtualization/ API simulation / API mocking tool for developers and testers
https://hoverfly.io
Apache License 2.0
2.36k stars 208 forks source link

Deploying in Cloud foundry #515

Open pradeepkusingh opened 7 years ago

pradeepkusingh commented 7 years ago

I have cloud foundry in my environment and want to deploy this in it. How can I achieve this ?

JohnFDavenport commented 7 years ago

Download and install from here: http://hoverfly.readthedocs.io/en/latest or here https://hoverfly.io

pradeepkusingh commented 7 years ago

I think it is not going to work as cloud foundry has different deployment structure.

JohnFDavenport commented 7 years ago

I believe Cloud Foundry supports Linux hosts but perhaps you are looking to deploy Hoverfly in a container??? Can you be a bit more explicit what you are looking for or what you have tried to do so far?

mogronalol commented 7 years ago

@pradeepkusingh We aren't actually that familiar with cloud foundry. As it's a paas it looks like there is some extra work to be done to make it a deployable. I have had a brief look here -

We can add it to our road map.

pradeepsingh1234 commented 7 years ago

Thanks, it would be rally helpful if we can deploy hoverfly on Cloud as we don't want to maintain the separate environment and having too many VMs. Once we deploy we can scale over anytime.

Cloud foundry has a concept of build packs and it supports multiple language build packs. So hoverfly should be packaged as war, ear, jar to be deployable on Cloud foundry. Build packs: Java(Tomcat/Jetty servers), GO, Node, PHP, Python.

pradeepsingh1234 commented 7 years ago

@JohnFDavenport , you are right John, CF support linux , but deployment architecture is fully different, it can support docker, but I wanted to explore options to deploy it as an app in CF. Cloud foundry has lot of benefits like scaling over on the fly. and want to integrate this as a Mock servers in my CI-CD( GO-CD)

mogronalol commented 7 years ago

So it looks like we could do a Go build pack for CloudFoundry which contains the Hoverfly binary. I'm sure it wouldn't be too complicated, it's just a matter of prioritizing it. We also know a few people at Pivotal who might be able to help us.

We also have a SaaS private beta coming out shortly which could be of use. Of course, this would run outside of CF, but may still be of help. But watch this space :)

pradeepkusingh commented 7 years ago

Thanks, is this something we can get in couple of weeks or months ? If it takes long then I will explore other tools.

Thanks for help.

mogronalol commented 7 years ago

We are opening it up privately this week and will be gradually opening it over to the public over the weeks after that. If you're interested in participating in the private beta email contact@specto.io.

JohnFDavenport commented 7 years ago

@pradeepkusingh in #556:

This might be a great feature as Cloud foundry is very popular as a private cloud. I am desperately looking for a Mock server which can be deployed in CF.

It's on our roadmap as @mogronalol says, but we have been busy on Hoverfly Cloud.

Which distribution of CF are you using? It might be of help if you told your account manager you need this so that we get some assistance. It's marvellous that Hoverfly is available on so many platforms now but at the same time it creates an overhead for us that we are not paid for.

noelnole commented 7 years ago

We are in the same problem that pradeepkusingh, for us will be very useful a Go buildpack for Cloud Foundry. Do you have any estimation about a new Release with this new functionality?

tjcunliffe commented 7 years ago

Hi @noelnole - I'm afraid a buildpack is not currently a high priority for the Hoverfly open source project. This is because we do not have a great deal of experience with Cloud Foundry, and none of our (SpectoLabs) clients are currently using it.

However, we are always interested to hear more about how people are using Hoverfly, and we are happy to help with community contributions. I've noticed that there are quite a few community-contributed CF buildpacks.

I will ask some people I know who have more experience in Cloud Foundry to see if any of them would be interested in collaborating on a community-contributed Hoverfly buildpack.

In the meantime, please feel free to email us at contact@specto.io if you would like to tell us more about your use-case.

Alternatively, I'd suggest raising a separate GitHub issue which describes the requirements for a buildpack in as much detail as possible. This could provide a starting point for a community collaboration.

DanielJonesEB commented 7 years ago

I don't think you'll need a custom buildpack. Pushing the Hoverfly binary and specifying the correct start command should be enough?

http://docs.cloudfoundry.org/buildpacks/go/#start_command

noelnole commented 7 years ago

@DanielJonesEB , I tried this with the next commands:

PROCESS_TYPE: COMMAND

web: hoverctl start $PORT

web: sh script.sh $PORT

But was not possible run Hoverfly in Cloud foundry, because when Hoverfly try to run suddenly going fail and it is not possible keep running the application.

d-lorenc commented 7 years ago

Here is how I'm running the hoverfly on CF in the standalone/webserver mode.

First, get the linux binaries of the hoverfly. Use the binary buildpack, so your manifest.yml may look like this:

---
applications:
  - name: my-mock-app
    buildpack: binary_buildpack
    memory: 64M

Add the hoverfly command that you want to execute in the Procfile. Something like this: web: ./hoverfly -webserver -pp $PORT -import path-to-your-json-file You could use the command in your manifest.yml instead of Procfile.

Push you app. Happy days :) Works for me on PWS.

A couple of gotchas: -Use hoverfly binary instead of hoverctl. The hoverctl will exit after you run it, so the CF will think your app crashed. The hoverfly runs in the foreground. -Make sure you set hoverfly port to the one given by CF ($PORT variable)

mogronalol commented 7 years ago

@d-lorenc Thank you, this is very helpful for the community, and very much appreciated. We need to add this to the Hoverfly documentation. Again, PR's are always welcome :)

mogronalol commented 7 years ago

@d-lorenc One comment on not using Hoverctl - does it work with nuhup? That's how I get around it with ansible, but I'm not sure if that would apply to CF as I don't know if the host container is killed when the command exists (I've never used CF)

d-lorenc commented 7 years ago

@mogronalol I think the nohup won't help in this scenario. I would use it to run a process in the background. So it does the opposite. The hoverfly binary seems more suitable in this case.

BTW, I created this little repo with a ready to use example for those interested in trying to run the hoverfly on CF:

https://github.com/d-lorenc/hoverfly-on-cf

All you need to do is to clone it and run cf push from that folder. All assuming you've got CF CLI installed, access to some CF instance etc.

This time I included the startup command inside the manifest.yml. No Procfile needed. Simples ;)

mogronalol commented 7 years ago

Thank you, we will add a reference to this in our documentation.