LoadBalancer Pools
Warning
Load balancing functions accessed via the neutron endpoint are deprecated and will be removed in a future release. Users are strongly encouraged to migrate to using the octavia endpoint. This library does not support the octavia endpoint yet. Consider helping us to implement it .
More information can be found in the official documentation.
Create
$networking = $openstack->networkingV2();
// Options for pool
$options = [
'name' => 'poolName',
'description' => 'Load Balancer Pool',
'listenerId' => '{listenerId}',
'adminStateUp' => true,
'protocol' => 'HTTPS',
'lbAlgorithm' => 'ROUND_ROBIN',
'sessionPersistence' => [
'type' => 'APP_COOKIE',
'cookie_name' => 'example_cookie'
]
];
// Create the pool
$pool = $networking->createLoadBalancerPool($options);
Read
$read = $openstack->networkingV2();
// Get the pool
$pool = $read->getLoadBalancerPool('{poolId}');
$pool->retrieve();
List
$networking = $openstack->networkingV2();
foreach ($networking->listLoadBalancerPools() as $pool) {
// Do Stuff
}
Update
$networking = $openstack->networkingV2();
// Get the pool
$pool = $networking->getLoadBalancerPool('{poolId}');
$pool->name = 'newPool';
$pool->description = 'New Description';
$pool->update();
Delete
$networking = $openstack->networkingV2();
// Get the pool
$pool = $networking->getLoadBalancerPool('{poolId}');
$pool->delete();
Add Member
$networking = $openstack->networkingV2();
// Get the pool
$pool = $networking->getLoadBalancerPool('{poolId}');
// Member options
$options = [
'address' => '10.1.2.3',
'protocolPort' => 443,
'weight' => 1,
'adminStateUp' => true,
'subnetId' => '{subnetId}'
];
$member = $pool->addMember($options);
Get Member
$networking = $openstack->networkingV2();
// Get the pool
$pool = $networking->getLoadBalancerPool('{poolId}');
$pool->retrieve();
// Get a member
$member = $pool->getMember('{memberId}');
$member->retrieve();
Delete Member
$networking = $openstack->networkingV2();
// Get the pool
$pool = $networking->getLoadBalancerPool('{poolId}');
$pool->retrieve();
// Get a member
$member = $pool->getMember('{memberId}');
$member->delete();
Add Health Monitor
$networking = $openstack->networkingV2();
// Get the pool
$pool = $networking->getLoadBalancerPool('{poolId}');
$pool->retrieve();
// Health Monitor options
$options = [
'type' => 'HTTPS',
'delay' => 1,
'timeout' => 1,
'httpMethod' => 'GET',
'urlPath' => '/',
'expectedCodes' => '200,201,302',
'maxRetries' => 5,
'adminStateUp' => true
];
$healthmonitor = $pool->addHealthMonitor($options);