diff --git a/Documentation/ceph-cluster-crd.md b/Documentation/ceph-cluster-crd.md index 0215646cd..40154ea6a 100755 --- a/Documentation/ceph-cluster-crd.md +++ b/Documentation/ceph-cluster-crd.md @@ -88,6 +88,15 @@ starts with three nodes, but might grow to more than five nodes, you might want When the operator sees the new nodes come online, the number of mons will increase to the preferred count. If the number of nodes decreases below the `preferredCount`, the operator will reduce the number of mons back to `count`. If `allowMultiplePerNode: true` (for testing scenarios), the number of mons will always use `preferredCount` if set. - `allowMultiplePerNode`: Enable (`true`) or disable (`false`) the placement of multiple mons on one node. Default is `false`. +- `volumeClaimTemplate`: A `PersistentVolumeSpec` used by Rook to create PVCs + for monitor storage. This field is optional, and when not provided, HostPath + volume mounts are used. The current set of fields from template that are used + are `storageClassName` and the `storage` resource request and limit. The + default storage size request for new PVCs is `10Gi`. Ensure that associated + storage class is configured to use `volumeBindingMode: WaitForFirstConsumer`. + This setting only applies to new monitors that are created when the requested + number of monitors increases, or when a monitor fails and is recreated. An + [example CRD configuration is provided below](#using-pvc-storage-for-monitors). If these settings are changed in the CRD the operator will update the number of mons during a periodic check of the mon health, which by default is every 45 seconds. @@ -478,3 +487,41 @@ spec: ``` This configuration will split replication of your volumes across unique racks in your datacenter setup. + +### Using PVC storage for monitors + +In the CRD specification below three monitors are created each using a 10Gi PVC +created by Rook using the `fast-disks` storage class. + +```yaml +apiVersion: ceph.rook.io/v1 +kind: CephCluster +metadata: + name: rook-ceph + namespace: rook-ceph +spec: + cephVersion: + image: ceph/ceph:v14.2.1-20190430 + dataDirHostPath: /var/lib/rook + mon: + count: 3 + allowMultiplePerNode: false + volumeClaimTemplate: + spec: + storageClassName: fast-disks + resources: + requests: + storage: 10Gi + dashboard: + enabled: true + storage: + useAllNodes: true + useAllDevices: true + deviceFilter: + location: + config: + metadataDevice: + databaseSizeMB: "1024" # this value can be removed for environments with normal sized disks (100 GB or larger) + journalSizeMB: "1024" # this value can be removed for environments with normal sized disks (20 GB or larger) + osdsPerDevice: "1" +``` diff --git a/Documentation/ceph-examples.md b/Documentation/ceph-examples.md index 6de8ee275..e9f32dcb9 100644 --- a/Documentation/ceph-examples.md +++ b/Documentation/ceph-examples.md @@ -47,6 +47,9 @@ Now that your operator is running, let's create your Ceph storage cluster: See the [Cluster CRD](ceph-cluster-crd.md) topic for more details on the settings. +Monitors may be configured to run on PVC storage. Details on [how to set this up +and some minor restrctions are described here](ceph-cluster-crd.md#mon-settings). + ## Setting up consumable storage Now we are ready to setup [block](https://ceph.com/ceph-storage/block-storage/), [shared filesystem](https://ceph.com/ceph-storage/file-system/) or [object storage](https://ceph.com/ceph-storage/object-storage/) in the rook ceph cluster. These kinds of storage are respectively referred to as CephBlockPool, CephFilesystem and CephObjectStore in the spec files. diff --git a/PendingReleaseNotes.md b/PendingReleaseNotes.md index 88e9072fc..e34815951 100644 --- a/PendingReleaseNotes.md +++ b/PendingReleaseNotes.md @@ -35,6 +35,8 @@ an example usage - Upgrades have drastically improved, Rook intelligently checks for each daemon state before and after upgrading. To learn more about the upgrade workflow see [Ceph Upgrades](Documentation/ceph-upgrade.md) - Rook Operator now supports 2 new environmental variables: `AGENT_TOLERATIONS` and `DISCOVER_TOLERATIONS`. Each accept list of tolerations for agent and discover pods accordingly. - Ceph daemons now run under 'ceph' user and not 'root' anymore (monitor or osd store already owned by 'root' will keep running under 'root') +- Ceph monitors have initial support for running on PVC storage. See docs on + [monitor settings for more detail](Documentation/ceph-cluster-crd.md#mon-settings). ## Breaking Changes diff --git a/cluster/examples/kubernetes/ceph/cluster-on-pvc.yaml b/cluster/examples/kubernetes/ceph/cluster-on-pvc.yaml new file mode 100644 index 000000000..3b24b1080 --- /dev/null +++ b/cluster/examples/kubernetes/ceph/cluster-on-pvc.yaml @@ -0,0 +1,25 @@ +# +# Hi, it looks like you just had a conflict merging #3341. Please integrate the +# `mon.volumeClaimTemplate` configuration and associated comment below, and +# remove this note. Thanks :) +# +apiVersion: ceph.rook.io/v1 +kind: CephCluster +metadata: + name: rook-ceph + namespace: rook-ceph +spec: + dataDirHostPath: /var/lib/rook + mon: + # A volume claim template can be specified in which case new monitors (and + # monitors created during fail over) will construct a PVC based on the + # template for the monitor's primary storage. Changes to the template do not + # affect existing monitors. Log data is stored on the HostPath under + # dataDirHostPath. If no storage requirement is specified, a default storage + # size appropriate for monitor data will be used. + volumeClaimTemplate: + spec: + storageClassName: local-storage + resources: + requests: + storage: 10Gi diff --git a/pkg/apis/ceph.rook.io/v1/types.go b/pkg/apis/ceph.rook.io/v1/types.go index d670eca98..cd09a125e 100755 --- a/pkg/apis/ceph.rook.io/v1/types.go +++ b/pkg/apis/ceph.rook.io/v1/types.go @@ -143,9 +143,10 @@ const ( ) type MonSpec struct { - Count int `json:"count"` - PreferredCount int `json:"preferredCount"` - AllowMultiplePerNode bool `json:"allowMultiplePerNode"` + Count int `json:"count"` + PreferredCount int `json:"preferredCount"` + AllowMultiplePerNode bool `json:"allowMultiplePerNode"` + VolumeClaimTemplate *v1.PersistentVolumeClaim `json:"volumeClaimTemplate,omitempty"` } type RBDMirroringSpec struct { diff --git a/pkg/operator/ceph/cluster/mon/mon.go b/pkg/operator/ceph/cluster/mon/mon.go index e032ce888..36505849a 100644 --- a/pkg/operator/ceph/cluster/mon/mon.go +++ b/pkg/operator/ceph/cluster/mon/mon.go @@ -38,6 +38,7 @@ import ( opspec "github.com/rook/rook/pkg/operator/ceph/spec" cephver "github.com/rook/rook/pkg/operator/ceph/version" "github.com/rook/rook/pkg/operator/k8sutil" + apps "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -79,6 +80,10 @@ const ( // minimum amount of memory in MB to run the pod cephMonPodMinimumMemory uint64 = 1024 + + // default storage request size for ceph monitor pvc + // https://docs.ceph.com/docs/master/start/hardware-recommendations/#monitors-and-managers-ceph-mon-and-ceph-mgr + cephMonDefaultStorageRequest = "10Gi" ) var ( @@ -617,34 +622,85 @@ func (c *Cluster) saveMonConfig() error { var updateDeploymentAndWait = UpdateCephDeploymentAndWait +func (c *Cluster) updateMon(m *monConfig, d *apps.Deployment) error { + logger.Infof("deployment for mon %s already exists. updating if needed", + d.Name) + + daemonType := string(config.MonType) + var cephVersionToUse cephver.CephVersion + currentCephVersion, err := client.LeastUptodateDaemonVersion(c.context, c.clusterInfo.Name, daemonType) + if err != nil { + logger.Warningf("failed to retrieve current ceph %s version. %+v", daemonType, err) + logger.Debug("could not detect ceph version during update, this is likely an initial bootstrap, proceeding with c.clusterInfo.CephVersion") + cephVersionToUse = c.clusterInfo.CephVersion + } else { + logger.Debugf("current cluster version for monitors before upgrading is: %+v", currentCephVersion) + cephVersionToUse = currentCephVersion + } + + err = updateDeploymentAndWait(c.context, d, c.Namespace, daemonType, m.DaemonName, cephVersionToUse) + if err != nil { + return fmt.Errorf("failed to update mon deployment %s. %+v", m.ResourceName, err) + } + + return nil +} + func (c *Cluster) startMon(m *monConfig, hostname string) error { + // check if the monitor deployment already exists. if the deployment does + // exist, also determine if it using pvc storage. + pvcExists := false + deploymentExists := false d := c.makeDeployment(m, hostname) - logger.Debugf("Starting mon: %+v", d.Name) - _, err := c.context.Clientset.AppsV1().Deployments(c.Namespace).Create(d) - if err != nil { - if !errors.IsAlreadyExists(err) { - return fmt.Errorf("failed to create mon deployment %s. %+v", m.ResourceName, err) - } - logger.Infof("deployment for mon %s already exists. updating if needed", m.ResourceName) + existingDeployment, err := c.context.Clientset.AppsV1().Deployments(c.Namespace).Get(d.Name, metav1.GetOptions{}) + if err == nil { + deploymentExists = true + pvcExists = opspec.DaemonVolumesContainsPVC(existingDeployment.Spec.Template.Spec.Volumes) + } else if !errors.IsNotFound(err) { + return fmt.Errorf("failed to get mon deployment %s. %+v", d.Name, err) + } - // Always invoke ceph version before an upgrade so we are sure to be up-to-date - daemonType := string(config.MonType) - var cephVersionToUse cephver.CephVersion - currentCephVersion, err := client.LeastUptodateDaemonVersion(c.context, c.clusterInfo.Name, daemonType) + // persistent storage is not altered after the deployment is created. this + // means we need to be careful when updating the deployment to avoid new + // changes to the crd to change an existing pod's persistent storage. the + // deployment spec created above does not specify persistent storage. here + // we add in PVC or HostPath storage based on an existing deployment OR on + // the current state of the CRD. + if pvcExists || (!deploymentExists && c.spec.Mon.VolumeClaimTemplate != nil) { + pvcName := m.ResourceName + d.Spec.Template.Spec.Volumes = append(d.Spec.Template.Spec.Volumes, opspec.DaemonVolumesDataPVC(pvcName)) + logger.Debugf("adding pvc volume source %s to mon deployment %s", pvcName, d.Name) + } else { + d.Spec.Template.Spec.Volumes = append(d.Spec.Template.Spec.Volumes, opspec.DaemonVolumesDataHostPath(m.DataPathMap)...) + logger.Debugf("adding host path volume source to mon deployment %s", d.Name) + } + + if deploymentExists { + return c.updateMon(m, d) + } + + if c.spec.Mon.VolumeClaimTemplate != nil { + pvc, err := c.makeDeploymentPVC(m) if err != nil { - logger.Warningf("failed to retrieve current ceph %s version. %+v", daemonType, err) - logger.Debug("could not detect ceph version during update, this is likely an initial bootstrap, proceeding with c.clusterInfo.CephVersion") - cephVersionToUse = c.clusterInfo.CephVersion - } else { - logger.Debugf("current cluster version for monitors before upgrading is: %+v", currentCephVersion) - cephVersionToUse = currentCephVersion + return fmt.Errorf("failed to make mon %s pvc. %+v", d.Name, err) } - if err := updateDeploymentAndWait(c.context, d, c.Namespace, daemonType, m.DaemonName, cephVersionToUse); err != nil { - return fmt.Errorf("failed to update mon deployment %s. %+v", m.ResourceName, err) + _, err = c.context.Clientset.CoreV1().PersistentVolumeClaims(c.Namespace).Create(pvc) + if err != nil { + if errors.IsAlreadyExists(err) { + logger.Debugf("cannot create mon %s pvc %s: already exists.", d.Name, pvc.Name) + } else { + return fmt.Errorf("failed to create mon %s pvc %s. %+v", d.Name, pvc.Name, err) + } } } + logger.Debugf("Starting mon: %+v", d.Name) + _, err = c.context.Clientset.AppsV1().Deployments(c.Namespace).Create(d) + if err != nil { + return fmt.Errorf("failed to create mon deployment %s. %+v", d.Name, err) + } + return nil } diff --git a/pkg/operator/ceph/cluster/mon/spec.go b/pkg/operator/ceph/cluster/mon/spec.go index 12561ca52..8a9c065fc 100644 --- a/pkg/operator/ceph/cluster/mon/spec.go +++ b/pkg/operator/ceph/cluster/mon/spec.go @@ -30,6 +30,7 @@ import ( "github.com/rook/rook/pkg/operator/k8sutil" apps "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -83,6 +84,52 @@ func (c *Cluster) makeDeployment(monConfig *monConfig, hostname string) *apps.De return d } +func (c *Cluster) makeDeploymentPVC(m *monConfig) (*v1.PersistentVolumeClaim, error) { + template := c.spec.Mon.VolumeClaimTemplate + volumeMode := v1.PersistentVolumeFilesystem + pvc := &v1.PersistentVolumeClaim{ + ObjectMeta: metav1.ObjectMeta{ + Name: m.ResourceName, + Namespace: c.Namespace, + Labels: c.getLabels(m.DaemonName), + }, + Spec: v1.PersistentVolumeClaimSpec{ + AccessModes: []v1.PersistentVolumeAccessMode{ + v1.ReadWriteOnce, + }, + Resources: template.Spec.Resources, + StorageClassName: template.Spec.StorageClassName, + VolumeMode: &volumeMode, + }, + } + k8sutil.AddRookVersionLabelToObjectMeta(&pvc.ObjectMeta) + cephv1.GetMonAnnotations(c.spec.Annotations).ApplyToObjectMeta(&pvc.ObjectMeta) + opspec.AddCephVersionLabelToObjectMeta(c.clusterInfo.CephVersion, &pvc.ObjectMeta) + k8sutil.SetOwnerRef(&pvc.ObjectMeta, &c.ownerRef) + + // k8s uses limit as the resource request fallback + if _, ok := pvc.Spec.Resources.Limits[v1.ResourceStorage]; ok { + return pvc, nil + } + + // specific request in the crd + if _, ok := pvc.Spec.Resources.Requests[v1.ResourceStorage]; ok { + return pvc, nil + } + + req, err := resource.ParseQuantity(cephMonDefaultStorageRequest) + if err != nil { + return nil, err + } + + if pvc.Spec.Resources.Requests == nil { + pvc.Spec.Resources.Requests = v1.ResourceList{} + } + pvc.Spec.Resources.Requests[v1.ResourceStorage] = req + + return pvc, nil +} + /* * Pod spec */ @@ -99,7 +146,7 @@ func (c *Cluster) makeMonPod(monConfig *monConfig, hostname string) *v1.Pod { }, RestartPolicy: v1.RestartPolicyAlways, NodeSelector: map[string]string{v1.LabelHostname: hostname}, - Volumes: opspec.DaemonVolumes(monConfig.DataPathMap, keyringStoreName), + Volumes: opspec.DaemonVolumesBase(monConfig.DataPathMap, keyringStoreName), HostNetwork: c.HostNetwork, } if c.HostNetwork { diff --git a/pkg/operator/ceph/cluster/mon/spec_test.go b/pkg/operator/ceph/cluster/mon/spec_test.go index e3c349335..ff39e3b55 100644 --- a/pkg/operator/ceph/cluster/mon/spec_test.go +++ b/pkg/operator/ceph/cluster/mon/spec_test.go @@ -22,6 +22,7 @@ import ( cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1" "github.com/rook/rook/pkg/clusterd" "github.com/rook/rook/pkg/operator/ceph/config" + opspec "github.com/rook/rook/pkg/operator/ceph/spec" cephtest "github.com/rook/rook/pkg/operator/ceph/test" testop "github.com/rook/rook/pkg/operator/test" "github.com/stretchr/testify/assert" @@ -31,11 +32,13 @@ import ( ) func TestPodSpecs(t *testing.T) { - testPodSpec(t, "a") - testPodSpec(t, "mon0") + testPodSpec(t, "a", true) + testPodSpec(t, "mon0", true) + testPodSpec(t, "a", false) + testPodSpec(t, "mon0", false) } -func testPodSpec(t *testing.T, monID string) { +func testPodSpec(t *testing.T, monID string, pvc bool) { clientset := testop.New(1) c := New( &clusterd.Context{Clientset: clientset, ConfigDir: "/var/lib/rook"}, @@ -62,6 +65,14 @@ func testPodSpec(t *testing.T, monID string) { d := c.makeDeployment(monConfig, "node0") assert.NotNil(t, d) + if pvc { + d.Spec.Template.Spec.Volumes = append( + d.Spec.Template.Spec.Volumes, opspec.DaemonVolumesDataPVC("i-am-pvc")) + } else { + d.Spec.Template.Spec.Volumes = append( + d.Spec.Template.Spec.Volumes, opspec.DaemonVolumesDataHostPath(monConfig.DataPathMap)...) + } + // Deployment should have Ceph labels cephtest.AssertLabelsContainCephRequirements(t, d.ObjectMeta.Labels, config.MonType, monID, appName, "ns") @@ -70,3 +81,64 @@ func testPodSpec(t *testing.T, monID string) { podTemplate.RunFullSuite(config.MonType, monID, appName, "ns", "ceph/ceph:myceph", "200", "100", "1337", "500" /* resources */) } + +func TestDeploymentPVCSpec(t *testing.T) { + clientset := testop.New(1) + c := New( + &clusterd.Context{Clientset: clientset, ConfigDir: "/var/lib/rook"}, + "ns", + "/var/lib/rook", + false, + metav1.OwnerReference{}, + ) + setCommonMonProperties(c, 0, cephv1.MonSpec{Count: 3, AllowMultiplePerNode: true}, "rook/rook:myversion") + c.spec.CephVersion = cephv1.CephVersionSpec{Image: "ceph/ceph:myceph"} + c.spec.Resources = map[string]v1.ResourceRequirements{} + c.spec.Resources["mon"] = v1.ResourceRequirements{ + Limits: v1.ResourceList{ + v1.ResourceCPU: *resource.NewQuantity(200.0, resource.BinarySI), + v1.ResourceMemory: *resource.NewQuantity(1337.0, resource.BinarySI), + }, + Requests: v1.ResourceList{ + v1.ResourceCPU: *resource.NewQuantity(100.0, resource.BinarySI), + v1.ResourceMemory: *resource.NewQuantity(500.0, resource.BinarySI), + }, + } + monConfig := testGenMonConfig("a") + + // configured with default storage request + c.spec.Mon.VolumeClaimTemplate = &v1.PersistentVolumeClaim{} + pvc, err := c.makeDeploymentPVC(monConfig) + assert.NoError(t, err) + defaultReq, err := resource.ParseQuantity(cephMonDefaultStorageRequest) + assert.NoError(t, err) + assert.Equal(t, pvc.Spec.Resources.Requests[v1.ResourceStorage], defaultReq) + + // limit is preserved + req, err := resource.ParseQuantity("22Gi") + assert.NoError(t, err) + c.spec.Mon.VolumeClaimTemplate = &v1.PersistentVolumeClaim{ + Spec: v1.PersistentVolumeClaimSpec{ + Resources: v1.ResourceRequirements{ + Limits: v1.ResourceList{v1.ResourceStorage: req}, + }, + }, + } + pvc, err = c.makeDeploymentPVC(monConfig) + assert.NoError(t, err) + assert.Equal(t, pvc.Spec.Resources.Limits[v1.ResourceStorage], req) + + // request is preserved + req, err = resource.ParseQuantity("23Gi") + assert.NoError(t, err) + c.spec.Mon.VolumeClaimTemplate = &v1.PersistentVolumeClaim{ + Spec: v1.PersistentVolumeClaimSpec{ + Resources: v1.ResourceRequirements{ + Requests: v1.ResourceList{v1.ResourceStorage: req}, + }, + }, + } + pvc, err = c.makeDeploymentPVC(monConfig) + assert.NoError(t, err) + assert.Equal(t, pvc.Spec.Resources.Requests[v1.ResourceStorage], req) +} diff --git a/pkg/operator/ceph/spec/label.go b/pkg/operator/ceph/spec/label.go index eab780d68..749da7009 100644 --- a/pkg/operator/ceph/spec/label.go +++ b/pkg/operator/ceph/spec/label.go @@ -22,6 +22,7 @@ import ( "github.com/rook/rook/pkg/operator/ceph/version" apps "k8s.io/api/apps/v1" batch "k8s.io/api/batch/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) const ( @@ -76,3 +77,10 @@ func AddCephVersionLabelToJob(cephVersion version.CephVersion, j *batch.Job) { } addCephVersionLabel(cephVersion, j.Labels) } + +func AddCephVersionLabelToObjectMeta(cephVersion version.CephVersion, meta *metav1.ObjectMeta) { + if meta.Labels == nil { + meta.Labels = map[string]string{} + } + addCephVersionLabel(cephVersion, meta.Labels) +} diff --git a/pkg/operator/ceph/spec/spec.go b/pkg/operator/ceph/spec/spec.go index 702dd928c..d4dd83b4f 100644 --- a/pkg/operator/ceph/spec/spec.go +++ b/pkg/operator/ceph/spec/spec.go @@ -71,9 +71,8 @@ func RookVolumeMounts() []v1.VolumeMount { ) } -// DaemonVolumes returns the pod volumes used by all Ceph daemons. If keyring resource name is -// empty, there will be no keyring volume created from a secret. -func DaemonVolumes(dataPaths *config.DataPathMap, keyringResourceName string) []v1.Volume { +// DaemonVolumesBase returns the common / static set of volumes. +func DaemonVolumesBase(dataPaths *config.DataPathMap, keyringResourceName string) []v1.Volume { vols := []v1.Volume{ config.StoredFileVolume(), } @@ -84,6 +83,25 @@ func DaemonVolumes(dataPaths *config.DataPathMap, keyringResourceName string) [] // logs are not persisted to host vols = append(vols, StoredLogVolume(dataPaths.HostLogDir)) } + return vols +} + +// DaemonVolumesDataPVC returns a PVC volume source for daemon container data. +func DaemonVolumesDataPVC(pvcName string) v1.Volume { + return v1.Volume{ + Name: "ceph-daemon-data", + VolumeSource: v1.VolumeSource{ + PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{ + ClaimName: pvcName, + }, + }, + } +} + +// DaemonVolumesDataHostPath returns HostPath volume source for daemon container +// data. +func DaemonVolumesDataHostPath(dataPaths *config.DataPathMap) []v1.Volume { + vols := []v1.Volume{} if dataPaths.ContainerDataDir == "" { // no data is stored in container, and therefore no data can be persisted to host return vols @@ -97,6 +115,25 @@ func DaemonVolumes(dataPaths *config.DataPathMap, keyringResourceName string) [] return append(vols, v1.Volume{Name: "ceph-daemon-data", VolumeSource: src}) } +// DaemonVolumesContainsPVC returns true if a volume exists with a volume source +// configured with a persistent volume claim. +func DaemonVolumesContainsPVC(volumes []v1.Volume) bool { + for _, volume := range volumes { + if volume.VolumeSource.PersistentVolumeClaim != nil { + return true + } + } + return false +} + +// DaemonVolumes returns the pod volumes used by all Ceph daemons. If keyring resource name is +// empty, there will be no keyring volume created from a secret. +func DaemonVolumes(dataPaths *config.DataPathMap, keyringResourceName string) []v1.Volume { + vols := DaemonVolumesBase(dataPaths, keyringResourceName) + vols = append(vols, DaemonVolumesDataHostPath(dataPaths)...) + return vols +} + // DaemonVolumeMounts returns volume mounts which correspond to the DaemonVolumes. These // volume mounts are shared by most all Ceph daemon containers, both init and standard. If keyring // resource name is empty, there will be no keyring mounted in the container. diff --git a/pkg/operator/ceph/test/podspec.go b/pkg/operator/ceph/test/podspec.go index 32318796c..5ef4f2b34 100644 --- a/pkg/operator/ceph/test/podspec.go +++ b/pkg/operator/ceph/test/podspec.go @@ -82,8 +82,13 @@ func (ps *PodSpecTester) AssertVolumesMeetCephRequirements( switch v.Name { case "ceph-daemon-data": switch daemonType { - case config.MonType, config.OsdType: - // mons and osds MUST be host path + case config.MonType: + // mons may be host path or pvc + assert.True(ps.t, + v.VolumeSource.HostPath != nil || v.VolumeSource.PersistentVolumeClaim != nil, + string(daemonType)+" daemon should be host path or pvc:", v) + case config.OsdType: + // osds MUST be host path assert.NotNil(ps.t, v.VolumeSource.HostPath, string(daemonType)+" daemon should be host path:", v) case config.MgrType, config.MdsType, config.RgwType: diff --git a/pkg/operator/k8sutil/deployment.go b/pkg/operator/k8sutil/deployment.go index bff6e0e58..832edae5a 100644 --- a/pkg/operator/k8sutil/deployment.go +++ b/pkg/operator/k8sutil/deployment.go @@ -181,3 +181,10 @@ func AddRookVersionLabelToDeployment(d *v1.Deployment) { } addRookVersionLabel(d.Labels) } + +func AddRookVersionLabelToObjectMeta(meta *metav1.ObjectMeta) { + if meta.Labels == nil { + meta.Labels = map[string]string{} + } + addRookVersionLabel(meta.Labels) +}