Can't Connect to (or start?) Google Cloud Compute Instance - google-compute-engine

I attempted to restart my Windows instance (using the Start menu), but haven't been able to connect to it. After a few hours of waiting, I also tried using the Reboot button in the Google Developers Console. That didn't work either. I can't RDP into it, or even ping it. However, when I look at the instance in the GDC, it's been steady at 27% CPU usage for the duration. Anyone know what's going on or how to fix it?

You can run this gcutil command to reset the instance: gcutil --project=[project-id] resetinstance [instance-name]
If this has no effect, a suggestion would be to delete the instance without deleting the boot disk and then create a new instance with that disk. This will ensure that you get a fresh instance without losing any of your previous data.

Related

Creating a Staging VM in Google Compute Engine

I'm trying to set up a Staging VM for a site that's in production that I have just inherited. The site is running Wordpress/Woocommerce and has not been updated in a while. The VM it's hosted on is running an old version of PHP. Obviously, this all needs to be fixed up but I'm unfamiliar with GCP Compute Engine. Also any attempt to run backup/clone plugins crashes the site and requires a restore from the daily snapshot which is very annoying.
Is it possible to clone the VM/disk to a new instance, point that at a temporary domain, and test/update the site? I have been trying to do this for a while now without much luck any suggestions would be much appreciated. Thanks.
Creating a clone of an existing VM is possible and quite easy.
Create a snapshot of the VM. If possible stop the VM before doing this to ensure 100% accuracy - this way you will have exact snapshot of the drive without any errors. You can do it while the VM is running too if stopping it is out of the question.
Create a VM from the shapshot - select as a boot disk a snapshot that you've just created. Remember to assign a static public IP to this VM (unless you want it changed after VM restart and since you're going to do some configuration this would likely happen). You can change the VM's specs at this time too - nothing stops you from adding/removing CPU's, RAM etc. It may well be that your VM is underutilised and you can use something smaller to save costs. Or the opposite.
Start the machine. Now you can modify your WP configuration to point to a new domain. Depending on the SSL certificate - you can either use external one or the one provided by GCP (most convinient solution).
If you already own a domain you want to use for staging you can host it in Cloud DNS or at some other provider - just point it to the external IP you just reserved.
If you will be hosting your domain in the Cloud DNS then you will find necessary infomration in the documentation about managed zones (domains).
You can also consider creating a new VM and setting it as a template for creating a group of VM's (managed autoscaled group) and creating an external HTTPS load balancer in front of it. But this adds a little to the complexity so it's just my idea if you needed to handle a lot more traffic.

Unable to connect with Google Compute Engine

My GCP Compute engine is down. In GCP console it is up and running. It is an Ubuntu 18.04 server with 0.6GB memory(an always free tier compute engine). It was not restarted for more than couple of months. The system usage was around 60% last checked. I have already checked this answer. And none of them seems valid for me(seems so).
Free disk stands at 54%.
SSH perfectly configured.
No firewall issue.
It just seemed the VM stopped responding putting the hosted url down. When I checked Compute engine monitoring tabs, all the graphs were normal without any visible changes. I even checked the logging but no system crash kind of logs were present. I stopped and restarted the compute engine, and it started working perfectly, as nothing happened. In AWS, the VM instance failed System Reachability tests in such scenarios.
Does GCP has something similar like AWS system reachability test?
Any possible logs or something, by which I can understand the reason why the Compute Engine stopped responding?
There are different kinds of test with custom scenarios in your project , please find it on reference link [1]
[1] https://cloud.google.com/network-intelligence-center/docs/connectivity-tests/how-to/running-connectivity-tests

Dynamic ip address in minishift causes problems to spin up

