Orchestrator CLI

This module provides a command line interface (CLI) to orchestrator modules (ceph-mgr modules which interface with external orchestration services).

As the orchestrator CLI unifies multiple external orchestrators, a common nomenclature for the orchestrator module is needed.

host

hostname (not DNS name) of the physical host. Not the podname, container name, or hostname inside the container.

service type

The type of the service. e.g., nfs, mds, osd, mon, rgw, mgr, iscsi

service

A logical service, Typically comprised of multiple service instances on multiple hosts for HA

  • fs_name for mds type

  • rgw_zone for rgw type

  • ganesha_cluster_id for nfs type

daemon

A single instance of a service. Usually a daemon, but maybe not (e.g., might be a kernel service like LIO or knfsd or whatever)

This identifier should uniquely identify the instance

The relation between the names is the following:

  • A service has a specific service type

  • A daemon is a physical instance of a service type

Note

Orchestrator modules may only implement a subset of the commands listed below. Also, the implementation of the commands may differ between modules.

Status

  1. ceph orch status

Show current orchestrator mode and high-level status (whether the orchestrator plugin is available and operational)

Host Management

List hosts associated with the cluster:

  1. ceph orch host ls

Add and remove hosts:

  1. ceph orch host add <hostname> [<addr>] [<labels>...]
  2. ceph orch host rm <hostname>

For cephadm, see also Fully qualified domain names vs bare host names.

Host Specification

Many hosts can be added at once using ceph orch apply -i by submitting a multi-document YAML file:

  1. ---
  2. service_type: host
  3. addr: node-00
  4. hostname: node-00
  5. labels:
  6. - example1
  7. - example2
  8. ---
  9. service_type: host
  10. addr: node-01
  11. hostname: node-01
  12. labels:
  13. - grafana
  14. ---
  15. service_type: host
  16. addr: node-02
  17. hostname: node-02

This can be combined with service specifications (below) to create a cluster spec file to deploy a whole cluster in one command. see cephadm bootstrap --apply-spec also to do this during bootstrap. Cluster SSH Keys must be copied to hosts prior to adding them.

OSD Management

List Devices

Print a list of discovered devices, grouped by host and optionally filtered to a particular host:

  1. ceph orch device ls [--host=...] [--refresh]

Example:

  1. HOST PATH TYPE SIZE DEVICE AVAIL REJECT REASONS
  2. master /dev/vda hdd 42.0G False locked
  3. node1 /dev/vda hdd 42.0G False locked
  4. node1 /dev/vdb hdd 8192M 387836 False locked, LVM detected, Insufficient space (<5GB) on vgs
  5. node1 /dev/vdc hdd 8192M 450575 False locked, LVM detected, Insufficient space (<5GB) on vgs
  6. node3 /dev/vda hdd 42.0G False locked
  7. node3 /dev/vdb hdd 8192M 395145 False LVM detected, locked, Insufficient space (<5GB) on vgs
  8. node3 /dev/vdc hdd 8192M 165562 False LVM detected, locked, Insufficient space (<5GB) on vgs
  9. node2 /dev/vda hdd 42.0G False locked
  10. node2 /dev/vdb hdd 8192M 672147 False LVM detected, Insufficient space (<5GB) on vgs, locked
  11. node2 /dev/vdc hdd 8192M 228094 False LVM detected, Insufficient space (<5GB) on vgs, locked

Erase Devices (Zap Devices)

Erase (zap) a device so that it can be reused. zap calls ceph-volume zap on the remote host.

  1. orch device zap <hostname> <path>

Example command:

  1. ceph orch device zap my_hostname /dev/sdx

Note

Cephadm orchestrator will automatically deploy drives that match the DriveGroup in your OSDSpec if the unmanaged flag is unset. For example, if you use the all-available-devices option when creating OSDs, when you zap a device the cephadm orchestrator will automatically create a new OSD in the device . To disable this behavior, see Create OSDs.

Create OSDs

Create OSDs on a set of devices on a single host:

  1. ceph orch daemon add osd <host>:device1,device2

Another way of doing it is using apply interface:

  1. ceph orch apply osd -i <json_file/yaml_file> [--dry-run]

where the json_file/yaml_file is a DriveGroup specification. For a more in-depth guide to DriveGroups please refer to OSD Service Specification

dry-run will cause the orchestrator to present a preview of what will happen without actually creating the OSDs.

Example:

  1. # ceph orch apply osd --all-available-devices --dry-run
  2. NAME HOST DATA DB WAL
  3. all-available-devices node1 /dev/vdb - -
  4. all-available-devices node2 /dev/vdc - -
  5. all-available-devices node3 /dev/vdd - -

