Skip to content

Commit

Permalink
Merge pull request #126 from topolvm/remove-old-metrics
Browse files Browse the repository at this point in the history
Remove old metrics
  • Loading branch information
cupnes committed Jun 12, 2024
2 parents 9a9f580 + 1c01d73 commit d74f4ba
Show file tree
Hide file tree
Showing 25 changed files with 167 additions and 1,478 deletions.
60 changes: 26 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,68 +17,60 @@ pie verifies that PVs are successfully provisioned on the specified nodes for th
## Getting Started
### Running on the cluster

1. Create values.yaml. At least the following setting is mandatory.

```yaml
controller:
monitoringStorageClasses: [<storage_classes_to_be_monitored>]
```

2. Then you can install it using Helm.

1. Install pie using Helm:
```sh
helm repo add pie https://topolvm.github.io/pie
helm install pie --values values.yaml
helm install pie
```
2. Create a PieProbe resource:
```sh
cat <<EOS | kubectl apply -f -
apiVersion: pie.topolvm.io/v1alpha1
kind: PieProbe
metadata:
name: pieprobe
spec:
monitoringStorageClass: YOUR-STORAGE-CLASS-NAME # This field is mandatory.
# All other fields are optional.
nodeSelector:
nodeSelectorTerms:
- matchExpressions:
- key: foo
operator: DoesNotExist
probePeriod: 1
probeThreshold: 10s
EOS
```
## Prometheus metrics
### `pie_io_write_latency_seconds`
IO latency of write.

TYPE: gauge

### `pie_io_read_latency_seconds`
IO latency of read.

TYPE: gauge

### `pie_create_probe_total`
The number of attempts of the creation of the Pod object and the creation of the container.

TYPE: counter

### `pie_performance_probe_total`
The number of attempts of performing the IO benchmarks.

TYPE: counter
### `pie_io_write_latency_on_mount_probe_seconds`
_Experimental metrics._ IO latency of write, benchmarked on mount-probe Pods.
IO latency of write, benchmarked on mount-probe Pods.
TYPE: gauge
### `pie_io_read_latency_on_mount_probe_seconds`
_Experimental metrics._ IO latency of read, benchmarked on mount-probe Pods.
IO latency of read, benchmarked on mount-probe Pods.
TYPE: gauge
### `pie_mount_probe_total`
_Experimental metrics._ The number of attempts of the creation of the mount-probe Pod object and the creation of the container.
The number of attempts of the creation of the mount-probe Pod object and the creation of the container.
TYPE: counter
### `pie_performance_on_mount_probe_total`
_Experimental metrics._ The number of attempts of performing the IO benchmarks on mount-probe Pods.
The number of attempts of performing the IO benchmarks on mount-probe Pods.
TYPE: counter
### `pie_provision_probe_total`
_Experimental metrics._ The number of attempts of the creation of the provision-probe Pod object and the creation of the container.
The number of attempts of the creation of the provision-probe Pod object and the creation of the container.
TYPE: counter
Expand Down
12 changes: 9 additions & 3 deletions api/pie/v1alpha1/pieprobe_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ type PieProbeSpec struct {
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="monitoringStorageClass is immutable"
MonitoringStorageClass string `json:"monitoringStorageClass"`

NodeSelector corev1.NodeSelector `json:"nodeSelector"`
ProbePeriod int `json:"probePeriod"`
ProbeThreshold string `json:"probeThreshold"`
NodeSelector corev1.NodeSelector `json:"nodeSelector"`

//+kubebuilder:default:=1
//+kubebuilder:validation:Maximum:=59
//+kubebuilder:validation:Minimum:=1
ProbePeriod int `json:"probePeriod"`

//+kubebuilder:default:="1m"
ProbeThreshold metav1.Duration `json:"probeThreshold"`
}

// PieProbeStatus defines the observed state of PieProbe
Expand Down
1 change: 1 addition & 0 deletions api/pie/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions charts/pie/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,12 @@ spec:
{{- toYaml .Values.resources | nindent 12 }}
args:
- "controller"
{{- range .Values.controller.monitoringStorageClasses }}
- "--monitoring-storage-class={{ . }}"
{{- end }}
- "--container-image"
- "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
- "--namespace"
- "{{ .Release.Namespace }}"
- "--controller-url"
- "http://{{ include "pie.fullname" . }}.{{ .Release.Namespace }}.svc:8082"
{{- with .Values.controller.createProbeThreshold }}
- "--create-probe-threshold={{ . }}"
{{- end }}
{{- with .Values.controller.nodeSelector }}
- "--node-selector"
- "{{ . }}"
{{- end }}
{{- with .Values.controller.probePeriod }}
- "--probe-period"
- "{{ . }}"
{{- end }}
{{- with .Values.controller.enablePProf }}
- "--enable-pprof"
- "{{ . }}"
Expand Down
4 changes: 4 additions & 0 deletions charts/pie/templates/pie.topolvm.io_pieprobes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,12 @@ spec:
type: object
x-kubernetes-map-type: atomic
probePeriod:
default: 1
maximum: 59
minimum: 1
type: integer
probeThreshold:
default: 1m
type: string
required:
- monitoringStorageClass
Expand Down
47 changes: 0 additions & 47 deletions charts/pie/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@ rules:
- patch
- update
- watch
- apiGroups:
- ""
resources:
- nodes/finalizers
verbs:
- update
- apiGroups:
- ""
resources:
- nodes/status
verbs:
- get
- patch
- update
- apiGroups:
- pie.topolvm.io
resources:
Expand Down Expand Up @@ -59,27 +45,9 @@ rules:
resources:
- storageclasses
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- storage.k8s.io
resources:
- storageclasses/finalizers
verbs:
- update
- apiGroups:
- storage.k8s.io
resources:
- storageclasses/status
verbs:
- get
- patch
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
Expand All @@ -94,7 +62,6 @@ rules:
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
Expand Down Expand Up @@ -133,20 +100,6 @@ rules:
- patch
- update
- watch
- apiGroups:
- ""
resources:
- pods/finalizers
verbs:
- update
- apiGroups:
- ""
resources:
- pods/status
verbs:
- get
- patch
- update
---
# permissions to do leader election.
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
3 changes: 0 additions & 3 deletions charts/pie/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,4 @@ tolerations: []
affinity: {}

