Why does pivotal cloud foundry does not remove a route when a corresponding app is deleted? - cloud-foundry

I have been exploring Pivotal Cloud Foundry - Public Cloud Version by setting up an Pivotal Web Services account.
While exploring the CF CLI I followed the below tutorial.
https://pivotal.io/platform/pcf-tutorials/getting-started-with-pivotal-cloud-foundry/introduction
I was able to successfully push the sample spring boot app to PCF Cloud and follow the tutorial.
When I started to play around with it, I tried deleting the app using the below command. cf-spring is my app name.
cf delete cf-spring
When navigated to my Pivotal Web Service account, I could see the app has been deleted. The route still displays the name of the route which was created when an app was created using the cf push command.
So I tried to delete the route using the below command.
It does not allow me to delete using CLI ? Does the app delete command should have taken care to remove the related routes associated with the application ?

Try cf delete-route -h to see the syntax of the delete-route command.
You probably want to run cf delete-route cfapps.io --hostname cf-spring-rested-platypus.
In recent versions of cf-cli you can also run cf delete-orphaned-routes.
I think the reason CF doesn't completely delete the route when you delete an app is so that it kind of keeps the hostname reserved for your use, ie: someone else can't reuse it in another org or space if you've just taken down your app for a refresh. It's kind of annoying when you actually want to reuse the hostname in another space, but considering the multi-tenancy capabilities it kind of makes sense to keep them intact/reserved.

cf delete APP_NAME will not delete the route bound to the Apps and this should not happen first-of-all. Because the router-concept in Cloud foundry is that
One App can have Multiple Routes and Multiple Routes can be configured to one App.
Its Many-to-One mapping. So there is a possibility that the routes you created would still be mapped to another App and it would be as Orphaned-route, only when there are no apps for that routes..
So its a cautious decision and a wise decision too !!

Related

I had deployed the test application on Production on Google Cloud via App Engine, But URL still accessible

I had deployed the test application on Production on Google Cloud via App Engine and i could not see the instance is being created as its serverless it could or it could not create the instance.
But I am concerned about the billing since the URL was still running like on :
Example: http://mytestproject-123456.appspot.com/
So I disabled the billing for the project and also the application from the App Engine settings.
Could someone please help or suggest.
Is any action still required to stop the billing if there is any since I had deployed the application on Production and the url was accessible.
1.And If delete the whole project will it work?
If yes please tell the process.
If you want to stop the app from serving requests and running instances, you can disable the application. This way you will not be getting billed for that. Basically, there is no need to delete a billing account or the project to just stop serving requests. Please be aware that you still might be charged for storage, or other GCP services that you are using if applicable.
I would say that you do not need to do anything else. For future reference, before deploying a service, a good practice is to test it locally before deploying and starting to serve requests from users.
I suppose you are talking about the Standard Environment; if i am right, you can see the number of instances by going in the console, choosing your project in the selection control on top of the page. After this, in the left column, select App Engine, and, in the page that shows up, you can see the instances tab. There you will find all the running instances, if any.
If you are using other resources, they will be billed accordingly. If you are not, disabling the application is all you need to protect yourself against unwanted billing.
Hope this helps.

Create and Push an App programmatically from another App in Cloud Foundry

