You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org

Difference between revisions of "Wikimedia Cloud Services team/EnhancementProposals/ceph client refactor"

From Wikitech-static
Jump to navigation Jump to search
imported>David Caro
imported>David Caro
Line 28: Line 28:
* <code>access type</code> this would be an abstraction over actual ceph auth permissions. Something like <code>glance_client</code>, <code>nova_client</code>, <code>radosgw_client</code>, <code>osd_server</code>, <code>mon_server</code>, ... this will then realize to the correct auth caps statements (ex. <code>[osd] profile rbd pool=equiad1-compute</code>).
* <code>access type</code> this would be an abstraction over actual ceph auth permissions. Something like <code>glance_client</code>, <code>nova_client</code>, <code>radosgw_client</code>, <code>osd_server</code>, <code>mon_server</code>, ... this will then realize to the correct auth caps statements (ex. <code>[osd] profile rbd pool=equiad1-compute</code>).


== Proposal ==
=== abstraction ===


Each openstack role should be able to load ceph client credentials in an elegant way, for example:
Inspired by how acme-chief manages certificates:
 
* the source of truth is a private hiera hash with this layout, what it is called a '''DC-specific configuration hash''':


<pre>
<pre>
* role::wmcs::openstack::eqiad1::control
profile::ceph::auth::load_all::configuration:
** ( ..many other includes.. )
  cinder:
** include profile::ceph::XXXX::rbc_client::cloudcontrol
    keydata: XXXXXX
*** include profile::ceph::XXXX::rbd_client::nova
    keyring_filename: /path/to/file.keyring
*** include profile::ceph::XXXX::rbd_client::glance
    caps:
*** include profile::ceph::XXXX::rbd_client::cinder
        mds: "whatever"
*** include profile::ceph::XXXX::rbd_client::swift (or radosgw)
        mgr: "whatever"
        mon: "whatever"
        osd: "whatever"
  glance:
    keydata: XXXXXX
    keyring_filename: /path/to/file.keyring
    caps:
        mds: "whatever"
        mgr: "whatever"
        mon: "whatever"
        osd: "whatever"
  osd:
    keydata: XXXXXX
    keyring_filename: /path/to/file.keyring
    caps:
        mds: "whatever"
        mgr: "whatever"
        mon: "whatever"
        osd: "whatever"
</pre>
</pre>
* the hiera hash is per-DC (i.e, eqiad, codfw). Future iterations may evolve this to support multiple ceph farms per DC, but we don't want this at this point
* clients may declare which creds they want by using an additional hiera key, for example, on file '''hieradata/roles/codfw/wmcs/openstack/codfw1dev/control.yaml''':


<pre>
<pre>
* role::wmcs::openstack::eqiad1::virt_ceph
profile::ceph::auth::deploy::selected_creds:
** ( ..many other includes.. )
  - cinder
** include profile::ceph::XXXX::rbc_client::virt
  - glance
*** include profile::ceph::XXXX::rbd_client::nova
</pre>
</pre>
Once this hiera structures are in place, we have 2 important profiles/modules to handle that data:
* <code>profile::ceph::auth::load_all</code>: profile loaded on '''mons''', reads the hiera hash (has a parameter 'configuration'), and calls internally the inner module:
** <code>ceph::auth::load_all</code> receives a list of credentials and loads them to the ceph running system.
* <code>profile::ceph::auth::deploy</code>: profile loaded on ceph clients, like ''osd'', ''cloudcontrol'' and friends. Reads configuration hash (has a parameter 'auths'), and calls internally the inner module:
** <code>ceph::auth::deploy</code>: deploys a keyring file on the filesystem.
=== code organization proposal ===
With the abstraction described above, we could use the puppet code like this:


<pre>
<pre>
* role::wmcs::openstack::eqiad1::cinder_backups <--- made up name, for illustration purposes; may happen for real soon
* role::wmcs::ceph::mon
** ( ..many other includes.. )
** profile::ceph::auth::load_all <-- reads DC-specific configuration hiera hash (i.e, eqiad or codfw)
** include profile::ceph::XXXX::rbc_client::backups
 
*** include profile::ceph::XXXX::rbd_client::cinder
* role::wmcs::ceph::osd
** profile::ceph::auth::deploy <-- reads DC-specific configuration hiera hash, and an array of individual keyfile names to deploy as files
 
* role::wmcs::openstack::codfw1dev::control
** profile::ceph::auth::deploy <-- reads DC-specific configuration hiera hash, and an array of individual keyfile names to deploy as files
</pre>
</pre>


