Download the PHP package benmag/laravel-rancher without Composer
On this page you can find all versions of the php package benmag/laravel-rancher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download benmag/laravel-rancher
More information about benmag/laravel-rancher
Files in benmag/laravel-rancher
Package laravel-rancher
Short Description Rancher API wrapper for Laravel
License MIT
Homepage https://github.com/benmag/laravel-rancher
Informations about the package laravel-rancher
Laravel Rancher
Rancher API wrapper for Laravel. This package provides a simple interface to Rancher's (awesome) API. Orchestrate your private container service with expressive, clean PHP.
Installation
Laravel Rancher uses compose to make installation a breeze.
Install via composer
Register service provider
Add the Laravel Rancher service provider to your config/app.php
file in the providers key
Rancher facade alias
Then add the Rancher
facade to your aliases
key: 'Rancher' => Benmag\Rancher\Facades\Rancher::class
.
Configuration
Configuration can be done via your .env
file.
`
You may also publish the config file to
config/rancher.php
for editing:php artisan vendor:publish --provider="Benmag\Rancher\RancherServiceProvider"
Notes
Make sure you have authentication enabled. Without this, you might experience some weird behaviour. I still need to look into changing Environments/Projects in a slightly more coordinated way but you should just be able to instantiate a new client instance.
Usage
Laravel Rancher is incredibly intuitive to use.
Introduction
Already configured everything and just want to see it in action? Take a look at the example code below.
Host
Retrieving all Hosts
Retrieve Host by ID
Activate a Host by ID
Evacuate a Host by ID
Remove a Host by ID
Container
Retrieving all Containers
Retrieve Container by ID
Create a Container
Stack
Create a Stack
When creating a Stack, you will need to tell Rancher which Project you want to create it in.
Update an Stack
Activate Services in an Stack
Deactivate Services in an Stack
Delete a Stack
Project
Create a new Project
Activate a Project
Deactivate a Project
Delete a Project
Service
Create a Service
Update a Service
Add a Service Link
You may also add a single service link to the service. You can use the name
value to specify a link alias.
Set Service Links
The setServiceLinks
method will overwrite all of the links for that service.
Remove a Service Link
Individual service links can also be removed
Upgrade a Service
Finish a Service Upgrade
Cancel a Service Upgrade
Rollback an Upgrade
Cancel Rollback
Load Balancer Service
Create a Load Balancer
Update a Load Balancer
Add a Service Link to Load Balancer
You may also add a single service link to the service. You can use the name
value to specify a link alias.
Set Service Links for Load Balancer
The setServiceLinks
method will overwrite all of the links for that load balancer.
Remove a Service Link from Load Balancer
Individual service links can also be removed.
Machine
[todo]
Registry
Add Registry
Activate Registry
Deactivate Registry
Registry Credential
Add registry credential
Registration Token
Create Registration Token
Fetch Registration Tokens
Service Consume Map
[todo]
Certificates
Get certificates
Create a certificate
Remove a certificate
Query Building
The wrapper also provides a convenient way for you to build fairly elaborate Rancher API requests. The following methods return the instance so you can chain more constraints onto the request as required.
Filters
Rancher lets you specify filters on API resources. The type of filter to apply is set via the key. Listed below is an example of all of the filter options.
Remember: to change the field you filter on, change the key e.g.
['state' => 'active']
or['description_notnull' => null]
Include
With Rancher, you can specify additional endpoints that should be eager loaded with the request through an include
parameter. This functionality is exposed via the with
method.
Fields
Define additional fields from the API for the entity to dynamically expose. You can use this to enable access properties that are not explicitly defined by the entity class.
Scope
By default, Rancher's scope is the default Project your credentials have access too. This chained method lets you easily change the scope to another project your credentials have access to on the fly.
Of course, you may utilize the setClient
method to change the client to something completely new but if you want to change
All together now
Here is a simple example of how you can use method chaining to build elaborate Rancher API requests.
Handling Exceptions
The Rancher API will return errors as required. I am still looking for a nicer way to handle these exceptions... For the time being, simply wrap your call in a try/catch block.
Rancher API Endpoint Coverage
The Rancher API is extensive. I've attempted to cover all of the key endpoints but there are a few endpoints that are currently unimplemented.
- Host
[5/8]
- delete
- dockersocket
- purge
- Container
[7/18]
- update
- delete
- allocate
- console
- deallocate
- execute
- logs
- migrate
- setlabels
- updatehealthy
- updateunhealthy
- Environment
[6/14]
- addoutputs
- cancelrollback
- cancelupgrade
- error
- exportconfig
- finishupgrade
- rollback
- upgrade
- Project
[5/8]
- purge
- restore
- setmembers
- Service
[13/14]
- remove
- LoadBalancerService
[7/13]
- cancelrollback
- cancelupgrade
- finishupgrade
- remove
- rollback
- upgrade
- Account
[0]
- ApiKey
[0]
- Certificate
[0]
- DnsService
[0]
- externalService
[0]
- Identity
[0]
- Machine
[0]
- Mount
[0]
- ProjectMember
[0]
- StoragePool
[0]
- Volume
[0]
License
The MIT License (MIT). Please see License File for more information.