GCP: How to Retain resource on delete deployment? - google-cloud-platform

I want to retain External IP address created 1st time and use it again after deleting and recreating deployment.
I searched in documentation but did't find anything useful.
Is there any way I can specify in .jinja file to retain resources?

In order to use always the same IP in Google Cloud Platform, you need to reserve a static external IP.
After that you should define your service to use that static IP.
type: LoadBalancer
loadBalancerIP: "YOUR.IP.ADDRESS.HERE"
Keep in mind that in Google Cloud Platform every time the VM instance is restarted it will get a different random external IP assigned. The same goes for GKE service, if you recreate it, it will get a different external IP each time it gets created. If you want to have the same IP, you will need to reserve a static external IP.

Related

AWS ECS Containers and External DNS

We have AWS ECS instances.
We're using an external service (Twilio) that needs to reach a specific container:port.
And it's SSL, so it has to be a DNS name
Currently, our Upgrade scripts assigns each container an entry in Route53, and I can use a combination of nslookup and my external IP address to discover my name (and then set an env var) on bootup.
But if containers crash, my upgrade script won't have run, so updating Route 53 won't have happened.
Is this problem already solved in some way? At this point, I'm looking at 2 or 3 days to implement a solution.
I don't believe I can use Service Discovery, as SD uses the internal IP address and would be in foo.local, which isn't externally accessible.
At this point, I think I have to write a program that determines what my DNS name needs to be and updates Route 53. That seems simple, but I also have to add permissions to update Route 53 to the IAM user inside the container, and that sounds like a security problem. I'd write a different program to expire dead names.
Is there a better way? This doesn't seem like that unique a problem.
Isn't this the problem that ECS Services and their integration with AWS Load Balancers solve? If you have an ECS task that needs to run for a long time, and it needs to be accessible at a public address, then it needs to run in an ECS service that is configured to use a public load balancer.

Assigning domain name to Google Cloud VM

I'm attempting to assign a domain name to my Google Cloud VM external IP. I was following some walkthroughs and getting a bit confused. I set up apache with a simple "Hello" message when you visit my external IP. The walkthroughs I'm following are providing steps to reserve a new static external IP and creating a DNS zone.
Could someone provide clarification on why I would need to secure a new static external IP address when it appears I already have one assigned?
As discussed by #Ferregina Pelona in the comment section. The public IP that your VM already has is an ephimeral one which means that if the VM is stopped or restarted, there is a possibility this public IP changes. The problem will be that if it changes, your DNS will continue pointing to the old one which means your site will be not accesible until you update the DNS with the new IP. Reserving the public IP will warranty your VM always has the same IP.
Also, added by #DazWilkin. it should be more explicit in the documentation but I assume (!) it's an ephemeral IP. I submitted doc feedback for this.
I assume you're following a guide like [1]
The tutorial demonstrates the following steps when assigning a domain to a VM which would act as a server:
-Register a domain name using Google Domains or Cloud Domains
-Create a virtual machine (VM) instance
-Run a basic Apache web server
-Set up your domain using Cloud DNS
-Update name servers
-Verify your setup
However, there is a very important note that I believe clarifies completely the scenario you faced and the questions regarding this which states:
Note:By default, the VM instance that you create receives an ephemeral external IP address. Ephemeral external IP addresses are lost whenever the VM instance shuts down or reboots for any reason (for example, maintenance). To avoid shutdowns and reboots, use a static external IP address for web hosting. For instructions about how to reserve a static external IP address, see Reserving a static external IP address.
My suggestion would be that you try always to find an official docummentation according to the configuration/products you're expecting to use so as shown in this section, these are the advices that could avoid you yo fall into errors while moving forward. I hops this info make sense for you...
Cheers,

Instance is running but ip shows nothing