Where XXXX is some kind of new identifier for a ceph cluster (see [[phab:T281250]]) '''TO BE DECIDED'''.
A code example of this:
 
<syntaxhighlight lang="puppet">
class profile::ceph::auth::load_all (
  Hash $configuration = lookup('ceph::auth'),
) {
 
  class { 'ceph::auth::load_all':
    configuration => $configuration,
  }
}


This includes the relevant layer of hiera overrides.
class ceph::auth::load_all (
  Hash $configuration,
) {
    # for each entry in the configuration hash
    # load it using 'ceph auth get-or-create'
}
</syntaxhighlight>
 
Also:
 
<syntaxhighlight lang="puppet">
class profile::ceph::auth::deploy (
  Hash $configuration = lookup('ceph::auth'),
  Array[String] $selected_creds = lookup('profile::ceph::auth::deploy::selected_creds'),
) {
  class { 'ceph::auth::deploy':
      configuration = $configuration,
      selected_creds = $selected_creds,
  }
}
 
class ceph::auth::deploy(
  Hash $configuration,
  Array[String] $selected_creds, 
) {
  # filter configuration for the selected creds
  # if we find a match, then create a keyring file resource with the keydata
}
</syntaxhighlight>
 
Example hiera configuration:
 
File on '''private repository''' <code>hieradata/common/codfw.yaml</code> (which should be available to all systems on the DC --- TODO: we may want to have a more suitable place for this)
<pre>
ceph::auth:
  cinder:
    keydata: XXXXXX
    keyring_filename: /path/to/file.keyring
    caps:
        caps_mds: "whatever"
        caps_mgr: "whatever"
        caps_mon: "whatever"
        caps_osd: "whatever"
  glance:
    keydata: XXXXXX
    keyring_filename: /path/to/file.keyring
    caps:
        caps_mds: "whatever"
        caps_mgr: "whatever"
        caps_mon: "whatever"
        caps_osd: "whatever"
  osd:
    keydata: XXXXXX
    keyring_filename: /path/to/file.keyring
    caps:
        caps_mds: "whatever"
        caps_mgr: "whatever"
        caps_mon: "whatever"
        caps_osd: "whatever"
</pre>
 
File '''on the public repo''' <code>hieradata/role/codfw/wmcs/openstack/codfw1dev/control.yaml</code>, which should be available to all openstack codfw1dev cloudcontrol servers:
<pre>
profile::ceph::auth::deploy:
  - cinder
  - glance
</pre>
 
File '''on the public repo''' <code>hieradata/role/codfw/wmcs/openstack/codfw1dev/virt_ceph.yaml</code>, which should be available to all openstack codfw1dev virt servers:
<pre>
profile::ceph::auth::deploy:
  - compute
</pre>


== See also ==
== See also ==

Revision as of 13:45, 20 October 2021

This page contains a puppet refactor proposal for the ceph client code.

Problem statement

The ceph rbd client code in puppet does not have a easy and single way to use it, some points:

  • There's 3 ways of using it so far, sometimes it splits by host that uses it (ceph::client::rbd_cloudcontrol) sometimes by service (ceph::client::rbd_glance/rbd_libvirt) and for cinder it's in the main class instead (p:openstack::codfw1dev::cinder).
  • There is no clear way of setting up ceph rbd config/credentials for a given ceph pool/service, and we have at least 4:
    • nova VM disks (often referred to as 'compute' in the puppet tree)
    • glance images
    • cinder volumes
    • radosgw
  • Setting up config/credentials should be paired with the actual user/keydata being added in the ceph cluster. This is not something we can/want to do with puppet though, and automating this is something we can do in a later iteration.

Proposed solution

In summary: we should refresh the code to support the mappings:

<openstack deployment>+<sevice> <-> <ceph deployment>+<access type>

Where:

  • openstack deployment is one of eqiad1 or codfw1dev for now
  • service is one of glance, cinder, nova, cinder-backups, ...
  • ceph deployment is currently "ceph", though this should be extended in the future to allow multi-dc/multi-cluster deployments (task)
  • access type this would be an abstraction over actual ceph auth permissions. Something like glance_client, nova_client, radosgw_client, osd_server, mon_server, ... this will then realize to the correct auth caps statements (ex. [osd] profile rbd pool=equiad1-compute).

abstraction

Inspired by how acme-chief manages certificates:

  • the source of truth is a private hiera hash with this layout, what it is called a DC-specific configuration hash:
