You have created several pre-emptible Linux virtual machine instances using Google Compute Engine. You want to properly shut down your application before the virtual machines are preempted. What should you do?
A.
Create a shutdown script named k99.shutdown in the /etc/rc.6.d/ directory
B.
Create a shutdown script registered as a xinetd service in Linux and configure a Stackdriver endpoint check to call the service
C.
Create a shutdown script and use it as the value for a new metadata entry with the key shutdown-script in the Cloud Platform Console when you create the new virtual machine instance
D.
Create a shutdown script, registered as a xinetd service in Linux, and use the gcloud compute instances add-metadata command to specify the service URL as the value for a new metadata entry with the key shutdown-script-url
Since the instance is already created Option C gets eliminated. "gcloud compute instances addmetadata”
command can be used to add or update the metadata of a virtual machine instance"
I have doubts with the answer C because the question states that "You have created the instances" so C works too but the solution cannot apply to the already created instances. D seems correct to me...
Reference:
https://cloud.google.com/compute/docs/shutdownscript#apply_a_shutdown_script_to_running_instances
Yes. The correct answer should be D.
To add a shutdown script to a running instance, follow the instructions in the Applying a startup script to running instances documentation but replace the metadata keys with one of the following keys:
shutdown-script: Supply the shutdown script contents directly with this key. Using the gcloud command-line tool, you can provide the path to a shutdown script file, using the --metadata-from-file flag and the shutdown-script metadata key.
shutdown-script-url: Supply a Cloud Storage URL to the shutdown script file with this key.
1. Preemptible instances and shutdown scripts: Google Cloud Platform's preemptible instances are cost-effective but can be terminated with short notice. To gracefully handle this, you need a shutdown script that runs before the instance is preempted.
2. Metadata and shutdown-script: Google Cloud allows you to add custom metadata to your instances. When you create a preemptible instance, you can include a shutdown-script metadata entry. The value of this entry should be your script, which will be executed automatically before the instance is preempted.
It's not C. C says "when you create the new virtual machine instance". But in the question, the instances have already been created. Thus, D. In D, "service URL" obviously means cloud storage.
Among Option C & D, option D uses shutdown-script-url but shutdown-script-url should be a Cloud storage url and not a linux service URL.
That brings us to option C
Every virtual machine instance in GCP has access to a metadata server, which provides information about the instance and allows you to configure various settings, including startup and shutdown scripts.
Startup and shutdown scripts are specified using special metadata keys in the metadata server.
shutdown-script specifies the shutdown script that should be executed when the instance is being shut down.
All other options are related to play with Linux files or services. With Preemptible VMs ,these operations are overhead. Hence it makes sense to Automate such tasks.
The answer is either C or D
I exclude D because shutdown-script-url only works with a shutdown script hosted on a cloud storage. Option D wants you to use shutdown-script-url for a locally hosted shutdown script, thus it's not the correct answer.
The answer should be C. reference to https://cloud.google.com/compute/docs/shutdownscript#apply_a_shutdown_script_to_running_instances
Regarding the answer D, it is not the option becasue no need to touch xinetd servie inside Linux.
C is the right answer. See, there is one tip. In GCP, things like these are given to the customers as a solution - like give a shutdown script. GCP won't trouble the users to know all those geeky linux stuffs. So the answer is simply C
Option D: Creating a shutdown script, registered as a xinetd service in Linux, and using the gcloud compute instances add-metadata command to specify the service URL as the value for a new metadata entry with the key shutdown-script-url is not as reliable as option C because it requires the gcloud command-line tool to be installed and configured on the virtual machine instance.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Eroc
Highly Voted 5 years agonitinz
3 years, 8 months agoVishalB
3 years, 3 months agoGini
Highly Voted 4 years, 6 months ago[Removed]
11 months agoNG123
2 years, 5 months agodsnaghxhinwtsvvmip
1 year, 7 months agopepYash
4 years agopepYash
4 years agoEkramy_Elnaggar
Most Recent 2 days, 20 hours agoBarry123456
1 month agosnehaso
3 months, 1 week agoHungdv
3 months, 2 weeks agonicksb19
4 months, 3 weeks agolisabisa
9 months agoashishdwi007
10 months agoMo7y
10 months, 1 week agokip21
10 months, 1 week agoTerryhsieh
11 months agoRLsh
1 year agoArun_m_123
1 year, 1 month agowukoon
1 year, 1 month agovc1011
1 year, 1 month agoAdityaGupta
1 year, 1 month ago