I recently installed minishift, the openshift origin environment built on docker on my laptop. The instance works fine at the first time when installed. However, when I poweroff my machine and then try to start the system again, it fails.
The issue is the ip address assigned while provisioning the VM first time changes when the system is restarted.
The issue doesn't persist when I delete the VM and then start it again. What's the solution for this? I have tried several possible solutions provided on the internet.
I have also tried --host-only-cidr "192.168.99.1/24" to minishift while starting it for the first time. But that didn't help either.
I have found the solution. Though it requires using a third party script, currently there's no provision to assign static ip to Virtualbox VMs. I have used the library https://github.com/ahilbig/docker-machine-ipconfig and performed the steps followed, which provide a static ip address for minishift. The command is
minishift-ipconfig static <your_ip_address>
Please note the ip address should be the same which was assigned while creating the VM.

What is difference between snapshot, image and persistent disk on Google Compute Engine?

I have a compute engine instance on google cloud which is running fine. user base is increasing and I wish to upgrade to a bigger compute engine in terms of cpu and memory.
What is the most easy way to do such migration?
What is the snapshot, image, persistent disk features in google compute engine? Are they anyway useful to my task?
I figured it out. Lennert answer is good. I will add few more things to complete it. You can always stop a VM, edit the CPU/memory and restart the VM. But this action may change the external IP address and cause lot of issues. You can handle it but it may cause further downtime. You may have to update the new IP address at DNS and inside the code. One way to avoid this hassle is that you should Reserve a static IP adreess [in console, go to NETWORKING > EXTERNAL IP ADDRESS > RESERVE A STATIC IP ADDRESS]. If you do this, your ip address will not change once you restart the VM.
Image is aka Operating System. While creating a VM, you are asked to choose a boot disk, disk which is used to boot your VM from. You can select from pre-defined images.
Snapshot is the copy of the disk. If it is a boot disk, it contains the operating system image too. We can create a snapshot of an existing disk and use it as the boot disk while creating new VM.
Persistent Disk is the disk that can persists even if you delete the VM [provided you have deselect the option of deleting it while deleting the VM]. We can delete VM and use a persistent disk to create new ones. We can simply pay for persistent disk only, without having any VM.
The easiest way is to stop the machine, change the machine type from the console and start the machine again. No need to create backups (snapshots), new VM's, etc.

Cant Disable Google Compute Engine

I am trying to stop google compute engine from
https://console.developers.google.com/project/myapp/apiui/api
As soon as I click the off button next to google compute engine, I see the message "Disabling Google Compute Engine...".
The message never goes away and Google Compute Engine is still on.
I'm using Chrome on Windows.
I'm trying to restart the GCE service because I keep getting:
Error: API rate limit exceeded when I try to run gcutil listinstances after setting up my instance for the first time.
Can someone help with either the service restart issue or the API rate limit exceeded issue?
If you'd like to restart your instance, there are two ways to do this. For the first one, go to your VM Instances page (https://console.developers.google.com/project/{project-id}/compute/instances) Be sure to fill in your project-id, or simply go to the page from the console.
Then click on the instance you'd like to restart, and on that page, there's a simple "reboot" button. If this still isn't working, try the next option.
The next option is to login to your instance and do sudo reboot. My guess is this will succeed and not fix your problem, but it will either succeed of tell you why it didn't. Alternatively you can use sudo poweroff and use the console to restart your instance.
You have 4 options to stop your instance.
If you would like to stop your instance using Google Cloud Platform Console, you may use this guide:
Go to the VM instances page in the GCP Console.
Select one or more instances that you want to stop.
At the top of the VM instances page, click Stop.
To stop your instance using gcloud tool, please follow this procedure.
Open your Google Cloud Shell in GCP.
Use the instances stop command and specify one or more instances that you want to stop.
$ gcloud compute instances stop your-instance1 your-instance-2
In the API, construct a POST request to stop an instance.
POST https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/instances/example-instance/stop
To stop your instance through the OS for Linux and Windows.
In the GCP Console, go to the VM Instances page.
In the list of virtual machine instances, click SSH in the row of the instance that you want to connect to.
Use the sudo shutdown -h now or sudo poweroff commands. Execute one of these commands while you are logged into the virtual machine:
$ sudo shutdown -h now
$ sudo poweroff
You can reboot a Windows instance, similar to sudo reboot above, using the Start menu. In the Start menu, click on the arrow next to Log off and click Restart.