google managedvm delete instance foverver - google-app-engine

I recently changed the version of the app when deployment and everytime i execute gcloud compute instances list it will list out the old version, i tried manually deleting from the console and it works but after few minutes it will go back. I tried gcloud delete too
gcloud compute instances delete instance --delete-disks all
Stopping doesnt help to, as it is a running instance would it charge me on its up time? How do i completely remove it (Did tried removing appengine version too but it keeps coming back)?

I've been having a lot of trouble with deploying (with versions) and deleting instances on Google Compute Engine's managed VMs. Here's a solution I found for deleting the default GCE managed VM:
Make sure you have the up-to-date GCE components. Run gcloud components update in the Google Cloud SDK Shell.
In your app.yaml, remove the vm:true, resources: section, and manual scaling: section.
Navigate to Compute -> App Engine -> Versions and record the <default-version-number>. Mine looks like 20150722t1245032 with the words (default) indicating the default version.
Deploy the application, set the default, and specify the default version. gcloud preview app deploy "...\app.yaml" --set-default --version=<default-version-number>.
Navigate to Compute -> Compute Engine -> VM instances. Select the default instance and delete.
I was also taught how to stop deploying additional instances:
The key is to specify the version number gcloud preview app deploy "...\app.yaml" --set-default --version=<version-number>. #ZacharyNewman was able to help me with this problem.
And finally, this is how to delete the additional versions of an instance:
Navigate to Compute -> App Engine -> Versions and delete the versions you don't want.
Navigate to Compute -> Compute Engine -> VM instances. Select the instances you don't want and delete.
Hope this helps!

Related

How to select Google App Engine Location

GAE recently got some updates including "organisations" which seems to have also resetted many other settings - e.g. super unclean migration.
Question: how can I select the deploy region/location for google-app-engine apps?
Unfortunately it is not anymore possible to do so as described here: How to choose Google App Engine servers' location
When I create a new project there is no "advanced" settings. If I still just "blindly" deploy (after ignoring the annoying new tutorial / quick start that is forced into ones throat) it will use europe-west as region.
In the Google Cloud Console -> Menu -> Compute -> App Engine
You should then see a box with title "Your first app", follow the steps and at some point it will prompt you to select the server location (cannot be changed later once selected). After selecting server location you don't need to continue with the Hello World app, just deploy your code as normal.
I believed something has been changed recently and there's no clear documentation yet.

Google App Engine Flexible Environment creating too many VM instances

I followed the Quickstart for Node.js in the App Engine Flexible Environment found at
https://cloud.google.com/nodejs/getting-started/hello-world
I deployed the hello-world node.js app using gcloud preview app deploy.
However, this simple command generated dozens of VM instances that I can see on the Developers Console. These instances are named gae-default-timestamp-xywz.
I manually deleted the instances on the console, and minutes later new ones were back, only stopping to create new ones when my resources quota is reached.
Has anyone out there seen anything like this and know how to fix the issue? Thanks!
For the existing instances, you need to shut down first before deleting them. And to fix the new instance spinning, you can use max_num_instances: THE NUMBER_AS_YOU_DESIRE (ex. max_num_instances: 2 for auto scale) in your app.yaml file.

Maintaining separate environments with no downtime on update in app engine

I have been tweaking my environment in Google's App Engine to have several instances of my app for testing and production. However I am uncertain if the intended use of versions applies here.
App background:
- Node.js express app configured on app engine, using Cloud sql.
- 2 modules:
- - default/main - front end code code and API
- - workers - separate app that has a variety of workers
- Redis to keep track of the queue, kue.js for implementation
I was under the impression that I could use versions here, so that I keep only 2 modules, my default one and a workers module. Each will then have 2 versions, staging and production. The commands to push each one would then be:
gcloud preview app deploy --version staging --no-promote
gcloud preview app deploy --version production --promote --no-stop-previous-version
That is all separated well, and perhaps the intended use of versions. However, what I can't achieve with this is no downtime. What seems to happen is that the old machine is tore down then the new one build up, resulting in 3-4 minutes of down time during deploys. As opposed to keeping the old until the new is finished and then just rerouting. Note, the production version in this case should always have 100% of the traffic.
What I found to work well is to keep a module for each version, so I end up with 4 modules (default, default-staging, workers, workers-staging) and no real versions specified during deploys. When deploying with this, there is no downtime, but old versions are kept running:
gcloud preview app deploy --promote
I have a helper script to delete all versions that get 0% of the traffic. Is this the correct approach for setting up separate environments? Just looking for some feedback in case I am missing something obvious.

