cobak78 / rancher-api
Rancher API client
v0.1.3
2017-03-23 14:40 UTC
Requires
- php: >=7.0
- guzzlehttp/guzzle: ^6.2
- ratchet/pawl: ^0.2.3
Requires (Dev)
- phpunit/phpunit: ~4
- vlucas/phpdotenv: ^2.4
This package is not auto-updated.
Last update: 2025-03-24 18:33:51 UTC
README
Rancher api client with php7 and PSR7 specification, to execute bash actions on deployed containers
Install via composer:
composer require cobak78/rancher-api
Docker
Rancher-api includes a base image with test dependencies installed in. Use docker-compose file to stand up a fpm container with the app code mounted.
Usage
Create an script to use api.
define('DOCUMENT_ROOT', dirname(__FILE__)); require_once DOCUMENT_ROOT . '/vendor/autoload.php'; use Dotenv\Dotenv; use Cobak78\RancherApi\Clients\HttpClient; use Cobak78\RancherApi\Clients\WSClient; use Cobak78\RancherApi\RancherApi; $dotenv = new Dotenv(DOCUMENT_ROOT); $dotenv->load(); $client = new HttpClient(); $wsClient = new WSClient(); $rancherApi = new RancherApi($client, $wsClient, $argv, $argc); $rancherApi->execute();
If you need to execute the same script on all deployed containers, modify script.
$rancherApi->execute(true);
this api expects at least three arguments:
- project name
- container name
- command to execute
- command parameters [optional]
php execute.php project-api fpm bin/console c:c
What it does
Rancher api, look for projects, service and containers deployed on rancher. If the connection need a web socket to execute bash action, retrieve token from rancher and creates a connection. Then decode and show the response on console.