When the parameter all-available-devices or a DriveGroup specification is used, a cephadm service is created. This service guarantees that all available devices or devices included in the DriveGroup will be used for OSDs. Note that the effect of --all-available-devices is persistent; that is, drives which are added to the system or become available (say, by zapping) after the command is complete will be automatically found and added to the cluster.

That is, after using:

  1. ceph orch apply osd --all-available-devices
  • If you add new disks to the cluster they will automatically be used to create new OSDs.

  • A new OSD will be created automatically if you remove an OSD and clean the LVM physical volume.

If you want to avoid this behavior (disable automatic creation of OSD on available devices), use the unmanaged parameter:

  1. ceph orch apply osd --all-available-devices --unmanaged=true

Remove an OSD

  1. ceph orch osd rm <osd_id(s)> [--replace] [--force]

Evacuates PGs from an OSD and removes it from the cluster.

Example:

  1. # ceph orch osd rm 0
  2. Scheduled OSD(s) for removal

OSDs that are not safe-to-destroy will be rejected.

You can query the state of the operation with:

  1. # ceph orch osd rm status
  2. OSD_ID HOST STATE PG_COUNT REPLACE FORCE STARTED_AT
  3. 2 cephadm-dev done, waiting for purge 0 True False 2020-07-17 13:01:43.147684
  4. 3 cephadm-dev draining 17 False True 2020-07-17 13:01:45.162158
  5. 4 cephadm-dev started 42 False True 2020-07-17 13:01:45.162158

When no PGs are left on the OSD, it will be decommissioned and removed from the cluster.

Note

After removing an OSD, if you wipe the LVM physical volume in the device used by the removed OSD, a new OSD will be created. Read information about the unmanaged parameter in Create OSDs.

Stopping OSD Removal

You can stop the queued OSD removal operation with

  1. ceph orch osd rm stop <svc_id(s)>

Example:

  1. # ceph orch osd rm stop 4
  2. Stopped OSD(s) removal

This will reset the initial state of the OSD and take it off the removal queue.

Replace an OSD

  1. orch osd rm <svc_id(s)> --replace [--force]

Example:

  1. # ceph orch osd rm 4 --replace
  2. Scheduled OSD(s) for replacement

This follows the same procedure as the “Remove OSD” part with the exception that the OSD is not permanently removed from the CRUSH hierarchy, but is assigned a ‘destroyed’ flag.

Preserving the OSD ID

The previously-set ‘destroyed’ flag is used to determine OSD ids that will be reused in the next OSD deployment.

If you use OSDSpecs for OSD deployment, your newly added disks will be assigned the OSD ids of their replaced counterparts, assuming the new disks still match the OSDSpecs.

For assistance in this process you can use the ‘–dry-run’ feature.

Tip: The name of your OSDSpec can be retrieved from ceph orch ls

Alternatively, you can use your OSDSpec file:

  1. ceph orch apply osd -i <osd_spec_file> --dry-run
  2. NAME HOST DATA DB WAL
  3. <name_of_osd_spec> node1 /dev/vdb - -

If this matches your anticipated behavior, just omit the –dry-run flag to execute the deployment.

Monitor and manager management

Creates or removes MONs or MGRs from the cluster. Orchestrator may return an error if it doesn’t know how to do this transition.

Update the number of monitor hosts:

  1. ceph orch apply mon --placement=<placement> [--dry-run]

Where placement is a Placement Specification.

Each host can optionally specify a network for the monitor to listen on.

Update the number of manager hosts:

  1. ceph orch apply mgr --placement=<placement> [--dry-run]

Where placement is a Placement Specification.

Service Status

Print a list of services known to the orchestrator. The list can be limited to services on a particular host with the optional –host parameter and/or services of a particular type via optional –type parameter (mon, osd, mgr, mds, rgw):

  1. ceph orch ls [--service_type type] [--service_name name] [--export] [--format f] [--refresh]

Discover the status of a particular service or daemons:

  1. ceph orch ls --service_type type --service_name <name> [--refresh]

Export the service specs known to the orchestrator as yaml in format that is compatible to ceph orch apply -i:

  1. ceph orch ls --export

Daemon Status

Print a list of all daemons known to the orchestrator:

  1. ceph orch ps [--hostname host] [--daemon_type type] [--service_name name] [--daemon_id id] [--format f] [--refresh]

Query the status of a particular service instance (mon, osd, mds, rgw). For OSDs the id is the numeric OSD ID, for MDS services it is the file system name:

  1. ceph orch ps --daemon_type osd --daemon_id 0

