Merge pull request #3322 from umangachapagain/rook-ceph-monitoring
Integrate ceph-mixins with rook-ceph
This commit is contained in:
16 files changed
+283
-4
No files matched your search
@@ -81,11 +81,20 @@ You can find Prometheus Consoles here: https://github.com/ceph/cephmetrics/tree/
|
||||
A guide to how you can write your own Prometheus consoles can be found on the official Prometheus site here: https://prometheus.io/docs/visualization/consoles/.
|
||||
|
||||
## Prometheus Alerts
|
||||
To enable Prometheus based alerting for Ceph, run the following commands:
|
||||
To enable prometheus alerts during cluster deployment, make following changes to `cluster.yaml`
|
||||
```YAML
|
||||
monitoring:
|
||||
enabled: true
|
||||
rulesNamespace: "rook-ceph"
|
||||
```
|
||||
_Note: This expects prometheus to be pre-installed by the admin._
|
||||
|
||||
To enable prometheus alerts after cluster is deployed, run the following commands:
|
||||
```BASH
|
||||
cd cluster/examples/kubernetes/ceph/monitoring
|
||||
kubectl create -f prometheus-ceph-rules.yaml
|
||||
kubectl create -f prometheus-ceph-v<VERSION>-rules.yaml
|
||||
```
|
||||
_where, VERSION is the version of ceph cluster to be monitored_
|
||||
|
||||
## Grafana Dashboards
|
||||
The dashboards have been created by [@galexrt](https://github.com/galexrt). For feedback on the dashboards please reach out to him on the [Rook.io Slack](https://slack.rook.io).
|
||||
|
||||
Generated
+17
@@ -112,6 +112,20 @@
|
||||
revision = "97fdf19511ea361ae1c100dd393cc47f8dcfa1e1"
|
||||
version = "v4"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:32945438a670edb831120e35007cbb4ba17218e0c5fd52566ba7c56043ae0d96"
|
||||
name = "github.com/coreos/prometheus-operator"
|
||||
packages = [
|
||||
"pkg/apis/monitoring",
|
||||
"pkg/apis/monitoring/v1",
|
||||
"pkg/client/versioned",
|
||||
"pkg/client/versioned/scheme",
|
||||
"pkg/client/versioned/typed/monitoring/v1",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "18fbf558ab7f8809fd610a3dc50bf483508dc1bb"
|
||||
version = "v0.30.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:86909a5b1e4522ad763f86327cfa65e51d7eb838d4adb3d6f68069fede181122"
|
||||
name = "github.com/corpix/uarand"
|
||||
@@ -1367,6 +1381,8 @@
|
||||
"github.com/aws/aws-sdk-go/aws/session",
|
||||
"github.com/aws/aws-sdk-go/service/s3",
|
||||
"github.com/coreos/pkg/capnslog",
|
||||
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1",
|
||||
"github.com/coreos/prometheus-operator/pkg/client/versioned",
|
||||
"github.com/davecgh/go-spew/spew",
|
||||
"github.com/ghodss/yaml",
|
||||
"github.com/go-ini/ini",
|
||||
@@ -1408,6 +1424,7 @@
|
||||
"k8s.io/apimachinery/pkg/util/validation",
|
||||
"k8s.io/apimachinery/pkg/util/version",
|
||||
"k8s.io/apimachinery/pkg/util/wait",
|
||||
"k8s.io/apimachinery/pkg/util/yaml",
|
||||
"k8s.io/apimachinery/pkg/watch",
|
||||
"k8s.io/apiserver/pkg/server",
|
||||
"k8s.io/client-go/discovery",
|
||||
|
||||
@@ -24,5 +24,8 @@ spec:
|
||||
allowMultiplePerNode: false
|
||||
dashboard:
|
||||
enabled: true
|
||||
monitoring:
|
||||
enabled: false # requires Prometheus to be pre-installed
|
||||
rulesNamespace: rook-ceph
|
||||
network:
|
||||
hostNetwork: false
|
||||
@@ -22,6 +22,9 @@ spec:
|
||||
allowMultiplePerNode: true
|
||||
dashboard:
|
||||
enabled: true
|
||||
monitoring:
|
||||
enabled: false # requires Prometheus to be pre-installed
|
||||
rulesNamespace: rook-ceph
|
||||
network:
|
||||
hostNetwork: false
|
||||
rbdMirroring:
|
||||
|
||||
@@ -41,6 +41,16 @@ spec:
|
||||
# port: 8443
|
||||
# serve the dashboard using SSL
|
||||
# ssl: true
|
||||
# enable prometheus alerting for cluster
|
||||
monitoring:
|
||||
# requires Prometheus to be pre-installed
|
||||
enabled: false
|
||||
# namespace to deploy prometheusRule in. If empty, namespace of the cluster will be used.
|
||||
# Recommended:
|
||||
# If you have a single rook-ceph cluster, set the rulesNamespace to the same namespace as the cluster or keep it empty.
|
||||
# If you have multiple rook-ceph clusters in the same k8s cluster, choose the same namespace (ideally, namespace with prometheus
|
||||
# deployed) to set rulesNamespace for all the clusters. Otherwise, you will get duplicate alerts with multiple alert definitions.
|
||||
rulesNamespace: rook-ceph
|
||||
network:
|
||||
# toggle to use hostNetwork
|
||||
hostNetwork: false
|
||||
|
||||
File renamed without changes.
@@ -24,6 +24,6 @@ RUN curl --fail -sSL -o /tini https://github.com/krallin/tini/releases/download/
|
||||
|
||||
COPY rook rookflex toolbox.sh /usr/local/bin/
|
||||
COPY ceph-csi /etc/ceph-csi
|
||||
|
||||
COPY ceph-monitoring /etc/ceph-monitoring
|
||||
ENTRYPOINT ["/tini", "--", "/usr/local/bin/rook"]
|
||||
CMD [""]
|
||||
@@ -39,6 +39,7 @@ do.build:
|
||||
@cp $(OUTPUT_DIR)/bin/linux_$(GOARCH)/rook $(TEMP)
|
||||
@cp $(OUTPUT_DIR)/bin/linux_$(GOARCH)/rookflex $(TEMP)
|
||||
@cp -r ../../cluster/examples/kubernetes/ceph/csi/template $(TEMP)/ceph-csi
|
||||
@cp -r ../../cluster/examples/kubernetes/ceph/monitoring $(TEMP)/ceph-monitoring
|
||||
@cd $(TEMP) && $(SED_CMD) 's|BASEIMAGE|$(BASEIMAGE)|g' Dockerfile
|
||||
@$(DOCKERCMD) build $(BUILD_ARGS) \
|
||||
--build-arg ARCH=$(GOARCH) \
|
||||
|
||||
@@ -77,6 +77,9 @@ type ClusterSpec struct {
|
||||
|
||||
// Dashboard settings
|
||||
Dashboard DashboardSpec `json:"dashboard,omitempty"`
|
||||
|
||||
// Prometheus based Monitoring settings
|
||||
Monitoring MonitoringSpec `json:"monitoring,omitempty"`
|
||||
}
|
||||
|
||||
// VersionSpec represents the settings for the Ceph version that Rook is orchestrating.
|
||||
@@ -100,6 +103,17 @@ type DashboardSpec struct {
|
||||
SSL *bool `json:"ssl,omitempty"`
|
||||
}
|
||||
|
||||
// MonitoringSpec represents the settings for Prometheus based Ceph monitoring
|
||||
type MonitoringSpec struct {
|
||||
// Whether to create the prometheus rules for the ceph cluster. If true, the prometheus
|
||||
// types must exist or the creation will fail.
|
||||
Enabled bool `json:"enabled,omitempty"`
|
||||
|
||||
// The namespace where the prometheus rules and alerts should be created.
|
||||
// If empty, the same namespace as the cluster will be used.
|
||||
RulesNamespace string `json:"rulesNamespace,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterStatus struct {
|
||||
State ClusterState `json:"state,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
|
||||
@@ -481,6 +481,7 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) {
|
||||
out.Mon = in.Mon
|
||||
out.RBDMirroring = in.RBDMirroring
|
||||
in.Dashboard.DeepCopyInto(&out.Dashboard)
|
||||
out.Monitoring = in.Monitoring
|
||||
return
|
||||
}
|
||||
|
||||
@@ -682,6 +683,22 @@ func (in *MonSpec) DeepCopy() *MonSpec {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *MonitoringSpec) DeepCopyInto(out *MonitoringSpec) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MonitoringSpec.
|
||||
func (in *MonitoringSpec) DeepCopy() *MonitoringSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(MonitoringSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NFSGaneshaSpec) DeepCopyInto(out *NFSGaneshaSpec) {
|
||||
*out = *in
|
||||
|
||||
@@ -204,7 +204,7 @@ func (c *cluster) doOrchestration(rookImage string, cephVersion cephver.CephVers
|
||||
|
||||
mgrs := mgr.New(c.Info, c.context, c.Namespace, rookImage,
|
||||
spec.CephVersion, cephv1.GetMgrPlacement(spec.Placement), cephv1.GetMgrAnnotations(c.Spec.Annotations),
|
||||
spec.Network.HostNetwork, spec.Dashboard, cephv1.GetMgrResources(spec.Resources), c.ownerRef, c.Spec.DataDirHostPath)
|
||||
spec.Network.HostNetwork, spec.Dashboard, spec.Monitoring, cephv1.GetMgrResources(spec.Resources), c.ownerRef, c.Spec.DataDirHostPath)
|
||||
err = mgrs.Start()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to start the ceph mgr. %+v", err)
|
||||
|
||||
@@ -19,6 +19,9 @@ package mgr
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/coreos/pkg/capnslog"
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
@@ -36,11 +39,15 @@ import (
|
||||
|
||||
var logger = capnslog.NewPackageLogger("github.com/rook/rook", "op-mgr")
|
||||
|
||||
var prometheusRuleName = "prometheus-ceph-vVERSION-rules"
|
||||
|
||||
const (
|
||||
appName = "rook-ceph-mgr"
|
||||
serviceAccountName = "rook-ceph-mgr"
|
||||
prometheusModuleName = "prometheus"
|
||||
metricsPort = 9283
|
||||
monitoringPath = "/etc/ceph-monitoring/"
|
||||
serviceMonitorFile = "service-monitor.yaml"
|
||||
// minimum amount of memory in MB to run the pod
|
||||
cephMgrPodMinimumMemory uint64 = 512
|
||||
)
|
||||
@@ -58,6 +65,7 @@ type Cluster struct {
|
||||
resources v1.ResourceRequirements
|
||||
ownerRef metav1.OwnerReference
|
||||
dashboard cephv1.DashboardSpec
|
||||
monitoringSpec cephv1.MonitoringSpec
|
||||
cephVersion cephv1.CephVersionSpec
|
||||
rookVersion string
|
||||
exitCode func(err error) (int, bool)
|
||||
@@ -74,6 +82,7 @@ func New(
|
||||
annotations rookalpha.Annotations,
|
||||
hostNetwork bool,
|
||||
dashboard cephv1.DashboardSpec,
|
||||
monitoringSpec cephv1.MonitoringSpec,
|
||||
resources v1.ResourceRequirements,
|
||||
ownerRef metav1.OwnerReference,
|
||||
dataDirHostPath string,
|
||||
@@ -88,6 +97,7 @@ func New(
|
||||
Replicas: 1,
|
||||
dataDir: k8sutil.DataDir,
|
||||
dashboard: dashboard,
|
||||
monitoringSpec: monitoringSpec,
|
||||
HostNetwork: hostNetwork,
|
||||
resources: resources,
|
||||
ownerRef: ownerRef,
|
||||
@@ -171,6 +181,32 @@ func (c *Cluster) Start() error {
|
||||
logger.Infof("mgr metrics service started")
|
||||
}
|
||||
|
||||
// enable monitoring if `monitoring: enabled: true`
|
||||
if c.monitoringSpec.Enabled {
|
||||
if c.clusterInfo.CephVersion.IsAtLeastNautilus() {
|
||||
logger.Infof("starting monitoring deployment")
|
||||
// servicemonitor takes some metadata from the service for easy mapping
|
||||
if err := c.enableServiceMonitor(service); err != nil {
|
||||
logger.Errorf("failed to enable service monitor. %+v", err)
|
||||
} else {
|
||||
logger.Infof("servicemonitor enabled")
|
||||
}
|
||||
// namespace in which the prometheusRule should be deployed
|
||||
// if left empty, it will be deployed in current namespace
|
||||
namespace := c.monitoringSpec.RulesNamespace
|
||||
if namespace == "" {
|
||||
namespace = c.Namespace
|
||||
}
|
||||
if err := c.deployPrometheusRule(prometheusRuleName, namespace); err != nil {
|
||||
logger.Errorf("failed to deploy prometheusule. %+v", err)
|
||||
} else {
|
||||
logger.Infof("prometheusRule deployed")
|
||||
}
|
||||
logger.Debugf("ended monitoring deployment")
|
||||
} else {
|
||||
logger.Debugf("monitoring not supported for ceph versions <v%v", c.clusterInfo.CephVersion.Major)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -181,3 +217,40 @@ func (c *Cluster) enablePrometheusModule(clusterName string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// add a servicemonitor that allows prometheus to scrape from the monitoring endpoint of the cluster
|
||||
func (c *Cluster) enableServiceMonitor(service *v1.Service) error {
|
||||
name := service.GetName()
|
||||
namespace := service.GetNamespace()
|
||||
serviceMonitor, err := k8sutil.GetServiceMonitor(path.Join(monitoringPath, serviceMonitorFile))
|
||||
if err != nil {
|
||||
return fmt.Errorf("service monitor could not be enabled. %+v", err)
|
||||
}
|
||||
serviceMonitor.SetName(name)
|
||||
serviceMonitor.SetNamespace(namespace)
|
||||
k8sutil.SetOwnerRef(&serviceMonitor.ObjectMeta, &c.ownerRef)
|
||||
if _, err := k8sutil.CreateOrUpdateServiceMonitor(serviceMonitor); err != nil {
|
||||
return fmt.Errorf("service monitor could not be enabled. %+v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// deploy prometheusRule that adds alerting and/or recording rules to the cluster
|
||||
func (c *Cluster) deployPrometheusRule(name, namespace string) error {
|
||||
version := strconv.Itoa(c.clusterInfo.CephVersion.Major)
|
||||
name = strings.Replace(name, "VERSION", version, 1)
|
||||
prometheusRuleFile := name + ".yaml"
|
||||
prometheusRuleFile = path.Join(monitoringPath, prometheusRuleFile)
|
||||
prometheusRule, err := k8sutil.GetPrometheusRule(prometheusRuleFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("prometheus rule could not be deployed. %+v", err)
|
||||
}
|
||||
prometheusRule.SetName(name)
|
||||
prometheusRule.SetNamespace(namespace)
|
||||
owners := append(prometheusRule.GetOwnerReferences(), c.ownerRef)
|
||||
k8sutil.SetOwnerRefs(&prometheusRule.ObjectMeta, owners)
|
||||
if _, err := k8sutil.CreateOrUpdatePrometheusRule(prometheusRule); err != nil {
|
||||
return fmt.Errorf("prometheus rule could not be deployed. %+v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -63,6 +63,7 @@ func TestStartMGR(t *testing.T) {
|
||||
rookalpha.Annotations{},
|
||||
false,
|
||||
cephv1.DashboardSpec{Enabled: true},
|
||||
cephv1.MonitoringSpec{Enabled: true, RulesNamespace: ""},
|
||||
v1.ResourceRequirements{},
|
||||
metav1.OwnerReference{},
|
||||
"/var/lib/rook/",
|
||||
|
||||
@@ -45,6 +45,7 @@ func TestPodSpec(t *testing.T) {
|
||||
rookalpha.Annotations{},
|
||||
false,
|
||||
cephv1.DashboardSpec{},
|
||||
cephv1.MonitoringSpec{},
|
||||
v1.ResourceRequirements{
|
||||
Limits: v1.ResourceList{
|
||||
v1.ResourceCPU: *resource.NewQuantity(200.0, resource.BinarySI),
|
||||
@@ -93,6 +94,7 @@ func TestServiceSpec(t *testing.T) {
|
||||
rookalpha.Annotations{},
|
||||
false,
|
||||
cephv1.DashboardSpec{},
|
||||
cephv1.MonitoringSpec{},
|
||||
v1.ResourceRequirements{},
|
||||
metav1.OwnerReference{},
|
||||
"/var/lib/rook/",
|
||||
@@ -116,6 +118,7 @@ func TestHostNetwork(t *testing.T) {
|
||||
rookalpha.Annotations{},
|
||||
true,
|
||||
cephv1.DashboardSpec{},
|
||||
cephv1.MonitoringSpec{},
|
||||
v1.ResourceRequirements{},
|
||||
metav1.OwnerReference{},
|
||||
"/var/lib/rook/",
|
||||
@@ -147,6 +150,7 @@ func TestHttpBindFix(t *testing.T) {
|
||||
rookalpha.Annotations{},
|
||||
true,
|
||||
cephv1.DashboardSpec{},
|
||||
cephv1.MonitoringSpec{},
|
||||
v1.ResourceRequirements{},
|
||||
metav1.OwnerReference{},
|
||||
"/var/lib/rook/",
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package k8sutil
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
||||
monitoringv1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
|
||||
monitoringclient "github.com/coreos/prometheus-operator/pkg/client/versioned"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
k8sYAML "k8s.io/apimachinery/pkg/util/yaml"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
)
|
||||
|
||||
func getMonitoringClient() (*monitoringclient.Clientset, error) {
|
||||
cfg, err := clientcmd.BuildConfigFromFlags("", "")
|
||||
client, err := monitoringclient.NewForConfig(cfg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get monitoring client. %+v", err)
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
|
||||
// GetServiceMonitor returns servicemonitor or an error
|
||||
func GetServiceMonitor(filePath string) (*monitoringv1.ServiceMonitor, error) {
|
||||
file, err := ioutil.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("servicemonitor file could not be fetched. %+v", err)
|
||||
}
|
||||
var servicemonitor monitoringv1.ServiceMonitor
|
||||
err = k8sYAML.NewYAMLOrJSONDecoder(bytes.NewBufferString(string(file)), 1000).Decode(&servicemonitor)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("servicemonitor could not be decoded. %+v", err)
|
||||
}
|
||||
return &servicemonitor, nil
|
||||
}
|
||||
|
||||
// CreateOrUpdateServiceMonitor creates serviceMonitor object or an error
|
||||
func CreateOrUpdateServiceMonitor(serviceMonitorDefinition *monitoringv1.ServiceMonitor) (*monitoringv1.ServiceMonitor, error) {
|
||||
name := serviceMonitorDefinition.GetName()
|
||||
namespace := serviceMonitorDefinition.GetNamespace()
|
||||
logger.Debugf("creating servicemonitor %s", name)
|
||||
client, err := getMonitoringClient()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get monitoring client. %+v", err)
|
||||
}
|
||||
sm, err := client.MonitoringV1().ServiceMonitors(namespace).Create(serviceMonitorDefinition)
|
||||
if err != nil {
|
||||
if !errors.IsAlreadyExists(err) {
|
||||
return nil, fmt.Errorf("failed to create servicemonitor. %+v", err)
|
||||
}
|
||||
sm, err = client.MonitoringV1().ServiceMonitors(namespace).Update(sm)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to update servicemonitor. %+v", err)
|
||||
|
||||
}
|
||||
}
|
||||
return sm, nil
|
||||
}
|
||||
|
||||
// GetPrometheusRule returns provided prometheus rules or an error
|
||||
func GetPrometheusRule(ruleFilePath string) (*monitoringv1.PrometheusRule, error) {
|
||||
ruleFile, err := ioutil.ReadFile(ruleFilePath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("prometheusRules file could not be fetched. %+v", err)
|
||||
}
|
||||
var rule monitoringv1.PrometheusRule
|
||||
err = k8sYAML.NewYAMLOrJSONDecoder(bytes.NewBufferString(string(ruleFile)), 1000).Decode(&rule)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("prometheusRules could not be decoded. %+v", err)
|
||||
}
|
||||
return &rule, nil
|
||||
}
|
||||
|
||||
// CreateOrUpdatePrometheusRule creates a prometheusRule object or an error
|
||||
func CreateOrUpdatePrometheusRule(prometheusRule *monitoringv1.PrometheusRule) (*monitoringv1.PrometheusRule, error) {
|
||||
name := prometheusRule.GetName()
|
||||
namespace := prometheusRule.GetNamespace()
|
||||
logger.Debugf("creating prometheusRule %s", name)
|
||||
client, err := getMonitoringClient()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get monitoring client. %+v", err)
|
||||
}
|
||||
promRule, err := client.MonitoringV1().PrometheusRules(namespace).Create(prometheusRule)
|
||||
if err != nil {
|
||||
if !errors.IsAlreadyExists(err) {
|
||||
return nil, fmt.Errorf("failed to create prometheusRules. %+v", err)
|
||||
}
|
||||
promRule, err = client.MonitoringV1().PrometheusRules(namespace).Update(prometheusRule)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to update prometheusRule. %+v", err)
|
||||
}
|
||||
}
|
||||
return promRule, nil
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package k8sutil
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetServiceMonitor(t *testing.T) {
|
||||
gopath := os.Getenv("GOPATH")
|
||||
filePath := path.Join(gopath, "src/github.com/rook/rook/cluster/examples/kubernetes/ceph/monitoring/service-monitor.yaml")
|
||||
servicemonitor, err := GetServiceMonitor(filePath)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "rook-ceph-mgr", servicemonitor.GetName())
|
||||
assert.Equal(t, "rook-ceph", servicemonitor.GetNamespace())
|
||||
assert.NotNil(t, servicemonitor.Spec.NamespaceSelector.MatchNames)
|
||||
assert.NotNil(t, servicemonitor.Spec.Endpoints)
|
||||
}
|
||||
|
||||
func TestGetPrometheusRule(t *testing.T) {
|
||||
gopath := os.Getenv("GOPATH")
|
||||
filePath := path.Join(gopath, "src/github.com/rook/rook/cluster/examples/kubernetes/ceph/monitoring/prometheus-ceph-v14-rules.yaml")
|
||||
rules, err := GetPrometheusRule(filePath)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "prometheus-ceph-rules", rules.GetName())
|
||||
assert.Equal(t, "rook-ceph", rules.GetNamespace())
|
||||
// Labels should be present as they are used by prometheus for identifying rules
|
||||
assert.NotNil(t, rules.GetLabels())
|
||||
assert.NotNil(t, rules.Spec.Groups)
|
||||
}
|
||||
Reference in new issue
Block a user