Skip to content

Commit

Permalink
feat: add ServiceMonitor crd
Browse files Browse the repository at this point in the history
Signed-off-by: joshua <i@joshua.su>
  • Loading branch information
sujoshua committed Aug 26, 2024
1 parent 619c423 commit f4c441b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
7 changes: 7 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package main

import (
"flag"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"log"
"os"
"reflect"
"strings"
Expand Down Expand Up @@ -94,6 +96,11 @@ func main() {

config := getConfig()

// Register the ServiceMonitor API
if err := monitoringv1.AddToScheme(mgr.GetScheme()); err != nil {
log.Fatalf("unable to register ServiceMonitor API: %v", err)
}

if err = (&controller.JobReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Expand Down
13 changes: 13 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ rules:
- ""
resources:
- persistentvolumeclaims
- configmaps
verbs:
- create
- delete
Expand Down Expand Up @@ -206,3 +207,15 @@ rules:
- patch
- update
- watch
- apiGroups:
- monitoring.coreos.com
resources:
- servicemonitors
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
6 changes: 3 additions & 3 deletions internal/controller/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import "github.com/CQUPTMirror/kubesync/api/v1beta1"

func getCommonLabels(job *v1beta1.Job) map[string]string {
labels := map[string]string{
"kubernetes.io/app": job.Name,
"kubernetes.io/component": "mirror",
"kubernetes.io/managed-by": "kubesync",
"app.kubernetes.io/app": job.Name,
"app.kubernetes.io/component": "mirror",
"app.kubernetes.io/managed-by": "kubesync",
}

return labels
Expand Down

0 comments on commit f4c441b

Please sign in to comment.