Deploying CephFS

In order to set up a CephFS, execute:

  1. ceph fs volume create <fs_name> <placement spec>

where name is the name of the CephFS and placement is a Placement Specification.

This command will create the required Ceph pools, create the new CephFS, and deploy mds servers.

Stateless services (MDS/RGW/NFS/rbd-mirror/iSCSI)

(Please note: The orchestrator will not configure the services. Please look into the corresponding documentation for service configuration details.)

The name parameter is an identifier of the group of instances:

  • a CephFS file system for a group of MDS daemons,

  • a zone name for a group of RGWs

Creating/growing/shrinking/removing services:

  1. ceph orch apply mds <fs_name> [--placement=<placement>] [--dry-run]
  2. ceph orch apply rgw <realm> <zone> [--subcluster=<subcluster>] [--port=<port>] [--ssl] [--placement=<placement>] [--dry-run]
  3. ceph orch apply nfs <name> <pool> [--namespace=<namespace>] [--placement=<placement>] [--dry-run]
  4. ceph orch rm <service_name> [--force]

where placement is a Placement Specification.

e.g., ceph orch apply mds myfs --placement="3 host1 host2 host3"

Service Commands:

  1. ceph orch <start|stop|restart|redeploy|reconfig> <service_name>

Deploying custom containers

The orchestrator enables custom containers to be deployed using a YAML file. A corresponding Service Specification must look like:

  1. service_type: container
  2. service_id: foo
  3. placement:
  4. ...
  5. image: docker.io/library/foo:latest
  6. entrypoint: /usr/bin/foo
  7. uid: 1000
  8. gid: 1000
  9. args:
  10. - "--net=host"
  11. - "--cpus=2"
  12. ports:
  13. - 8080
  14. - 8443
  15. envs:
  16. - SECRET=mypassword
  17. - PORT=8080
  18. - PUID=1000
  19. - PGID=1000
  20. volume_mounts:
  21. CONFIG_DIR: /etc/foo
  22. bind_mounts:
  23. - ['type=bind', 'source=lib/modules', 'destination=/lib/modules', 'ro=true']
  24. dirs:
  25. - CONFIG_DIR
  26. files:
  27. CONFIG_DIR/foo.conf:
  28. - refresh=true
  29. - username=xyz
  30. - "port: 1234"

where the properties of a service specification are:

  • service_id

    A unique name of the service.

  • image

    The name of the Docker image.

  • uid

    The UID to use when creating directories and files in the host system.

  • gid

    The GID to use when creating directories and files in the host system.

  • entrypoint

    Overwrite the default ENTRYPOINT of the image.

  • args

    A list of additional Podman/Docker command line arguments.

  • ports

    A list of TCP ports to open in the host firewall.

  • envs

    A list of environment variables.

  • bind_mounts

    When you use a bind mount, a file or directory on the host machine is mounted into the container. Relative source=… paths will be located below /var/lib/ceph/<cluster-fsid>/<daemon-name>.

  • volume_mounts

    When you use a volume mount, a new directory is created within Docker’s storage directory on the host machine, and Docker manages that directory’s contents. Relative source paths will be located below /var/lib/ceph/<cluster-fsid>/<daemon-name>.

  • dirs

    A list of directories that are created below /var/lib/ceph/<cluster-fsid>/<daemon-name>.

  • files

    A dictionary, where the key is the relative path of the file and the value the file content. The content must be double quoted when using a string. Use ‘\n’ for line breaks in that case. Otherwise define multi-line content as list of strings. The given files will be created below the directory /var/lib/ceph/<cluster-fsid>/<daemon-name>. The absolute path of the directory where the file will be created must exist. Use the dirs property to create them if necessary.

Service Specification

A Service Specification is a data structure represented as YAML to specify the deployment of services. For example:

  1. service_type: rgw
  2. service_id: realm.zone
  3. placement:
  4. hosts:
  5. - host1
  6. - host2
  7. - host3
  8. unmanaged: false
  9. ...

where the properties of a service specification are:

  • service_type

    The type of the service. Needs to be either a Ceph service (mon, crash, mds, mgr, osd or rbd-mirror), a gateway (nfs or rgw), part of the monitoring stack (alertmanager, grafana, node-exporter or prometheus) or (container) for custom containers.

  • service_id

    The name of the service.

  • placement

    See Placement Specification.

  • unmanaged

    If set to true, the orchestrator will not deploy nor remove any daemon associated with this service. Placement and all other properties will be ignored. This is useful, if this service should not be managed temporarily.

Each service type can have additional service specific properties.

Service specifications of type mon, mgr, and the monitoring types do not require a service_id.