Is it possible to create and push an application into Cloud Foundry from a different application that is already running in Cloud Foundry? Essentially I need to do a 'cf push' from within the application.
I saw there's a Cloud Foundry API that I can use (https://apidocs.cloudfoundry.org/237/apps/creating_an_app.html). Can anyone give me an example?
The Cloud Foundry Java Client is designed for use cases like this. It takes care of negotiating the OAuth2 security used by the CF API and provides nice abstractions for common operations that require multiple CF API calls (e.g. pushing an app, which involves creating app metadata, pushing the bits, and starting the app). I would prefer this option over using Java to shell out to the cf CLI, as you get greater control over the CF API and aren't subject the CLI UI to detect success/failure.
There's nothing stopping an app from running on CF from pushing other apps, but the platform doesn't do a lot to help with this either. Specifically, you'll need the address of the CF API endpoint (e.g. http://api.mycf.example.com) to be able to target, authenticate, and deploy apps. But there is no way for an app running on CF to know the API endpoint of the CF it is running on. So you will need to configure the CF API endpoint into the application that will be pushing other apps.
TL;DR Yes it is possible. Shell out to the CF cli.
The easiest way to do this would be to just include the CF cli in your application and shell out to it to push your app. You'll have to make sure that the binary you use matches the OS where your app is running (most likely Ubuntu 14.04). But that way, you can just provide it with your user's CF credentials and use the cf push logic in the CLI.
There is a CloudFoundry API you can use, but I'd advise against it. Trying to authenticate and push a cf app will be tricky. cf push does a lot under the hood -- it not only creates the app via the API endpoint you found, but it also uploads application files in an intelligent way, it attaches routes and services to the app, starts the app, polls the CF API for the updates on the status of the staging task, etc. You'd have to implement all of this on your own (not to mention the OAuth2 workflow to get an auth token).
There are some third-party CF libraries you might find useful (depending on the language you are using):
https://github.com/cloudfoundry/cf-java-client
https://www.npmjs.com/package/cf-nodejs-client
Lastly the CloudFoundry cli is open-sourced (https://github.com/cloudfoundry/cli). Bear in mind that as discussed above the push logic consists of multiple operations, and as such the codebase might be difficult to grok.

How do I use Blue-Green Deployment in Pivotal Web Services?

I read from this guide http://docs.cloudfoundry.org/devguide/deploy-apps/blue-green.html that this deployment is supported through CLI.
Can I use my Pivotal Web Services web interface to do that ?
Does the Green instance connect to the production DB ?
Any guide is greatly appreached
Yes,you can use the web interface to map and unmap routes. When you go to the detail app of your app, you can see at the bottom a tab panel. One of the tabs says 'Routes'. There you can map and unmap routes.
Yes, both instances should be connected to the same db. During a time, when both instances are live (the production route is mapped to both of them), you will have users using the old and the new version. If a user is using the old version, you want his/her edits to be stored and present when he/she is switched over to the new version. Note: That means you should make sure that all your database migrations are backwards compatible.

Can we have Ui for cloudfoundry deployed on AWS

Iam new to Cloudfoundry on AWS. I have deployed cloudfoundry on AWS, but when i want to push an application into cf which i have deployed i was using command line tool (cf). Is there any way we have UI like Cloudfoundry where we can check our app running on UI , and even on Bluemix we can have ace.ng.bluemix.net to login and check our apps.
I want to know if i can check my appp deployed in my custom cloudfoundry deployed on AWS in UI where i can see other applications as well running.
It would be very helpful if i get this.
Thanks & regards,
Srilatha K.
There is the admin-ui, which is a bit more detailed than the Pivotal WS/CF interface but will provide you a BUI as an alternative to cf cli:
https://github.com/cloudfoundry-incubator/admin-ui
You can make use of BOSH.
It takes care of deployment & life cycles managements...
Reference - http://www.slideshare.net/ManuelGarcia122/cloud-foundry-handson-deployment-workshop
Slide 29 onwards
Useful link - http://blog.altoros.com/tag/cloud-foundry

Grails App with Multi Tenant Single DB plugin URL implementation in Cloudfoundry

I am currently creating a web app using Grails implementing Multi Tenant Single DB plugin. The plugin allows me to have multiple tenants on a single db using a tenantID to differentiate between tenants. The plugin detects witch tenant will deal the current request that is made on my app by resolving using different domains/subdomains for each tenant.
For example:
Tenant 1 = companyA.myapp.com
Tenant 2 = companyB.myapp.com
On my local machine running Grails development mode I was able to implement the different hosts by changing my /etc/hosts and each tenant would have their own subdomain.
I am currently interested in using cloud foundry as my cloud platform but when I deploy my app to cloud foundry it is already using my app name as the subdomain for cloud foundry.
For example:
- myapp.cloudfoundry.com
Is it possible to change or control the domain name resolver in
cloud foundry?
Does anybody know how to handle multi-tenant subdomains as explained above in cloud foundry? Probably provide the steps in implementing this using cloud foundry?
What is the best approach to implement this using cloud foundry?
My App is using Grails 2.0.4 and Multi Tenant Single DB plugin 0.8.2.
Thanks
Unfortunately the current beta version CloudFoundry does not allow modification of the cloudfoundry subdomain. The plan is to have the GA towards the end of this year with a private preview of the version of the site available sooner in the fall. At that time you could be able to customize the subdomain.
Therefore you might need to change a little in your TenantResolver to only check the subdomain that varies.
To implement your requirement, did you try installing the grails cf plugin? If not you can start from here.
If you are using cli, installing the plugin just needs command in your project workspace:
grails install-plugin cloud-foundry
When your app is ready for deployment, push it to cloudfoundry:
grails cf-push
Note that you will have to have your cf credentials configured in the grails config file.
After that you can map multiple URLs you want using:
grails cf-map user1.yourapp.cloudfoundry.com
If you have already known about vmc which is the client command line interface for cf, you can see the urls mapped with your app by
vmc apps
If not you can refer to the installation guide to start if you would like to do that.
If you are using STS/eclipse, things will be even easier. First you need to have grails-support extension as well as the cloud foundry integration installed. For detailed docs of the cf integration please refer here.
After your app is deployed, right click the project and choose "Grails Tools" -> "Open Grails Command Prompt". This will enable you to have same grails cf plugin commands as the CLI does.
Hope this can help your move forward in the cloudfoundry world. Let me know if you have more questions.
Thanks,
William