Built-in 'centos-6' with no cloud-init installed by default?

511 views
Skip to first unread message

Pedro Diogo

unread,
May 22, 2018, 10:58:11 AM5/22/18
to gce-discussion
Hello everyone,

I need to boot a VM making use of cloud-init metadata
such as: 

zone
.createVM(name, {
os: 'centos-6',
metadata: {
items: [{
key: "user-data",
value: b64CloudConfig
}]
},
networkInterfaces: [{
accessConfigs: [{
type: "ONE_TO_ONE_NAT",
name: "External NAT",
// natIP: address
}],
"network": "global/networks/default"
}],
})
.then(data => {

but it is failing as, apparently, there is no cloud-init install per default on this centos-6/7 public image. 

As I need cloud-init for these VMs, do I need to first create an OS of my own? If so, would I then be able to create a VM properly with the provided cloud-config? Could not really find any info regarding
user-data
metadata key, so I am not really sure if it will work. Also, it will be b64 encoded. 

Any help is greatly appreciated. Thank you in advance.

Regards,

Fady (Google Cloud Platform)

unread,
May 22, 2018, 5:11:59 PM5/22/18
to gce-discussion

Hello Pedro,


From the example above, it seems that you are using OpenStack to create a VM instance. Hence, if you are trying to create a VM instance on Google Compute Engine the above will not work.


In a nutshell, metadata is implemented differently in Google Compute Engine, and does not use cloud-init packages. A similar functionality to OpenStack “user-data” would be using a startup-script and shutdown-script, but with the difference that they execute every time you restart your instance. You may check the differences between Openstack and Google Compute Engine at this document.


Pedro Diogo

unread,
May 24, 2018, 6:48:55 PM5/24/18
to gce-discussion
Hi Fady,

Thank you very much for this. Really appreciated.

The VM is actually created with an external IP (managed to get this ephemeral ip via the accessConfigs array ). 
I am thus strugling to understand why the user-data did not work. I'm ok with using OpenStack. Shouldn't it have worked fine? Is it a OS problem, or am I using the lib incorrectly? Apologies, but I don't understand what the problem is. I understand the differences between OpenStack and GCP, but this code did work except for the user-data (cloud-config).

I'm using the const Compute = require('@google-cloud/compute'); package - is this the problem? Does it work only for GCP?

Again, thank you very much.

Regards,

Fady (Google Cloud Platform)

unread,
May 25, 2018, 8:35:14 PM5/25/18
to gce-discussion

Hello Pedro,


I am not suggesting to use OpenStack, as that was just my assumption that you are using it due to your code. If you are trying to use cloud-init, the package does not come pre-installed on any image on GCE with the exception of Container Optimized images like this example.


However, as I explained in my past message a startup/shutdown script is an alternative as per this document. That said, you may either use the key:” startup-script” or manually install cloud-init, and create a custom metadata as per this suggestion at this cloud-init document. If you chose the latter, I found this github page that could be helpful in setting up cloud-init with the correct metadata paths.


As for your last question, you seem to be using the correct client libraries for Node.js per this document.


Message has been deleted

Frank Müller

unread,
Jul 26, 2019, 11:05:32 AM7/26/19
to gce-discussion
Hi Fady,

In our project we so far use the images 'coreos-stable / coreos-cloud'  and 'ubuntu-1804-lts / ubuntu-os-cloud'  with cloud-init. Now we wanted to add 'centos-7 / centos-cloud' and found out that there is no cloud-init. Any solution?

Thanks,
Mue
Reply all
Reply to author
Forward
0 new messages