Skip to content

Commit

Permalink
Add prometheus support
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuCesbron committed Feb 18, 2024
1 parent a80def2 commit 3e5c9d2
Show file tree
Hide file tree
Showing 11 changed files with 249 additions and 165 deletions.
12 changes: 12 additions & 0 deletions api/v1/immudb_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ type ImmudbSpec struct {

// +kubebuilder:validation:Required
Ingress ImmudbIngressSpec `json:"ingress"`

// +kubebuilder:validation:Required
ServiceMonitor ImmudbServiceMonitorSpec `json:"serviceMonitor"`
}

type ImmudbVolumeSpec struct {
Expand Down Expand Up @@ -79,6 +82,15 @@ type ImmudbIngressSpec struct {
Host string `json:"host"`
}

type ImmudbServiceMonitorSpec struct {
// +kubebuilder:validation:Required
Enabled bool `json:"enabled"`

// Labels Prometheus should be configured to watch.
// +kubebuilder:validation:Optional
Labels map[string]string `json:"labels"`
}

// ImmudbStatus defines the observed state of Immudb
type ImmudbStatus struct {
// Important: Run "make" to regenerate code after modifying this file
Expand Down
23 changes: 23 additions & 0 deletions api/v1/zz_generated.deepcopy.go

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

4 changes: 2 additions & 2 deletions charts/operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ apiVersion: v2
name: immudb-operator
description: Helm chart to deploy [unagex-immudb-operator](https://github.com/unagex/immudb-operator)
type: application
version: 0.0.6
appVersion: 0.0.6
version: 0.0.7
appVersion: 0.0.7
home: https://github.com/unagex/immudb-operator
13 changes: 13 additions & 0 deletions charts/operator/templates/crds/unagex.com_immudbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ spec:
maximum: 1
minimum: 1
type: integer
serviceMonitor:
properties:
enabled:
type: boolean
labels:
additionalProperties:
type: string
description: Labels Prometheus should be configured to watch.
type: object
required:
- enabled
type: object
volume:
properties:
size:
Expand All @@ -107,6 +119,7 @@ spec:
type: object
required:
- ingress
- serviceMonitor
- volume
type: object
status:
Expand Down
5 changes: 2 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"

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

func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))

utilruntime.Must(unagexcomv1.AddToScheme(scheme))
monitoring.AddToScheme(scheme)
//+kubebuilder:scaffold:scheme
}

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

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "0f600675.unagex.com",
Expand Down
13 changes: 13 additions & 0 deletions config/crd/bases/unagex.com_immudbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ spec:
maximum: 1
minimum: 1
type: integer
serviceMonitor:
properties:
enabled:
type: boolean
labels:
additionalProperties:
type: string
description: Labels Prometheus should be configured to watch.
type: object
required:
- enabled
type: object
volume:
properties:
size:
Expand All @@ -107,6 +119,7 @@ spec:
type: object
required:
- ingress
- serviceMonitor
- volume
type: object
status:
Expand Down
4 changes: 4 additions & 0 deletions config/samples/v1_immudb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ spec:
# - hosts:
# - example.com
# secretName : immudb-sample-secret
serviceMonitor:
enabled: false
# labels:
# app.kubernetes.io/name: immudb
67 changes: 33 additions & 34 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@ module github.com/unagex/immudb-operator
go 1.21

require (
github.com/go-logr/logr v1.2.4
github.com/onsi/ginkgo/v2 v2.9.5
github.com/onsi/gomega v1.27.7
k8s.io/api v0.27.7
k8s.io/apimachinery v0.27.7
k8s.io/client-go v0.27.7
github.com/go-logr/logr v1.3.0
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.10
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.71.2
k8s.io/api v0.28.4
k8s.io/apimachinery v0.28.4
k8s.io/client-go v0.28.4
k8s.io/utils v0.0.0-20240102154912-e7106e64919e
sigs.k8s.io/controller-runtime v0.15.0
sigs.k8s.io/controller-runtime v0.16.3
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/uuid v1.3.0 // indirect
Expand All @@ -43,33 +43,32 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.15.1 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.8.3 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.9.1 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
golang.org/x/tools v0.9.3 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.27.7 // indirect
k8s.io/component-base v0.27.7 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/apiextensions-apiserver v0.28.4 // indirect
k8s.io/component-base v0.28.4 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit 3e5c9d2

Please sign in to comment.