profile::ceph::auth::load_all::configuration:
  cinder:
    keydata: XXXXXX
    keyring_filename: /path/to/file.keyring
    caps:
        mds: "whatever"
        mgr: "whatever"
        mon: "whatever"
        osd: "whatever"
  glance:
    keydata: XXXXXX
    keyring_filename: /path/to/file.keyring
    caps:
        mds: "whatever"
        mgr: "whatever"
        mon: "whatever"
        osd: "whatever"
  osd:
    keydata: XXXXXX
    keyring_filename: /path/to/file.keyring
    caps:
        mds: "whatever"
        mgr: "whatever"
        mon: "whatever"
        osd: "whatever"
  • the hiera hash is per-DC (i.e, eqiad, codfw). Future iterations may evolve this to support multiple ceph farms per DC, but we don't want this at this point
  • clients may declare which creds they want by using an additional hiera key, for example, on file hieradata/roles/codfw/wmcs/openstack/codfw1dev/control.yaml:
profile::ceph::auth::deploy::selected_creds:
  - cinder
  - glance

Once this hiera structures are in place, we have 2 important profiles/modules to handle that data:

  • profile::ceph::auth::load_all: profile loaded on mons, reads the hiera hash (has a parameter 'configuration'), and calls internally the inner module:
    • ceph::auth::load_all receives a list of credentials and loads them to the ceph running system.
  • profile::ceph::auth::deploy: profile loaded on ceph clients, like osd, cloudcontrol and friends. Reads configuration hash (has a parameter 'auths'), and calls internally the inner module:
    • ceph::auth::deploy: deploys a keyring file on the filesystem.

code organization proposal

With the abstraction described above, we could use the puppet code like this:

* role::wmcs::ceph::mon
** profile::ceph::auth::load_all <-- reads DC-specific configuration hiera hash (i.e, eqiad or codfw)

* role::wmcs::ceph::osd
** profile::ceph::auth::deploy <-- reads DC-specific configuration hiera hash, and an array of individual keyfile names to deploy as files

* role::wmcs::openstack::codfw1dev::control
** profile::ceph::auth::deploy <-- reads DC-specific configuration hiera hash, and an array of individual keyfile names to deploy as files

A code example of this:

class profile::ceph::auth::load_all (
  Hash $configuration = lookup('ceph::auth'),
) {

   class { 'ceph::auth::load_all':
     configuration => $configuration,
   }
}

class ceph::auth::load_all (
  Hash $configuration,
) {
    # for each entry in the configuration hash
    # load it using 'ceph auth get-or-create'
}

Also:

class profile::ceph::auth::deploy (
  Hash $configuration = lookup('ceph::auth'),
  Array[String] $selected_creds = lookup('profile::ceph::auth::deploy::selected_creds'),
) {
  class { 'ceph::auth::deploy':
      configuration = $configuration,
      selected_creds = $selected_creds,
  }
}

class ceph::auth::deploy(
  Hash $configuration,
  Array[String] $selected_creds,  
) {
   # filter configuration for the selected creds
   # if we find a match, then create a keyring file resource with the keydata
}

Example hiera configuration:

File on private repository hieradata/common/codfw.yaml (which should be available to all systems on the DC --- TODO: we may want to have a more suitable place for this)

ceph::auth:
  cinder:
    keydata: XXXXXX
    keyring_filename: /path/to/file.keyring
    caps:
        caps_mds: "whatever"
        caps_mgr: "whatever"
        caps_mon: "whatever"
        caps_osd: "whatever"
  glance:
    keydata: XXXXXX
    keyring_filename: /path/to/file.keyring
    caps:
        caps_mds: "whatever"
        caps_mgr: "whatever"
        caps_mon: "whatever"
        caps_osd: "whatever"
  osd:
    keydata: XXXXXX
    keyring_filename: /path/to/file.keyring
    caps:
        caps_mds: "whatever"
        caps_mgr: "whatever"
        caps_mon: "whatever"
        caps_osd: "whatever"

File on the public repo hieradata/role/codfw/wmcs/openstack/codfw1dev/control.yaml, which should be available to all openstack codfw1dev cloudcontrol servers:

profile::ceph::auth::deploy:
  - cinder
  - glance

File on the public repo hieradata/role/codfw/wmcs/openstack/codfw1dev/virt_ceph.yaml, which should be available to all openstack codfw1dev virt servers:

profile::ceph::auth::deploy:
  - compute

See also