Delete all apps and services in specific space - cloud-foundry

Is there a foundry script or command to cleanup all space apps/services, the problem that we have many apps which is related to services and you cannot delete them until you delete all apps, is there any script or command which can help ?
I dont want to hard-code all the apps and services, is there a way for a given space delete all apps and services instances?
is it possible to make mass delete for services?

The easiest thing would be to cf delete-space, wait for that to finish, then cf create-space to remake your space. The cf delete-space is recursive so it would delete everything in that space.
The only challenge might be if you have lots of people invited to your space, this would delete the space so their access would be removed and you'd need to add that back after you recreate the space.
Aside from that, you're going to need to script it.
I would try this order:
grab all the apps in the space
for each app
delete the app (this should also delete service bindings)
grab all of the service instances in the space
if you use service keys, for each service
check for service keys, if present delete them
for each service instance, delete the instance
run cf delete-orphaned-routes, that should clean up all the routes left behind
alternatively, you could use cf delete -r when you delete the app and it will delete the routes associated as well.
As far as how you get "all the apps" or "all the services", you could do something like cf apps | tail +5 | awk '{print $1}' or cf services | tail +4 | awk '{print $1}', or you could use cf curl and the API. The API will be a little trickier though because you have to deal with paging (or maybe not, if you don't have that many apps/services).

You cannot delete all App from Cloudfoundry in a single shot. Cloudfoundry document doest not explain a way to delete all App.
You can delete one App at a time in cloudfoundry. Please refer below link to delete an APP.Click here
Many apps use services and routes. Deleting an app does not delete the services used by the app, and you must explicitly remove routes between your app and the Internet.

Related

Deletion notice for my Google Cloud Shell home directory

I got a deletion notice for my Google Cloud Shell home directory. Does that mean that my data will also be deleted?
This is documented here:
If you do not access Cloud Shell for 120 days, we will delete your
home disk. You will receive an email notification before we do so and
simply starting a session will prevent its removal.
This only applies to the home directory of your Cloud Shell instance (you may want to store it on Cloud Storage anyway if you want to keep it). Any other Google services you use will be unaffected.
Considering i'm paying for their services this is extremely annoying. Lost a lot of important documents and feel like taking my business somewhere else.

Revert failed cloud foundry deploy

I'm automating app deployment to cloud foundry. So in the start command, I do a db migration. What can happen is that the migration would fail and as the result, the app will be dead. Is there some predefined strategy that can be used to rollback to the last working deployment, or I should manually store the last working version, check for failure and in that case redeploy the stored version?
The typical strategy used to deploy apps on Cloud Foundry is blue/green. This generally works like this:
Push the new app under a new name & host, like my-app-new.
Test the app & make sure it works.
When your satisfied, change the route mapping from the old app to the new app.
Delete the old app & optionally rename the new app.
Step #3 is where the cut-over happens. Prior to that all traffic keeps flowing to the old app.
This is documented more here.
https://docs.cloudfoundry.org/devguide/deploy-apps/blue-green.html
I'd say this often works well, but sometimes there are problems. Where this breaks down is with steps #1 & #2, if your app cannot have multiple instances of itself running or if migrations to your service are so different that the old app breaks when you update the database. It definitely helps if you keep this strategy in mind as you develop your app.
Aside from that, which has historically been the way to go, you could take a look at the new v3 API functionality. With v3, apps now retain multiple versions of a droplet. With this, you can rollback to a previous version of a droplet.
http://v3-apidocs.cloudfoundry.org/version/3.36.0/index.html#droplets
You can run cf v3-droplets to see the available droplets and cf v3-set-droplet to change the droplet being used.
That said, this will only rollback the droplet. It would not rollback a service like a database schema. If you need to do that, you'd need reverse migrations or perhaps even restore from a backup.
Hope that helps!
I work on very similar automation processes.
Daniel has explained the process very well. I think you're looking for the blue-green deployment methodology
1) Read up on blue green deploy here:
https://docs.cloudfoundry.org/devguide/deploy-apps/blue-green.html
2) Look at this plugin or implement blue green deploy manually:
https://github.com/contraband/autopilot
3) Blue-green restage plugin (a nice to have, in case you need to restage the app but not cause any downtime to the clients):
https://github.com/orange-cloudfoundry/cf-plugin-bg-restage
It works by creating a temporary app, copying the env vars/routes/code from the working app to he temp app.
The temp app now accepts traffic while the original app is being restaged.
the traffic moves on to the original app after it is restaged and the temporary app is deleted.

Migrate existing live Django site from one server to another along with user records intact

I have deployed a Django site on GoDaddy Django "droplet" for a while and users have been using the site to keep their records.
Now that GoDaddy is discontinuing the service, I would like to migrate the entire site with all records intact to DigitalOcean.
How does one go about doing this?
Here's what I'd do:
dump my data into a file see dumpdata
stop the server
remove all .pyc files
copy paste the whole folder of the website to the destination server
restore data using loaddata
run the server
I did this 4 times without any problems (dev to test environment, test to pre-prod and pre-prod to prod).
The reply by Oliver is good for small sites, but big companies (or any) won't be happy if you stop the server, also some records/sales might be done between the time you dump and the time you stop the server
I think this would be better but I'm unsure:
make a new database and make it sync with the old one, whenever old db changes changes should be synced to the new db (I know for example postgres has a feature that triggers some kind of alerts on creations/updates, this is indeed the hardest step and needs quite a lot of research to pull it off, both databases must be on sync)
upload the new(copy) page next to the new database connected to it
modify the DNS records to point to the new server, traffic will organically move to the new server, at some point you might have people making database updates on both servers so it is important that the sync goes both ways
take the first web-page's server down, cut the database syncing and remove old
page and old database
remove the pipe/method that was letting you sync the
new db with the old one

aws alternative console/management web ui (stop/start/create/list)

Been searching for the last few days for an alternative to the AWS Console Web ui.
We want to give this to our employees to manage their development/test environment their self without interaction from the IT team.
What we want is an extra Web ui that does the following "management tasks"
List all instances (maybe based on tags)
Stop / Start instances
Create / Destroy instances (from specific AMI's)
Also we would like to have logs + authentication (preferable LDAP)
I found a few but none of them actually was that simple.
We would also prefer to have a django/python based application but sinatra is also fine.
Alternatives that I found:
Asgard from netflix
Spurios (has no EC2 instances)
We also found Flask app builder to build our own app but it would be nice if some things already exsists. I believe many company's want the same but are they keeping that for internal use only ?
Maybe you know more projects that I, for some reason, did not stumble on.

how to configure backup wamp server?

I have hosted an intranet website on WAMP server which is working as expected. Now i would like to configure a backup site to it. I mean if it goes down by any chance how do i counter that?
My challenge is i can not have the URL changed as its already been distributed to many users in the past.
My URL is like
http :/ /ipaddress/MyProject/Running/Index.html
I want to know, how do i have a backup website running on the same url to maintain high availability?
Since WAMP applications do not provide their own backup APIs, you need to stop all services if you want to take a full file-system level backup; otherwise you'll get a lot of "file locked" errors and/or your backups will be in an incoherent state.
So yes, you can just make a copy of your C:\wamp directory, but stop all your WAMP-related services before (and remember to restart them after).
any problem please comment me...)
use a slave server with the one using as a master not sure of the tech but I know windows allows two or more servers with same info on them both.