diff --git a/PendingReleaseNotes.md b/PendingReleaseNotes.md index dbe986a67..6d1905150 100644 --- a/PendingReleaseNotes.md +++ b/PendingReleaseNotes.md @@ -31,6 +31,7 @@ - The endpoint is now displayed in the Status field - Prometheus monitoring for external clusters is now possible, refer to the [external cluster section](Documentation/ceph-cluster-crd.html#external-cluster) - The operator will check for the presence of the `lvm2` package on the host where OSDs will run. If not available, the prepare job will fail. This will prevent issues of OSDs not restarting on node reboot. +- Added a new label "ceph_daemon_type" label to Ceph daemon pods to go alongside the existing "ceph_daemon_id" label. ### EdgeFS diff --git a/pkg/operator/ceph/cluster/mgr/spec.go b/pkg/operator/ceph/cluster/mgr/spec.go index d84d0cd37..cf360d7b1 100644 --- a/pkg/operator/ceph/cluster/mgr/spec.go +++ b/pkg/operator/ceph/cluster/mgr/spec.go @@ -323,7 +323,7 @@ func (c *Cluster) makeDashboardService(name string) *v1.Service { } func (c *Cluster) getPodLabels(daemonName string) map[string]string { - labels := controller.PodLabels(AppName, c.clusterInfo.Namespace, "mgr", daemonName) + labels := controller.CephDaemonAppLabels(AppName, c.clusterInfo.Namespace, "mgr", daemonName) // leave "instance" key for legacy usage labels["instance"] = daemonName return labels diff --git a/pkg/operator/ceph/cluster/mon/spec.go b/pkg/operator/ceph/cluster/mon/spec.go index 50dd99812..3fc514adb 100644 --- a/pkg/operator/ceph/cluster/mon/spec.go +++ b/pkg/operator/ceph/cluster/mon/spec.go @@ -46,7 +46,7 @@ const ( func (c *Cluster) getLabels(daemonName string, canary bool, pvcName string) map[string]string { // Mons have a service for each mon, so the additional pod data is relevant for its services // Use pod labels to keep "mon: id" for legacy - labels := controller.PodLabels(AppName, c.Namespace, "mon", daemonName) + labels := controller.CephDaemonAppLabels(AppName, c.Namespace, "mon", daemonName) // Add "mon_cluster: " for legacy labels[monClusterAttr] = c.Namespace if canary { diff --git a/pkg/operator/ceph/cluster/osd/labels.go b/pkg/operator/ceph/cluster/osd/labels.go index e32e4f8f8..c0764d16b 100644 --- a/pkg/operator/ceph/cluster/osd/labels.go +++ b/pkg/operator/ceph/cluster/osd/labels.go @@ -20,7 +20,7 @@ import ( "fmt" "strconv" - "github.com/rook/rook/pkg/operator/k8sutil" + "github.com/rook/rook/pkg/operator/ceph/controller" ) const ( @@ -43,11 +43,11 @@ func makeStorageClassDeviceSetPVCLabel(storageClassDeviceSetName, pvcStorageClas } func (c *Cluster) getOSDLabels(osdID int, failureDomainValue string, portable bool) map[string]string { - return map[string]string{ - k8sutil.AppAttr: AppName, - k8sutil.ClusterAttr: c.clusterInfo.Namespace, - OsdIdLabelKey: fmt.Sprintf("%d", osdID), - FailureDomainKey: failureDomainValue, - portableKey: strconv.FormatBool(portable), - } + stringID := fmt.Sprintf("%d", osdID) + labels := controller.CephDaemonAppLabels(AppName, c.clusterInfo.Namespace, "osd", stringID) + // Add "ceph-osd-id: " for legacy + labels[OsdIdLabelKey] = stringID + labels[FailureDomainKey] = failureDomainValue + labels[portableKey] = strconv.FormatBool(portable) + return labels } diff --git a/pkg/operator/ceph/cluster/rbd/spec.go b/pkg/operator/ceph/cluster/rbd/spec.go index e7e670401..f94f4219e 100644 --- a/pkg/operator/ceph/cluster/rbd/spec.go +++ b/pkg/operator/ceph/cluster/rbd/spec.go @@ -31,7 +31,7 @@ func (r *ReconcileCephRBDMirror) makeDeployment(daemonConfig *daemonConfig, rbdM podSpec := v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Name: daemonConfig.ResourceName, - Labels: controller.PodLabels(AppName, rbdMirror.Namespace, config.RbdMirrorType, daemonConfig.DaemonID), + Labels: controller.CephDaemonAppLabels(AppName, rbdMirror.Namespace, config.RbdMirrorType, daemonConfig.DaemonID), }, Spec: v1.PodSpec{ InitContainers: []v1.Container{ @@ -64,7 +64,7 @@ func (r *ReconcileCephRBDMirror) makeDeployment(daemonConfig *daemonConfig, rbdM Name: daemonConfig.ResourceName, Namespace: rbdMirror.Namespace, Annotations: rbdMirror.Spec.Annotations, - Labels: controller.PodLabels(AppName, rbdMirror.Namespace, config.RbdMirrorType, daemonConfig.DaemonID), + Labels: controller.CephDaemonAppLabels(AppName, rbdMirror.Namespace, config.RbdMirrorType, daemonConfig.DaemonID), }, Spec: apps.DeploymentSpec{ Selector: &metav1.LabelSelector{ diff --git a/pkg/operator/ceph/controller/spec.go b/pkg/operator/ceph/controller/spec.go index 40b075700..c4791deed 100644 --- a/pkg/operator/ceph/controller/spec.go +++ b/pkg/operator/ceph/controller/spec.go @@ -306,12 +306,13 @@ func AppLabels(appName, namespace string) map[string]string { } } -// PodLabels returns pod labels common to all Rook-Ceph pods which may be useful for admins. +// CephDaemonAppLabels returns pod labels common to all Rook-Ceph pods which may be useful for admins. // App name is the name of the application: e.g., 'rook-ceph-mon', 'rook-ceph-mgr', etc. // Daemon type is the Ceph daemon type: "mon", "mgr", "osd", "mds", "rgw" // Daemon ID is the ID portion of the Ceph daemon name: "a" for "mon.a"; "c" for "mds.c" -func PodLabels(appName, namespace, daemonType, daemonID string) map[string]string { +func CephDaemonAppLabels(appName, namespace, daemonType, daemonID string) map[string]string { labels := AppLabels(appName, namespace) + labels["ceph_daemon_type"] = daemonType labels["ceph_daemon_id"] = daemonID // Also report the daemon id keyed by its daemon type: "mon: a", "mds: c", etc. labels[daemonType] = daemonID diff --git a/pkg/operator/ceph/file/mds/spec.go b/pkg/operator/ceph/file/mds/spec.go index 9a706b0ac..311a6420e 100644 --- a/pkg/operator/ceph/file/mds/spec.go +++ b/pkg/operator/ceph/file/mds/spec.go @@ -133,7 +133,7 @@ func (c *Cluster) makeMdsDaemonContainer(mdsConfig *mdsConfig) v1.Container { } func (c *Cluster) podLabels(mdsConfig *mdsConfig) map[string]string { - labels := controller.PodLabels(AppName, c.fs.Namespace, "mds", mdsConfig.DaemonID) + labels := controller.CephDaemonAppLabels(AppName, c.fs.Namespace, "mds", mdsConfig.DaemonID) labels["rook_file_system"] = c.fs.Name return labels } diff --git a/pkg/operator/ceph/nfs/spec.go b/pkg/operator/ceph/nfs/spec.go index 9a41be543..feef4b5be 100644 --- a/pkg/operator/ceph/nfs/spec.go +++ b/pkg/operator/ceph/nfs/spec.go @@ -240,7 +240,7 @@ func (r *ReconcileCephNFS) dbusContainer(nfs *cephv1.CephNFS) v1.Container { } func getLabels(n *cephv1.CephNFS, name string) map[string]string { - labels := controller.AppLabels(AppName, n.Namespace) + labels := controller.CephDaemonAppLabels(AppName, n.Namespace, "nfs", name) labels["ceph_nfs"] = n.Name labels["instance"] = name return labels diff --git a/pkg/operator/ceph/object/spec.go b/pkg/operator/ceph/object/spec.go index 7492cc42b..fd6cde97d 100644 --- a/pkg/operator/ceph/object/spec.go +++ b/pkg/operator/ceph/object/spec.go @@ -349,7 +349,7 @@ func addPortToEndpoint(endpoints *v1.Endpoints, name string, port int32) { } func getLabels(name, namespace string) map[string]string { - labels := controller.PodLabels(AppName, namespace, "rgw", name) + labels := controller.CephDaemonAppLabels(AppName, namespace, "rgw", name) labels["rook_object_store"] = name return labels }