Skip to content

Commit 3e5c9d2

Browse files
committedFeb 18, 2024·
Add prometheus support
1 parent a80def2 commit 3e5c9d2

File tree

11 files changed

+249
-165
lines changed

11 files changed

+249
-165
lines changed
 

‎api/v1/immudb_types.go

+12
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ type ImmudbSpec struct {
5050

5151
// +kubebuilder:validation:Required
5252
Ingress ImmudbIngressSpec `json:"ingress"`
53+
54+
// +kubebuilder:validation:Required
55+
ServiceMonitor ImmudbServiceMonitorSpec `json:"serviceMonitor"`
5356
}
5457

5558
type ImmudbVolumeSpec struct {
@@ -79,6 +82,15 @@ type ImmudbIngressSpec struct {
7982
Host string `json:"host"`
8083
}
8184

85+
type ImmudbServiceMonitorSpec struct {
86+
// +kubebuilder:validation:Required
87+
Enabled bool `json:"enabled"`
88+
89+
// Labels Prometheus should be configured to watch.
90+
// +kubebuilder:validation:Optional
91+
Labels map[string]string `json:"labels"`
92+
}
93+
8294
// ImmudbStatus defines the observed state of Immudb
8395
type ImmudbStatus struct {
8496
// Important: Run "make" to regenerate code after modifying this file

‎api/v1/zz_generated.deepcopy.go

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎charts/operator/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ apiVersion: v2
22
name: immudb-operator
33
description: Helm chart to deploy [unagex-immudb-operator](https://github.com/unagex/immudb-operator)
44
type: application
5-
version: 0.0.6
6-
appVersion: 0.0.6
5+
version: 0.0.7
6+
appVersion: 0.0.7
77
home: https://github.com/unagex/immudb-operator

‎charts/operator/templates/crds/unagex.com_immudbs.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ spec:
9393
maximum: 1
9494
minimum: 1
9595
type: integer
96+
serviceMonitor:
97+
properties:
98+
enabled:
99+
type: boolean
100+
labels:
101+
additionalProperties:
102+
type: string
103+
description: Labels Prometheus should be configured to watch.
104+
type: object
105+
required:
106+
- enabled
107+
type: object
96108
volume:
97109
properties:
98110
size:
@@ -107,6 +119,7 @@ spec:
107119
type: object
108120
required:
109121
- ingress
122+
- serviceMonitor
110123
- volume
111124
type: object
112125
status:

‎cmd/main.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
// to ensure that exec-entrypoint and run can make use of them.
2525
_ "k8s.io/client-go/plugin/pkg/client/auth"
2626

27+
monitoring "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
2728
"k8s.io/apimachinery/pkg/runtime"
2829
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
2930
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
@@ -43,8 +44,8 @@ var (
4344

4445
func init() {
4546
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
46-
4747
utilruntime.Must(unagexcomv1.AddToScheme(scheme))
48+
monitoring.AddToScheme(scheme)
4849
//+kubebuilder:scaffold:scheme
4950
}
5051

@@ -67,8 +68,6 @@ func main() {
6768

6869
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
6970
Scheme: scheme,
70-
MetricsBindAddress: metricsAddr,
71-
Port: 9443,
7271
HealthProbeBindAddress: probeAddr,
7372
LeaderElection: enableLeaderElection,
7473
LeaderElectionID: "0f600675.unagex.com",

‎config/crd/bases/unagex.com_immudbs.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ spec:
9393
maximum: 1
9494
minimum: 1
9595
type: integer
96+
serviceMonitor:
97+
properties:
98+
enabled:
99+
type: boolean
100+
labels:
101+
additionalProperties:
102+
type: string
103+
description: Labels Prometheus should be configured to watch.
104+
type: object
105+
required:
106+
- enabled
107+
type: object
96108
volume:
97109
properties:
98110
size:
@@ -107,6 +119,7 @@ spec:
107119
type: object
108120
required:
109121
- ingress
122+
- serviceMonitor
110123
- volume
111124
type: object
112125
status:

‎config/samples/v1_immudb.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ spec:
1717
# - hosts:
1818
# - example.com
1919
# secretName : immudb-sample-secret
20+
serviceMonitor:
21+
enabled: false
22+
# labels:
23+
# app.kubernetes.io/name: immudb

‎go.mod

+33-34
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@ module github.com/unagex/immudb-operator
33
go 1.21
44

55
require (
6-
github.com/go-logr/logr v1.2.4
7-
github.com/onsi/ginkgo/v2 v2.9.5
8-
github.com/onsi/gomega v1.27.7
9-
k8s.io/api v0.27.7
10-
k8s.io/apimachinery v0.27.7
11-
k8s.io/client-go v0.27.7
6+
github.com/go-logr/logr v1.3.0
7+
github.com/onsi/ginkgo/v2 v2.11.0
8+
github.com/onsi/gomega v1.27.10
9+
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.71.2
10+
k8s.io/api v0.28.4
11+
k8s.io/apimachinery v0.28.4
12+
k8s.io/client-go v0.28.4
1213
k8s.io/utils v0.0.0-20240102154912-e7106e64919e
13-
sigs.k8s.io/controller-runtime v0.15.0
14+
sigs.k8s.io/controller-runtime v0.16.3
1415
)
1516

1617
require (
1718
github.com/beorn7/perks v1.0.1 // indirect
1819
github.com/cespare/xxhash/v2 v2.2.0 // indirect
19-
github.com/davecgh/go-spew v1.1.1 // indirect
20-
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
21-
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
20+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
21+
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
2222
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
2323
github.com/fsnotify/fsnotify v1.6.0 // indirect
2424
github.com/go-logr/zapr v1.2.4 // indirect
2525
github.com/go-openapi/jsonpointer v0.19.6 // indirect
26-
github.com/go-openapi/jsonreference v0.20.1 // indirect
26+
github.com/go-openapi/jsonreference v0.20.2 // indirect
2727
github.com/go-openapi/swag v0.22.3 // indirect
2828
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
2929
github.com/gogo/protobuf v1.3.2 // indirect
3030
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
3131
github.com/golang/protobuf v1.5.3 // indirect
32-
github.com/google/gnostic v0.5.7-v3refs // indirect
33-
github.com/google/go-cmp v0.5.9 // indirect
32+
github.com/google/gnostic-models v0.6.8 // indirect
33+
github.com/google/go-cmp v0.6.0 // indirect
3434
github.com/google/gofuzz v1.2.0 // indirect
3535
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
3636
github.com/google/uuid v1.3.0 // indirect
@@ -43,33 +43,32 @@ require (
4343
github.com/modern-go/reflect2 v1.0.2 // indirect
4444
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
4545
github.com/pkg/errors v0.9.1 // indirect
46-
github.com/prometheus/client_golang v1.15.1 // indirect
46+
github.com/prometheus/client_golang v1.16.0 // indirect
4747
github.com/prometheus/client_model v0.4.0 // indirect
48-
github.com/prometheus/common v0.42.0 // indirect
49-
github.com/prometheus/procfs v0.9.0 // indirect
48+
github.com/prometheus/common v0.44.0 // indirect
49+
github.com/prometheus/procfs v0.10.1 // indirect
5050
github.com/spf13/pflag v1.0.5 // indirect
51-
github.com/stretchr/testify v1.8.3 // indirect
52-
go.uber.org/atomic v1.7.0 // indirect
53-
go.uber.org/multierr v1.6.0 // indirect
54-
go.uber.org/zap v1.24.0 // indirect
55-
golang.org/x/net v0.17.0 // indirect
56-
golang.org/x/oauth2 v0.5.0 // indirect
57-
golang.org/x/sys v0.13.0 // indirect
58-
golang.org/x/term v0.13.0 // indirect
59-
golang.org/x/text v0.13.0 // indirect
51+
go.uber.org/multierr v1.11.0 // indirect
52+
go.uber.org/zap v1.25.0 // indirect
53+
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
54+
golang.org/x/net v0.19.0 // indirect
55+
golang.org/x/oauth2 v0.8.0 // indirect
56+
golang.org/x/sys v0.15.0 // indirect
57+
golang.org/x/term v0.15.0 // indirect
58+
golang.org/x/text v0.14.0 // indirect
6059
golang.org/x/time v0.3.0 // indirect
61-
golang.org/x/tools v0.9.1 // indirect
62-
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
60+
golang.org/x/tools v0.9.3 // indirect
61+
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
6362
google.golang.org/appengine v1.6.7 // indirect
64-
google.golang.org/protobuf v1.30.0 // indirect
63+
google.golang.org/protobuf v1.31.0 // indirect
6564
gopkg.in/inf.v0 v0.9.1 // indirect
6665
gopkg.in/yaml.v2 v2.4.0 // indirect
6766
gopkg.in/yaml.v3 v3.0.1 // indirect
68-
k8s.io/apiextensions-apiserver v0.27.7 // indirect
69-
k8s.io/component-base v0.27.7 // indirect
70-
k8s.io/klog/v2 v2.90.1 // indirect
71-
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
67+
k8s.io/apiextensions-apiserver v0.28.4 // indirect
68+
k8s.io/component-base v0.28.4 // indirect
69+
k8s.io/klog/v2 v2.110.1 // indirect
70+
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
7271
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
73-
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
74-
sigs.k8s.io/yaml v1.3.0 // indirect
72+
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
73+
sigs.k8s.io/yaml v1.4.0 // indirect
7574
)

0 commit comments

Comments
 (0)
Please sign in to comment.