Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Commit

Permalink
Ctrl-213: configure metrics-exporter with a configmap (#198)
Browse files Browse the repository at this point in the history
* configure metrics-exporter with a configmap

The configmap/storage-metrics-exporter is controlled by
StorageOSCluster.Spec.Metrics.* parameters. Whenever the cluster
paramers change, the CM gets updated by the operator and
storage-metrics-exporter pods get redeployed.

The reloading of the CM inside the exporter's pods is achieved by
setting the CM's resourceVersion on the DaemonSet.

* added [email protected] go api dependency

* dockerignore: ignore local GOPATH=./.go

* updated metrics-exporter bundle to v0.1.7

Signed-off-by: Michal Minář <[email protected]>
  • Loading branch information
Michal Minář authored Jun 29, 2022
1 parent 965f14d commit 208295e
Show file tree
Hide file tree
Showing 586 changed files with 30,890 additions and 14,083 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
!**/*.go
!**/*.mod
!**/*.sum
# ignore local GOPATH=$(pwd)/.go/
.go/
2 changes: 1 addition & 1 deletion .github/workflows/build-and-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env:
RELATED_IMAGE_UPGRADE_GUARD=storageos/upgrade-guard:develop
RELATED_IMAGE_CSIV1_NODE_DRIVER_REGISTRAR=quay.io/k8scsi/csi-node-driver-registrar:v2.1.0
RELATED_IMAGE_CSIV1_LIVENESS_PROBE=quay.io/k8scsi/livenessprobe:v2.2.0
RELATED_IMAGE_METRICS_EXPORTER=storageos/metrics-exporter:v0.1.6
RELATED_IMAGE_METRICS_EXPORTER=storageos/metrics-exporter:v0.1.7
jobs:
cancel-previous:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/develop-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env:
RELATED_IMAGE_UPGRADE_GUARD=storageos/upgrade-guard:develop
RELATED_IMAGE_CSIV1_NODE_DRIVER_REGISTRAR=quay.io/k8scsi/csi-node-driver-registrar:v2.1.0
RELATED_IMAGE_CSIV1_LIVENESS_PROBE=quay.io/k8scsi/livenessprobe:v2.2.0
RELATED_IMAGE_METRICS_EXPORTER=storageos/metrics-exporter:v0.1.6
RELATED_IMAGE_METRICS_EXPORTER=storageos/metrics-exporter:v0.1.7
jobs:
cancel-previous:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ NODE_MANAGER_MANIFESTS_IMAGE ?= storageos/node-manager-manifests
UPGRADE_GUARD_IMAGE ?= storageos/upgrade-guard:develop
NODE_DRIVER_REG_IMAGE ?= quay.io/k8scsi/csi-node-driver-registrar:v2.1.0
LIVENESS_PROBE_IMAGE ?= quay.io/k8scsi/livenessprobe:v2.2.0
METRICS_EXPORTER_VERSION ?= v0.1.6
METRICS_EXPORTER_VERSION ?= v0.1.7
METRICS_EXPORTER_IMAGE ?= storageos/metrics-exporter:$(METRICS_EXPORTER_VERSION)
METRICS_EXPORTER_MANIFESTS_URL ?= https://github.com/ondat/metrics-exporter/releases/download/$(METRICS_EXPORTER_VERSION)/bundle.yaml

Expand Down
6 changes: 6 additions & 0 deletions api/v1/storageoscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package v1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

metricsv1 "github.com/ondat/metrics-exporter/api/config.storageos.com/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
Expand Down Expand Up @@ -238,6 +240,10 @@ type StorageOSClusterKVBackend struct {
// Metrics contains the configuration for metrics.
type Metrics struct {
Enabled bool `json:"enabled,omitempty"`

// MetricsExporterConfigSpec is the source of configuration values for the metrics-exporter ConfigMap
// which is managed by the operator.
metricsv1.MetricsExporterConfigSpec `json:",inline"`
}

// Snapshots contains the configuration for snapshots.
Expand Down
3 changes: 2 additions & 1 deletion api/v1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ data:
RELATED_IMAGE_CSIV1_EXTERNAL_SNAPSHOTTER: quay.io/k8scsi/csi-snapshotter:v4.0.0
RELATED_IMAGE_CSIV1_LIVENESS_PROBE: quay.io/k8scsi/livenessprobe:v2.2.0
RELATED_IMAGE_CSIV1_NODE_DRIVER_REGISTRAR: quay.io/k8scsi/csi-node-driver-registrar:v2.1.0
RELATED_IMAGE_METRICS_EXPORTER: storageos/metrics-exporter:v0.1.6
RELATED_IMAGE_METRICS_EXPORTER: storageos/metrics-exporter:v0.1.7
RELATED_IMAGE_NODE_MANAGER: storageos/node-manager:develop
RELATED_IMAGE_PORTAL_MANAGER: storageos/portal-manager:develop
RELATED_IMAGE_STORAGEOS_INIT: storageos/init:v2.1.2
Expand Down
27 changes: 27 additions & 0 deletions bundle/manifests/storageos.com_storageosclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,35 @@ spec:
metrics:
description: Metrics feature configuration.
properties:
disabledCollectors:
description: DisabledCollectors is a list of collectors that shall
be disabled. By default, all are enabled.
items:
description: MetricsExporterCollector is the name of a metrics
collector in the metrics-exporter.
enum:
- diskstats
- filesystem
type: string
type: array
enabled:
type: boolean
logLevel:
description: Verbosity of log messages. Accepts go.uber.org/zap
log levels.
enum:
- debug
- info
- warn
- error
- dpanic
- panic
- fatal
type: string
timeout:
description: Timeout in seconds to serve metrics.
minimum: 1
type: integer
type: object
namespace:
description: 'Namespace is the kubernetes Namespace where storageos
Expand Down
2 changes: 1 addition & 1 deletion channels/1.23
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ manifests:
- name: after-install
version: 0.1.0
- name: metrics-exporter
version: 0.1.6
version: 0.1.7
- name: volumesnapshotclass
version: 0.1.0
2 changes: 1 addition & 1 deletion channels/1.24
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ manifests:
- name: after-install
version: 0.1.1
- name: metrics-exporter
version: 0.1.6
version: 0.1.7
- name: volumesnapshotclass
version: 0.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: ClusterRole
metadata:
labels:
app: storageos
app.kubernetes.io/component: metrics-exporter
name: storageos:metrics-exporter
rules:
- apiGroups:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: ClusterRoleBinding
metadata:
labels:
app: storageos
app.kubernetes.io/component: metrics-exporter
name: storageos:metrics-exporter
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

apiVersion: v1
data:
metrics-exporter-config.yaml: |
config.yaml: |
apiVersion: config.storageos.com/v1
kind: MetricsExporterConfig
logLevel: info
Expand All @@ -10,5 +10,6 @@ kind: ConfigMap
metadata:
labels:
app: storageos
name: storageos-metrics-exporter-6kd7dt7582
app.kubernetes.io/component: metrics-exporter
name: storageos-metrics-exporter
namespace: storageos
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,26 @@ kind: DaemonSet
metadata:
labels:
app: storageos
app.kubernetes.io/component: metrics-exporter
name: storageos-metrics-exporter
namespace: storageos
spec:
selector:
matchLabels:
app: storageos
app.kubernetes.io/component: metrics-exporter
template:
metadata:
labels:
app: storageos
app.kubernetes.io/component: metrics-exporter
category: metrics-exporter
spec:
containers:
- args:
- -config
- /etc/storageos/metrics-exporter-config.yaml
image: storageos/metrics-exporter:v0.1.6
image: storageos/metrics-exporter:v0.1.7
imagePullPolicy: IfNotPresent
name: storageos-metrics-exporter
securityContext:
Expand All @@ -37,7 +40,7 @@ spec:
- mountPath: /etc/storageos/metrics-exporter-config.yaml
name: storageos-metrics-exporter
readOnly: true
subPath: metrics-exporter-config.yaml
subPath: config.yaml
serviceAccountName: storageos-metrics-exporter
volumes:
- hostPath:
Expand All @@ -48,5 +51,5 @@ spec:
type: Directory
name: kubelet-dir
- configMap:
name: storageos-metrics-exporter-6kd7dt7582
name: storageos-metrics-exporter
name: storageos-metrics-exporter
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ resources:
- serviceaccount-storageos-metrics-exporter.yaml
- clusterrole-storageos-metrics-exporter.yaml
- clusterrolebinding-storageos-metrics-exporter.yaml
- configmap-storageos-metrics-exporter-6kd7dt7582.yaml
- configmap-storageos-metrics-exporter.yaml
- service-storageos-metrics-exporter.yaml
- daemonset-storageos-metrics-exporter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: Service
metadata:
labels:
app: storageos
service-discovery: storageos-metrics-exporter
app.kubernetes.io/component: metrics-exporter
name: storageos-metrics-exporter
namespace: storageos
spec:
Expand All @@ -14,4 +14,5 @@ spec:
port: 9100
selector:
app: storageos
app.kubernetes.io/component: metrics-exporter
category: metrics-exporter
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ kind: ServiceAccount
metadata:
labels:
app: storageos
app.kubernetes.io/component: metrics-exporter
name: storageos-metrics-exporter
namespace: storageos
2 changes: 1 addition & 1 deletion channels/stable
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ manifests:
- name: after-install
version: 0.1.0
- name: metrics-exporter
version: 0.1.6
version: 0.1.7
- name: volumesnapshotclass
version: 0.1.0
27 changes: 27 additions & 0 deletions config/crd/bases/storageos.com_storageosclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,35 @@ spec:
metrics:
description: Metrics feature configuration.
properties:
disabledCollectors:
description: DisabledCollectors is a list of collectors that shall
be disabled. By default, all are enabled.
items:
description: MetricsExporterCollector is the name of a metrics
collector in the metrics-exporter.
enum:
- diskstats
- filesystem
type: string
type: array
enabled:
type: boolean
logLevel:
description: Verbosity of log messages. Accepts go.uber.org/zap
log levels.
enum:
- debug
- info
- warn
- error
- dpanic
- panic
- fatal
type: string
timeout:
description: Timeout in seconds to serve metrics.
minimum: 1
type: integer
type: object
namespace:
description: 'Namespace is the kubernetes Namespace where storageos
Expand Down
2 changes: 1 addition & 1 deletion config/manager/related_images_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ RELATED_IMAGE_NODE_MANAGER=storageos/node-manager:develop
RELATED_IMAGE_UPGRADE_GUARD=storageos/upgrade-guard:develop
RELATED_IMAGE_CSIV1_NODE_DRIVER_REGISTRAR=quay.io/k8scsi/csi-node-driver-registrar:v2.1.0
RELATED_IMAGE_CSIV1_LIVENESS_PROBE=quay.io/k8scsi/livenessprobe:v2.2.0
RELATED_IMAGE_METRICS_EXPORTER=storageos/metrics-exporter:v0.1.6
RELATED_IMAGE_METRICS_EXPORTER=storageos/metrics-exporter:v0.1.7
3 changes: 2 additions & 1 deletion controllers/config_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"

storageoscomv1 "github.com/storageos/operator/api/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/util/workqueue"
Expand All @@ -13,6 +12,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/source"

storageoscomv1 "github.com/storageos/operator/api/v1"
)

// ConfigReconciler reconciles StorageOS related configs.
Expand Down
Loading

0 comments on commit 208295e

Please sign in to comment.