-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a20871
commit a2fcc7e
Showing
1 changed file
with
103 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,104 @@ | ||
# Salt Cloud Quickstart | ||
# Salt Cloud Quickstart - Salt Cloud 快速入门 | ||
|
||
https://docs.saltstack.com/en/latest/topics/cloud/qs.html#salt-cloud-qs | ||
Salt Cloud功能已经内置于Salt中,而运行Salt Cloud的最简单方法是直接在Salt Master上使用。 | ||
|
||
请注意,如果您是通过[Salt Bootstrap](https://github.com/watermelonbig/SaltStack-Chinese-ManualBook/blob/master/chapter03/03-3.Additional-Installation-Guides-补充安装说明.md#Salt-Bootstrap通用安装脚本)安装Salt的,则可能没有为您自动安装`salt-cloud`。 请使用操作系统发行版本的软件包管理器从用于安装Salt软件的同一存储库中安装继续`salt-cloud`软件包。 这些存储库将由Salt Bootstrap自动设置。 | ||
|
||
或者,可以在安装Salt时将`-L`选项传递给Salt Bootstrap脚本。` -L`选项将安装`salt-cloud`和所需的`libcloud`软件包。 | ||
|
||
本快速入门将引导您完成设置云主机和定义一些要创建的虚拟机的基本步骤。 | ||
|
||
> 注意:Salt Cloud有其自身的进程,并且不依赖于Salt Master,因此可以将其安装在独立的Minion上,而不是安装在Salt Master上。 | ||
## Define a Provider - 定义提供者 | ||
|
||
第一步是为您的云主机添加身份凭据。 云主机提供的凭据和其他设置都是存储在provider程序配置文件中。 Provider程序配置包含连接到云主机(例如EC2,GCE,Rackspace等)所需的详细信息,以及您要在云主机minions上设置的任何全局选项(例如Salt Master的位置)。 | ||
|
||
在您的Salt Master上,浏览到`/etc/salt/cloud.providers.d/`并创建一个名为`<provider>.conf`的文件,用`ec2`、`softlayer`等替换<provider>。 该名称可帮助您识别内容,但并不重要,只要文件以`.conf`结尾即可。 | ||
|
||
> 注意:这里提到的云主机,对于ec2这更接近于是可管理的一些云平台资源。对于单机的KVM虚拟化则是用来创建和运行VMs的物理服务器。其它云平台或虚拟化平台对这个概念的处理方法也相似。请不要误把这个提到的云主机认为是一个可管理的最小VM虚似化实现。 | ||
接下来,浏览 `Provider specifics` 章节的详细信息,并将云主机的所有必需设置添加到此文件。 这是Amazon EC2的示例: | ||
```YAML | ||
my-ec2: | ||
driver: ec2 | ||
# Set the EC2 access credentials (see below) | ||
# | ||
id: 'HJGRYCILJLKJYG' | ||
key: 'kdjgfsgm;woormgl/aserigjksjdhasdfgn' | ||
# Make sure this key is owned by root with permissions 0400. | ||
# | ||
private_key: /etc/salt/my_test_key.pem | ||
keyname: my_test_key | ||
securitygroup: default | ||
# Optional: Set up the location of the Salt Master | ||
# | ||
minion: | ||
master: saltmaster.example.com | ||
``` | ||
所需的配置因云主机而异,因此请确保您阅读了`Provider specifics` 章节的详细信息。 | ||
|
||
## List Cloud Provider Options - 查看云平台提供者的配置选项 | ||
|
||
现在,您可以查询配置的云提供商以获取可用的区域、镜像和大小。 设置VM配置文件时将使用此信息。 | ||
```bash | ||
salt-cloud --list-locations <provider_name> # my-ec2 in the previous example | ||
salt-cloud --list-images <provider_name> | ||
salt-cloud --list-sizes <provider_name> | ||
``` | ||
将`<provider_name>`替换为您定义的provider配置的名称。 | ||
|
||
##Create VM Profiles - 创建VM虚机的Profiles配置文件 | ||
|
||
在您的Salt Master上,浏览到`/etc/salt/cloud.profiles.d/`并创建一个名为`<profile>.conf`的文件,用`ec2`、`softlayer`等替换`<profile>`。 该文件必须以`.conf`结尾。 | ||
|
||
现在,您可以将要定义的任何自定义配置文件添加到此文件中。 这里有一些例子: | ||
```YAML | ||
micro_ec2: | ||
provider: my-ec2 | ||
image: ami-d514f291 | ||
size: t1.micro | ||
medium_ec2: | ||
provider: my-ec2 | ||
image: ami-d514f291 | ||
size: m3.medium | ||
large_ec2: | ||
provider: my-ec2 | ||
image: ami-d514f291 | ||
size: m3.large | ||
``` | ||
注意,在profile配置文件中的`provide`r与我们定义的提供程序名称匹配吗? 这就是Salt Cloud知道如何连接到云主机以创建具有这些属性的VM的方式。 | ||
|
||
## Create VMs - 创建虚机 | ||
|
||
通过使用以下选项调用`salt-cloud`创建VM: | ||
```bash | ||
salt-cloud -p <profile> <name1> <name2> ... | ||
``` | ||
例如: | ||
```bash | ||
salt-cloud -p micro_ec2 minion1 minion2 | ||
``` | ||
## Destroy VMs - 销毁虚机 | ||
|
||
添加`-d`参数以及需要销毁处理的minions name。 | ||
```bash | ||
salt-cloud -d minion1 minion2 | ||
``` | ||
|
||
## Query VMs - 查询虚机信息 | ||
|
||
您可以查看有关使用`--query`创建的VM的详细信息: | ||
```bash | ||
salt-cloud --query | ||
``` | ||
|
||
## Cloud Map | ||
|
||
既然您知道如何创建和存储单个VM,那么接下来,您应该学习如何使用`cloud map`一次创建多个VM。 | ||
|
||
`Cloud Map`使您可以定义基础结构图并快速配置任意数量的VMs。 在随后的运行中,将创建所有不存在的VM,并保留已配置的VMs不变。 | ||
|
||
See [Cloud Map File](https://github.com/watermelonbig/SaltStack-Chinese-ManualBook/blob/master/chapter15/15-2.Using-Salt-Cloud.md#Maps) |