I have a google cloud platform, with a VM instance and a SQL. Today they got suspended because the free trial ended. I restarted them both and now they are running. But when i try to go to the ip of the VM instance in my browser, it says This site can’t be reached and "refused to connect". Note that i know nothing about Google Cloud and instances, i just need to have my moodle up and running again.
I tried securing that it allowed http and https in the console. (Ref to this)
The external DNS setting is correct.
And i checked if it was on localhost (ref to this question)
Please help.
If you were using an ephemeral external IP address, that address has been release when the instance was stopped.
If you were using a static external IP address, that address was also released the moment your trial expired, hence reserved IPs generate costs.
When your re-started the instance, probably it received a new IP address.
Check for the external IP address that the instance is currently using and try to use it.
You can see the instances running in your project here: https://console.cloud.google.com/compute/instances
The resources you created during the trial are stopped and If you upgrade within 30 days of the end of the trial, you can restore the resources you created during the trial.
https://cloud.google.com/free/docs/gcp-free-tier#end
What happened is that all resources you created during the trial were stopped.
As Neo mentioned, if you didn’t have your external IP address reserved, the IP was released when the instances were stopped and when you started your instances again, GCP provided a new External IP.
You can check what External IP you have on the External IP addresses, and try to access your moodle through this new IP.
To avoid this problem in the future you can promote your ephemeral external IP address, you can use this guide as reference or follow the next steps:
In the Cloud Console, go to the External IP addresses page.
In the Type column, change the address type to Static for the IP address you want to promote.
Provide a name for the new static IP address and click Reserve.
In this way, the next time you stop your instance you will keep your IP.
Nevertheless, you are not charged for static external IP addresses that are assigned to forwarding rules.
Also you can consult the following documentation for External IP address pricing, in which the documentation provides you pricing for static and ephemeral external IP addresses.

Google Cloud managed instance group issue with plesk

I'm losing my mind over this so i thought I would ask about it. I have a VM instance that I was asked to put into managed instance group so that later on we can stuff like load balancing and Cloud armor.
This Vm instance has plesk panel that is configured with a website on it which is configured with a public domain to point to it.
I shut down the vm instance, create an image, then create instance template and finally create the managed instance group. The problem is that the instances that launch will have their internal and external ip addresses different then the original vm obviously so none of them will work until I ssh inside the vm instances and do some repairs like : Plesk repair all and that doesn't fix everything.
Essentially lets say original vm has internal ip : 11.11.11.1 and external ip : 20.20.20.1
when i create the managed instance group the first vm launching from the template will have
internal ip : 11.11.11.2 and external ip 20.20.20.2
but the config for plesk was setup for the first set of ips, so every instance created will be usesless as a webserver till they are fixed
Ive watched a lot of the tutorials on Managed vm instance groups, but none of them solve this issue. I'm trying to create a managed instance group of webservers that will go into a load balancer later.The tutorials online show just some simple start up script with one page being load balanced...
Any help is appreciated.
Thank you
As long as you want to host a single VM in Managed Instance Group, you can create an instance template that is bound to specific internal and/or external IP.
You can follow by analogy this example of creation MIGs with fixed IP addresses:
https://cloud.google.com/vpc/docs/special-configurations#configuring_the_gateways
As I don't know Plesk, please clarify in your question:
whether you need to host more than 1 VM in the group
whether Plask needs to know each individual VM by its both external & internal IP. It seems more natural to point Plesk to the loadbalancer's IP that routes the traffic to one of the VMs in the group.
why the solution with registration in startup-script didn't worked out.
Use :
plesk bin reconfigurator --autoconfigure
place on startup script of instance template

How do you change your external ip?

What im trying to do is bypass ip detection from websites that i crawl.
Each website limit the amount of times per day you can crawl the site.
They limit your actions by reading your ip.
I use virtual machine (gcloud) to do my crawling so i won't keep my personal pc running.
When this happens, the website puts a block because of my ip.
Im trying to bypass this detection by getting a new ip.
My vm everytime i stop and restart the instance gives me the same 2 external ip addresses.
And in gcloud i thought since the setting was not static and set to ethereal, they would give you a new ip each time you stop the instance, but no.
They only flip flop between the same 2 external ip addresses.
I've learned that in my vm, the external ip is the ip websites look at to see if this address has been here before.
If i can continuously get a new address (like every time i stop the vm) i can keep crawling the websites.
BUT, the vm only gives me the same 2 external ip addresses... I've read that there is a shell command where you can demand a new ip but i do not know how to do this.
I would recommend you to assign a static IP to your VM and change it when you need to do it for your use case. You can change or assign an external IP address, either ephemeral or static, to an existing instance by modifying the instance's access configuration.