innmind / ark
3.1.0
2021-02-13 16:48 UTC
Requires
- php: ~7.4|~8.0
- innmind/immutable: ~3.5
- innmind/operating-system: ~2.0
- innmind/scaleway-sdk: ~2.0
- innmind/ssh-key-provider: ~2.0
- innmind/url: ~3.3
- ovh/ovh: ^2.0
- ramsey/uuid: ^3.8
Requires (Dev)
- innmind/black-box: ^4.16
- innmind/coding-standard: ^1.1
- phpunit/phpunit: ~9.0
- vimeo/psalm: ~4.4
This package is auto-updated.
Last update: 2024-09-14 00:54:25 UTC
README
Ark 是一个简单的工具,用于启动新的服务器,并废弃您基础设施中正在运行的服务器。
它与 Ovh api 和 vps 端点一起工作,或者与 Scaleway 一起使用。
只能请求 Ark 数组提供的安装被废弃。
Ovh 实现细节
由于无法通过 Ovh api 订购新服务器,因此该库依赖于您的服务器状态。
如果服务器已停止,则在请求新服务器时认为它是可用的。当选择服务器作为新服务器时,它将使用您必须提供的 模板 ID 重新安装服务器,连接到服务器的唯一方式将是通过 ssh 密钥(我们无法自动化重新安装,因此不会生成密码)。
使用 ovh 废弃服务器只是简单地停止服务器(允许它在请求新服务器时被视为可用)。
安装
composer require innmind/ark
用法
Scaleway
use function Innmind\Ark\scaleway; use function Innmind\ScalewaySdk\bootstrap as sdk; use Innmind\OperatingSystem\Factory; use Innmind\ScalewaySdk\{ Token, Region, User, Organization, Image, }; use Innmind\SshKeyProvider\Local; use Innmind\Url\Path; $os = Factory::build(); $sdk = sdk($os->remote()->http(), $os->clock()); $scaleway = $sdk->autnenticated(new Token\Id('uuid')); // create an api token at https://console.scaleway.com/account/credentials $ark = scaleway( $scaleway->servers(Region::paris1()), $scaleway->ips(Region::paris1()), $scaleway->users(), $os->process(), new Local( $os->control()->processes(), Path::of('/home/{serverUser}/.ssh'), ), new User\Id('your user uuid'), new Organization\Id('the organization uuid you want to create servers in'), new Image\Id('the image uuid you want to build'), ); $installation = $ark->forge()->new(); $installAppOn($installation->location()); $ark->array(); // will contain the new server now
Ovh
第一步是购买来自 ovh 的 vps 服务器,然后您可以开始编写这样的代码
use function Innmind\Ark\ovh; use Innmind\OperatingSystem\Factory; use Innmind\SshKeyProvider\Local; use Innmind\Url\Path; use Ovh\Api; $os = Factory::build(); $ark = ovh( new Api(/* args */), new Local( $os->control()->processes(), Path::of('/home/{serverUser}/.ssh'), ), $os, ); $installation = $ark->forge()->new(); $installAppOn($installation->location()); $ark->array(); // will contain the new server now
您可以参考 ovh 文档 了解如何生成构建 Api
对象所需的令牌。
重要:您需要自己生成消费者密钥,因为它不能自动化。该库需要以下访问权限才能正常工作: POST</me*>
、DELETE</me*>
、GET</vps*>
和 POST</vps*>
。