Add support for Juju network spaces
Juju 2.0 provides support for network spaces, allowing charm authors to support direct binding of relations and extra-bindings onto underlying network spaces. Add public and cluster extra bindings to this charm to support separation of client facing and cluster network traffic using Juju network spaces. Existing network configuration options will still be preferred over any Juju provided network bindings, ensuring that upgrades to existing deployments don't break. Change-Id: I4df75a40f5308f701f15c45d3d7b1df1e03832ad
This commit is contained in:
parent
d82e89ea20
commit
f7c587f02b
|
@ -5,4 +5,4 @@ bin
|
|||
.tox
|
||||
*.sw[nop]
|
||||
.idea
|
||||
*.pyc
|
||||
*.pyc
|
||||
|
|
23
README.md
23
README.md
|
@ -72,6 +72,29 @@ You can use the Ceph OSD and Ceph Radosgw charms:
|
|||
- [Ceph OSD](https://jujucharms.com/precise/ceph-osd)
|
||||
- [Ceph Rados Gateway](https://jujucharms.com/precise/ceph-radosgw)
|
||||
|
||||
## Network Space support
|
||||
|
||||
This charm supports the use of Juju Network Spaces, allowing the charm to be bound to network space configurations managed directly by Juju. This is only supported with Juju 2.0 and above.
|
||||
|
||||
Network traffic can be bound to specific network spaces using the public (front-side) and cluster (back-side) bindings:
|
||||
|
||||
juju deploy ceph --bind "public=data-space cluster=cluster-space"
|
||||
|
||||
alternatively these can also be provided as part of a Juju native bundle configuration:
|
||||
|
||||
ceph:
|
||||
charm: cs:xenial/ceph
|
||||
num_units: 1
|
||||
bindings:
|
||||
public: data-space
|
||||
cluster: cluster-space
|
||||
|
||||
Please refer to the [Ceph Network Reference](http://docs.ceph.com/docs/master/rados/configuration/network-config-ref) for details on how using these options effects network traffic within a Ceph deployment.
|
||||
|
||||
**NOTE:** Spaces must be configured in the underlying provider prior to attempting to use them.
|
||||
|
||||
**NOTE**: Existing deployments using ceph-*-network configuration options will continue to function; these options are preferred over any network space binding provided if set.
|
||||
|
||||
# Contact Information
|
||||
|
||||
## Authors
|
||||
|
|
|
@ -72,6 +72,7 @@ from utils import (
|
|||
get_public_addr,
|
||||
assert_charm_supports_ipv6,
|
||||
is_unit_paused_set,
|
||||
get_cluster_addr,
|
||||
)
|
||||
from ceph_broker import (
|
||||
process_requests
|
||||
|
@ -310,6 +311,9 @@ def emit_cephconf():
|
|||
cephcontext['public_addr'] = dynamic_ipv6_address
|
||||
if not cluster_network:
|
||||
cephcontext['cluster_addr'] = dynamic_ipv6_address
|
||||
else:
|
||||
cephcontext['public_addr'] = get_public_addr()
|
||||
cephcontext['cluster_addr'] = get_cluster_addr()
|
||||
|
||||
# Install ceph.conf as an alternative to support
|
||||
# co-existence with other charms that write this file
|
||||
|
|
|
@ -13,6 +13,8 @@ from charmhelpers.core.hookenv import (
|
|||
unit_get,
|
||||
cached,
|
||||
config,
|
||||
network_get_primary_address,
|
||||
log, DEBUG,
|
||||
status_set,
|
||||
)
|
||||
from charmhelpers.core import unitdata
|
||||
|
@ -73,6 +75,32 @@ def get_host_ip(hostname=None):
|
|||
return answers[0].address
|
||||
|
||||
|
||||
@cached
|
||||
def get_public_addr():
|
||||
if config('ceph-public-network'):
|
||||
return get_network_addrs('ceph-public-network')[0]
|
||||
|
||||
try:
|
||||
return network_get_primary_address('public')
|
||||
except NotImplementedError:
|
||||
log("network-get not supported", DEBUG)
|
||||
|
||||
return get_host_ip()
|
||||
|
||||
|
||||
@cached
|
||||
def get_cluster_addr():
|
||||
if config('ceph-cluster-network'):
|
||||
return get_network_addrs('ceph-cluster-network')[0]
|
||||
|
||||
try:
|
||||
return network_get_primary_address('cluster')
|
||||
except NotImplementedError:
|
||||
log("network-get not supported", DEBUG)
|
||||
|
||||
return get_host_ip()
|
||||
|
||||
|
||||
def get_networks(config_opt='ceph-public-network'):
|
||||
"""Get all configured networks from provided config option.
|
||||
|
||||
|
@ -87,10 +115,6 @@ def get_networks(config_opt='ceph-public-network'):
|
|||
return []
|
||||
|
||||
|
||||
def get_public_addr():
|
||||
return get_network_addrs('ceph-public-network')[0]
|
||||
|
||||
|
||||
def get_network_addrs(config_opt):
|
||||
"""Get all configured public networks addresses.
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@ tags:
|
|||
peers:
|
||||
mon:
|
||||
interface: ceph
|
||||
extra-bindings:
|
||||
cluster:
|
||||
public:
|
||||
provides:
|
||||
nrpe-external-master:
|
||||
interface: nrpe-external-master
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
[global]
|
||||
{% if old_auth %}
|
||||
{%- if old_auth %}
|
||||
auth supported = {{ auth_supported }}
|
||||
{% else %}
|
||||
{%- else %}
|
||||
auth cluster required = {{ auth_supported }}
|
||||
auth service required = {{ auth_supported }}
|
||||
auth client required = {{ auth_supported }}
|
||||
{% endif %}
|
||||
{%- endif %}
|
||||
keyring = /etc/ceph/$cluster.$name.keyring
|
||||
mon host = {{ mon_hosts }}
|
||||
fsid = {{ fsid }}
|
||||
|
@ -17,17 +17,16 @@ mon cluster log to syslog = {{ use_syslog }}
|
|||
debug mon = {{ loglevel }}/5
|
||||
debug osd = {{ loglevel }}/5
|
||||
|
||||
{%- if ceph_public_network is string %}
|
||||
{% if ceph_public_network is string %}
|
||||
public network = {{ ceph_public_network }}
|
||||
{%- endif %}
|
||||
{%- if ceph_cluster_network is string %}
|
||||
cluster network = {{ ceph_cluster_network }}
|
||||
{%- endif %}
|
||||
|
||||
{% if public_addr %}
|
||||
{%- if public_addr %}
|
||||
public addr = {{ public_addr }}
|
||||
{% endif %}
|
||||
{% if cluster_addr %}
|
||||
{%- endif %}
|
||||
{%- if cluster_addr %}
|
||||
cluster addr = {{ cluster_addr }}
|
||||
{%- endif %}
|
||||
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
import test_utils
|
||||
import charmhelpers.core.hookenv as hookenv
|
||||
import utils as ceph_utils
|
||||
|
||||
TO_PATCH_SPACES = [
|
||||
'network_get_primary_address',
|
||||
'log',
|
||||
'get_host_ip',
|
||||
'config',
|
||||
'get_network_addrs',
|
||||
'cached',
|
||||
]
|
||||
|
||||
|
||||
class CephNetworkSpaceTestCase(test_utils.CharmTestCase):
|
||||
def setUp(self):
|
||||
super(CephNetworkSpaceTestCase, self).setUp(ceph_utils,
|
||||
TO_PATCH_SPACES)
|
||||
self.config.side_effect = self.test_config.get
|
||||
|
||||
def tearDown(self):
|
||||
# Reset @cached cache
|
||||
hookenv.cache = {}
|
||||
|
||||
def test_no_network_space_support(self):
|
||||
self.get_host_ip.return_value = '192.168.2.1'
|
||||
self.network_get_primary_address.side_effect = NotImplementedError
|
||||
self.assertEqual(ceph_utils.get_cluster_addr(),
|
||||
'192.168.2.1')
|
||||
self.assertEqual(ceph_utils.get_public_addr(),
|
||||
'192.168.2.1')
|
||||
|
||||
def test_public_network_space(self):
|
||||
self.network_get_primary_address.return_value = '10.20.40.2'
|
||||
self.assertEqual(ceph_utils.get_public_addr(),
|
||||
'10.20.40.2')
|
||||
self.network_get_primary_address.assert_called_with('public')
|
||||
self.config.assert_called_with('ceph-public-network')
|
||||
|
||||
def test_cluster_network_space(self):
|
||||
self.network_get_primary_address.return_value = '10.20.50.2'
|
||||
self.assertEqual(ceph_utils.get_cluster_addr(),
|
||||
'10.20.50.2')
|
||||
self.network_get_primary_address.assert_called_with('cluster')
|
||||
self.config.assert_called_with('ceph-cluster-network')
|
||||
|
||||
def test_config_options_in_use(self):
|
||||
self.get_network_addrs.return_value = ['192.122.20.2']
|
||||
self.test_config.set('ceph-cluster-network', '192.122.20.0/24')
|
||||
self.assertEqual(ceph_utils.get_cluster_addr(),
|
||||
'192.122.20.2')
|
Loading…
Reference in New Issue