Files
my-rook-config/pkg/operator/ceph/config/datapath.go
T
Blaine Gardner ec416cdd92 ceph mons: set up entirely in operator
Make the Rook config-init unnecessary for mons, and remove that init
container. Perform all mon configuration steps in the operator, and set
up the mon pods and k8s environment such that only Ceph containers are
needed for running mons.

This should help streamline changes to the mons, as there will be no
need to change the `daemon/mon` code or `cmd/rook/ceph` code with mon
changes in the future.

This work starts to lay the groundwork for supporting the
`design/ceph-config-updates.md` design.

Notable new bits:

Create a keyring secret store helper for storing dameon keyrings, and
use it to store the mon keyring. Mon pods mount the keyring into a
k8s secret-backed volume.

Create a configmap store for the Ceph config file which can be mounted
into pods/containers directly to /etc/ceph/ceph.conf. Also store
individual mon_host and mon_initial_members values which can be mapped
into pods as environment variables and used in Ceph commandline flags,
enabling the mon pods to have the most up-to-date information about the
mon cluster when restarting and without need for operator intervention.

Signed-off-by: Blaine Gardner <blaine.gardner@suse.com>
2019-02-05 06:19:59 -07:00

72 lines
2.8 KiB
Go

/*
Copyright 2019 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package config provides a shared way of referring to data storage locations for Ceph Daemons,
// including both the in-container location and on-host location as well as whether the data is
// persisted to the host.
package config
import "path"
// A DataPathMap is a struct which contains information about where Ceph daemon data is stored in
// containers and whether the data should be persisted to the host. If it is persisted to the host,
// directory on the host where the specific daemon's data is stored is given.
type DataPathMap struct {
// PersistData is true if the daemon's data should be persisted to the host.
PersistData bool
// If PersistData is true, HostDataDIr should be set to the path on the host where the specific
// daemon's data is stored.
HostDataDir string
// ContainerDataDir should be set to the path in the container where the specific daemon's data
// is stored.
ContainerDataDir string
}
// NewStatefulDaemonDataPathMap returns a new DataPathMap for a daemon which requires a persistent
// config (mons, osds). daemonDataDirHostRelativePath is the path relative to the dataDirHostPath
// where the daemon's data is stored on the host's filesystem. Daemons which use a DataPathMap
// created by this method will only have access to their own data and not the entire dataDirHostPath
// which may include data from other daemons.
func NewStatefulDaemonDataPathMap(
dataDirHostPath, daemonDataDirHostRelativePath string,
daemonType DaemonType, daemonID string,
) *DataPathMap {
return &DataPathMap{
PersistData: true,
HostDataDir: path.Join(dataDirHostPath, daemonDataDirHostRelativePath),
ContainerDataDir: cephDataDir(daemonType, daemonID),
}
}
// NewStatelessDaemonDataPathMap returns a new DataPathMap for a daemon which does not persist data
// to the host (mgrs, mdses, rgws)
func NewStatelessDaemonDataPathMap(
daemonType DaemonType, daemonID string,
) *DataPathMap {
return &DataPathMap{
PersistData: false,
HostDataDir: "",
ContainerDataDir: cephDataDir(daemonType, daemonID),
}
}
func cephDataDir(daemonType DaemonType, daemonID string) string {
// daemons' default data dirs are: /var/lib/ceph/<daemon-type>/ceph-<daemon-id>
return path.Join(VarLibCephDir, string(daemonType), "ceph-"+daemonID)
}