A service of type nfs requires a pool name and may contain an optional namespace:

  1. service_type: nfs
  2. service_id: mynfs
  3. placement:
  4. hosts:
  5. - host1
  6. - host2
  7. spec:
  8. pool: mypool
  9. namespace: mynamespace

where pool is a RADOS pool where NFS client recovery data is stored and namespace is a RADOS namespace where NFS client recovery data is stored in the pool.

A service of type osd is described in OSD Service Specification

Many service specifications can be applied at once using ceph orch apply -i by submitting a multi-document YAML file:

  1. cat <<EOF | ceph orch apply -i -
  2. service_type: mon
  3. placement:
  4. host_pattern: "mon*"
  5. ---
  6. service_type: mgr
  7. placement:
  8. host_pattern: "mgr*"
  9. ---
  10. service_type: osd
  11. service_id: default_drive_group
  12. placement:
  13. host_pattern: "osd*"
  14. data_devices:
  15. all: true
  16. EOF

Placement Specification

For the orchestrator to deploy a service, it needs to know where to deploy daemons, and how many to deploy. This is the role of a placement specification. Placement specifications can either be passed as command line arguments or in a YAML files.

Explicit placements

Daemons can be explicitly placed on hosts by simply specifying them:

  1. orch apply prometheus --placement="host1 host2 host3"

Or in YAML:

  1. service_type: prometheus
  2. placement:
  3. hosts:
  4. - host1
  5. - host2
  6. - host3

MONs and other services may require some enhanced network specifications:

  1. orch daemon add mon --placement="myhost:[v2:1.2.3.4:3300,v1:1.2.3.4:6789]=name"

where [v2:1.2.3.4:3300,v1:1.2.3.4:6789] is the network address of the monitor and =name specifies the name of the new monitor.

Placement by labels

Daemons can be explicitly placed on hosts that match a specific label:

  1. orch apply prometheus --placement="label:mylabel"

Or in YAML:

  1. service_type: prometheus
  2. placement:
  3. label: "mylabel"

Placement by pattern matching

Daemons can be placed on hosts as well:

  1. orch apply prometheus --placement='myhost[1-3]'

Or in YAML:

  1. service_type: prometheus
  2. placement:
  3. host_pattern: "myhost[1-3]"

To place a service on all hosts, use "*":

  1. orch apply crash --placement='*'

Or in YAML:

  1. service_type: node-exporter
  2. placement:
  3. host_pattern: "*"

Setting a limit

By specifying count, only that number of daemons will be created:

  1. orch apply prometheus --placement=3

To deploy daemons on a subset of hosts, also specify the count:

  1. orch apply prometheus --placement="2 host1 host2 host3"

If the count is bigger than the amount of hosts, cephadm deploys one per host:

  1. orch apply prometheus --placement="3 host1 host2"

results in two Prometheus daemons.

Or in YAML:

  1. service_type: prometheus
  2. placement:
  3. count: 3

Or with hosts:

  1. service_type: prometheus
  2. placement:
  3. count: 2
  4. hosts:
  5. - host1
  6. - host2
  7. - host3

Updating Service Specifications

The Ceph Orchestrator maintains a declarative state of each service in a ServiceSpec. For certain operations, like updating the RGW HTTP port, we need to update the existing specification.

  1. List the current ServiceSpec:

    1. ceph orch ls --service_name=<service-name> --export > myservice.yaml
  2. Update the yaml file:

    1. vi myservice.yaml
  3. Apply the new ServiceSpec:

    1. ceph orch apply -i myservice.yaml [--dry-run]

Configuring the Orchestrator CLI

To enable the orchestrator, select the orchestrator module to use with the set backend command:

  1. ceph orch set backend <module>

For example, to enable the Rook orchestrator module and use it with the CLI:

  1. ceph mgr module enable rook
  2. ceph orch set backend rook

Check the backend is properly configured:

  1. ceph orch status

Disable the Orchestrator

To disable the orchestrator, use the empty string "":

  1. ceph orch set backend ""
  2. ceph mgr module disable rook

Current Implementation Status

This is an overview of the current implementation status of the orchestrators.

Command

Rook

Cephadm

apply iscsi

apply mds

apply mgr

apply mon

apply nfs

apply osd

apply rbd-mirror

apply rgw

apply container

host add

host ls

host rm

daemon status

daemon {stop,start,…}

device {ident,fault}-(on,off}

device ls

iscsi add

mds add

nfs add

rbd-mirror add

rgw add

ps

where

  • ⚪ = not yet implemented

  • ❌ = not applicable

  • ✔ = implemented