controller:
monitoringStorageClasses: []
createProbeThreshold:
nodeSelector:
enablePProf:
76 changes: 7 additions & 69 deletions cmd/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/topolvm/pie/internal/controller"
"github.com/topolvm/pie/internal/controller/pie"
"github.com/topolvm/pie/metrics"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
Expand All @@ -38,17 +37,13 @@ var (
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")

metricsAddr string
enableLeaderElection bool
healthProbeAddr string
containerImage string
monitoringStorageClasses []string
nodeSelectorString string
namespace string
controllerURL string
probePeriod int
createProbeThreshold time.Duration
enablePProf bool
metricsAddr string
enableLeaderElection bool
healthProbeAddr string
containerImage string
namespace string
controllerURL string
enablePProf bool

opts zap.Options
)
Expand All @@ -61,12 +56,8 @@ func init() {
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
flags.StringVar(&containerImage, "container-image", "", "The container image for pie.")
flags.StringArrayVar(&monitoringStorageClasses, "monitoring-storage-class", nil, "Monitoring target StorageClasses.")
flags.StringVar(&nodeSelectorString, "node-selector", "", "The node selector for monitor nodes.")
flags.StringVar(&namespace, "namespace", "", "The namespace which the controller uses.")
flags.StringVar(&controllerURL, "controller-url", "", "The controller URL which probe pods access")
flags.IntVar(&probePeriod, "probe-period", 1, "The period[minute] for CronJob to create a probe pod.")
flags.DurationVar(&createProbeThreshold, "create-probe-threshold", time.Minute, "The threshold of probe creation.")
flags.BoolVar(&enablePProf, "enable-pprof", false, "Enable PProf function")
opts.Development = true

Expand Down Expand Up @@ -125,34 +116,6 @@ func subMain() error {
setupLog.Error(err, "the container image should be specified")
return err
}
nodeSelector, err := metav1.ParseToLabelSelector(nodeSelectorString)
if err != nil {
setupLog.Error(err, "invalid node selector")
return err
}
if probePeriod < 1 || probePeriod > 59 {
err = errors.New("invalid probe period")
setupLog.Error(err, "the probe period should be between 1 and 59", "probe period", probePeriod)
return err
}
if time.Duration(probePeriod)*time.Minute < createProbeThreshold {
err = errors.New("invalid large/small relation")
setupLog.Error(err, "probe period should be larger than create probe threshold",
"probe period", probePeriod, "create probe threshold", createProbeThreshold)
return err
}
podReconciler := controller.NewPodReconciler(
mgr.GetClient(),
createProbeThreshold,
exporter,
monitoringStorageClasses,
namespace,
)
err = podReconciler.SetupWithManager(mgr)
if err != nil {
setupLog.Error(err, "unable to start podReconciler")
return err
}

probePodReconciler := controller.NewProbePodReconciler(
mgr.GetClient(),
Expand All @@ -169,31 +132,6 @@ func subMain() error {
setupLog.Error(err, "the controllerURL should be specified")
return err
}
nodeReconciler := controller.NewNodeReconciler(
mgr.GetClient(),
containerImage,
namespace,
controllerURL,
monitoringStorageClasses,
nodeSelector,
probePeriod,
)
err = nodeReconciler.SetupWithManager(mgr)
if err != nil {
setupLog.Error(err, "unable to start nodeReconciler")
return err
}

storageClassReconciler := controller.NewStorageClassReconciler(
mgr.GetClient(),
namespace,
monitoringStorageClasses,
)
err = storageClassReconciler.SetupWithManager(mgr)
if err != nil {
setupLog.Error(err, "unable to start storageClassReconciler")
return err
}

pieProbeController := pie.NewPieProbeController(
mgr.GetClient(),
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/pie.topolvm.io_pieprobes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,12 @@ spec:
type: object
x-kubernetes-map-type: atomic
probePeriod:
default: 1
maximum: 59
minimum: 1
type: integer
probeThreshold:
default: 1m
type: string
required:
- monitoringStorageClass
Expand Down
Loading

0 comments on commit d74f4ba

Please sign in to comment.