Google Compute Engine keeps spawning instances, then deploy says no CPU's available

I'm just going through the node.js tutorials with a free trial account, and i'm stuck on the second one where you add a db. I add the mongodb deployment, shows up as a VM instances, fine. And my first deploy worked, but now that i'm trying to edit stuff, my deploy's keep failing.
The error i get is that I've exceeded my CPU quota. Watching the list of VM Instances under Compute Engine, i see it keeps spawning up instances, even though the app isn't being used. Guessing it just spins up 8 instances by default?
But then i guess the build system needs its own VM's, but the CPU capacity is used up, so none available to do subsequent builds?! I feel like i'm missing something...
Also, i see i can explicitly start VM's myself, so what process is creating them form me? And can i turn it off? or set a cap on number of instances it spawns?
Can i tell my project to only use 4
Also, the deploy takes forever, is that normal? Following the tutorials, so far I've only seen this command to deploy:
gcloud preview app deploy app.yaml --set-default
Is there another command that does an incremental deploy or something?
By using gcloud preview app deploy you're actually using Managed VMs which is an App Engine runtime which in turn runs Docker containers on Google Compute Engine, which it creates on its own. In other words, you're not using Google Compute Engine directly.
To get rid of extra VMs, you need to delete old app versions: navigate to Compute > App Engine > Versions and delete the versions you don't want.
See also this answer for more details and suggestions.

How to permanently delete Google managed VMs

I am unable to permanently delete Google App Engine managed VMs I've created. I've deleted them multiple times both from the developer's console and by using the gcloud command. In every case the command completes successfully and the VM is deleted, but then almost immediately Google creates a brand new VM to take its place.
Does anyone know how to permanently delete managed VMs? Thanks.
We are working on improving this experience. For now, though, one workaround is to deploy a non-Managed VM instance as the default version and delete any other versions that are Managed VM-based. Again, this issue is on our radar to be fixed.
[Chris Ramsdale, Product Manager for App Engine]
I wanted to update this post with some of my solutions to deploying (with versions) and deleting instances on Google Compute Engine's managed VMs. Here's a solution I found for deleting the default GCE managed VM:
Make sure you have the up-to-date GCE components. Run gcloud components update in the Google Cloud SDK Shell.
In your app.yaml, remove the vm:true, resources: section, and manual scaling: section.
Navigate to Compute -> App Engine -> Versions and record the <default-version-number>. Mine looks like 20150722t1245032 with the words (default) indicating the default version.
Deploy the application, set the default, and specify the default version. gcloud preview app deploy "...\app.yaml" --set-default --version=<default-version-number>.
Navigate to Compute -> Compute Engine -> VM instances. Select the default instance and delete.
I was also taught how to stop deploying additional instances:
The key is to specify the version number gcloud preview app deploy "...\app.yaml" --set-default --version=<version-number>. #ZacharyNewman was able to help me with this problem.
And finally, this is how to delete the additional versions of an instance:
Navigate to Compute -> App Engine -> Versions and delete the versions you don't want.
Navigate to Compute -> Compute Engine -> VM instances. Select the instances you don't want and delete.
Hope this helps!
There might be a simpler way to explain this -- "basically, you cannot delete a version that's receiving 100% of the traffic."
Therefore, you just need to create a non managed VM, like a simple helloworld application. Then, you can move all of the traffic to this helloworld application (see graphic, I named mine version 0), then, delete version 20160... or whatever the name of your vm is.
At some point in time, you're probably going to experiment or spin up your managed VM again. When you do that, it will automatically start getting 100% of the traffic.
Or, if you happen to know version number receiving 100% of the traffic, you can always deploy a simple, non managed VM, with this version.
In Google Cloud Console under App Engine -> Versions , select the default version of your managed VM application and use STOP button to turn it off.
I ran into the same problem this is how i was able to stop the managed VM permanently. Just go to appengine -> settings -> disable application. This will automatically stop and delete your VM. In future if you want to run managed vm just enable application this will redeploy your application to the last known version.

Resources