15.2. 向 Satellite 服务器添加 Google GCE 连接
在 Satellite 中将 Google Compute Engine (GCE)添加为计算资源。要使用 CLI 而不是 Satellite Web UI,请参阅 CLI 过程。
流程
- 在 Google GCE 中,以 JSON 格式生成服务帐户密钥。
将该文件从本地机器复制到 Satellite 服务器:
# scp gce_key.json root@satellite.example.com:/usr/share/foreman/gce_key.json在 Satellite 服务器上,将服务帐户密钥的所有者改为
foreman用户:# chown foreman /usr/share/foreman/gce_key.json在 Satellite 服务器上,为您的服务帐户密钥配置权限,以确保该文件可读:
# chmod 0600 /usr/share/foreman/gce_key.json在 Satellite 服务器上,为您的服务帐户密钥恢复 SELinux 上下文:
# restorecon -vv /usr/share/foreman/gce_key.json- 在 Satellite Web UI 中,导航到 Infrastructure > Compute Resources,再点 Create Compute Resource。
- 在 Name 字段中输入计算资源的名称。
- 从 Provider 列表中,选择 Google。
- 可选:在 Description 字段中输入资源的描述。
- 在 Google Project ID 字段中,输入项目 ID。
- 在 Client Email 字段中,输入客户端电子邮件。
-
在 Certificate Path 字段中输入服务帐户密钥的路径。例如:
/usr/share/foreman/gce_key.json。 - 点 Load Zones,从 GCE 环境中填充区域列表。
- 从 Zone 列表中,选择要使用的 GCE 区域。
- 点 Submit。
CLI 过程
- 在 Google GCE 中,以 JSON 格式生成服务帐户密钥。
将该文件从本地机器复制到 Satellite 服务器:
# scp gce_key.json root@satellite.example.com:/usr/share/foreman/gce_key.json在 Satellite 服务器上,将服务帐户密钥的所有者改为
foreman用户:# chown foreman /usr/share/foreman/gce_key.json在 Satellite 服务器上,为您的服务帐户密钥配置权限,以确保该文件可读:
# chmod 0600 /usr/share/foreman/gce_key.json在 Satellite 服务器上,为您的服务帐户密钥恢复 SELinux 上下文:
# restorecon -vv /usr/share/foreman/gce_key.json使用
hammer compute-resource create命令将 GCE 计算资源添加到 Satellite 中:# hammer compute-resource create \ --email "My_GCE_Email" \ --key-path "Path_To_My_GCE_Key.json" \ --name "My_GCE_Compute_Resource" \ --project "My_GCE_Project_ID" \ --provider "gce" \ --zone "My_Zone"