import(
"k8s.io/api/core/v1"
"github.com/operator-framework/operator-sdk/pkg/metrics"
"machine.openshift.io/controller-runtime/pkg/client/config"
)
func main() {
...
// Populate below with the Service(s) for which you want to create ServiceMonitors.
services := []*v1.Service{}
// Create one ServiceMonitor per application per namespace.
// Change the below value to name of the Namespace you want the ServiceMonitor to be created in.
ns := "default"
// restConfig is used for talking to the Kubernetes apiserver
restConfig := config.GetConfig()
// Pass the Service(s) to the helper function, which in turn returns the array of ServiceMonitor objects.
serviceMonitors, err := metrics.CreateServiceMonitors(restConfig, ns, services)
if err != nil {
// Handle errors here.
}
...
}
import(
"k8s.io/api/core/v1"
"github.com/operator-framework/operator-sdk/pkg/metrics"
"machine.openshift.io/controller-runtime/pkg/client/config"
)
func main() {
...
// Populate below with the Service(s) for which you want to create ServiceMonitors.
services := []*v1.Service{}
// Create one ServiceMonitor per application per namespace.
// Change the below value to name of the Namespace you want the ServiceMonitor to be created in.
ns := "default"
// restConfig is used for talking to the Kubernetes apiserver
restConfig := config.GetConfig()
// Pass the Service(s) to the helper function, which in turn returns the array of ServiceMonitor objects.
serviceMonitors, err := metrics.CreateServiceMonitors(restConfig, ns, services)
if err != nil {
// Handle errors here.
}
...
}
Copy to ClipboardCopied!Toggle word wrapToggle overflow