Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does cloud-init work?

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

What is the working principle of cloud-init, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

Cloud-init is a tool for linux, and cloud-init can obtain metadata from nova metadata services or config drive when the system starts up, including, but not limited to, the following customization work:

Set up default locale

Set up hostname

Add ssh keys to .ssh / authorized_keys

Set user password

Configure the network

Install the package

To implement instance customization, cloud-init performs tasks in four phases:

Local

Init

Config

Final

When cloud-init is installed, the tasks performed in these four phases will be registered with the system in the form of services. For example, in the environment of systemd, we can see the corresponding services of these four phases:

Local-cloud-init-local.service

Init-cloud-init.service

Config-cloud-config.service

Final-cloud-final.service

Local stage

As the first stage of cloud-init execution, instance does not know how to configure the network card at this time. The task of cloud-init is to get configuration information from config drive and write to / etc/network/interfaces file (or / etc/sysconfig/network-scripts/ifcfg-xxx if centos).

If there is no config drive, configure all NICs in dhcp mode. This is a very critical step, only when the network card is configured correctly, can you get the metadata.

The next section on the local phase will be analyzed in detail through experiments.

Init, config and final Pha

Normally, the instance network is configured before these three phases are executed, and the metadata has been successfully obtained. The configuration file / etc/cloud/cloud.cfg of cloud-init defines the tasks to be performed in each of the three phases, which are specified in the form of module. The real customization of instance is done by these module. Module decides what customization work to do, while metadata determines the final result of customization.

For example, if set_hostname, the module, is specified in cloud.cfg, it means that cloud-int sets the hostname of instance, and which hostname is determined by the hostname parameter in metadata.

Some module have default behavior, such as growpart, which automatically extends / partitions if not specifically specified in the metadata.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report