-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
operator: Use cluster monitoring alertmanager by default on openshift…
… clusters (#7272)
- Loading branch information
Mohamed-Amine Bouqsimi
authored
Oct 4, 2022
1 parent
6bf5b5d
commit 4103b32
Showing
21 changed files
with
550 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
operator/internal/handlers/internal/openshift/alertmanager.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package openshift | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/ViaQ/logerr/v2/kverrors" | ||
lokiv1 "github.com/grafana/loki/operator/apis/loki/v1" | ||
"github.com/grafana/loki/operator/internal/external/k8s" | ||
"github.com/grafana/loki/operator/internal/manifests/openshift" | ||
corev1 "k8s.io/api/core/v1" | ||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
// AlertManagerSVCExists returns true if the Openshift AlertManager is present in the cluster. | ||
func AlertManagerSVCExists(ctx context.Context, stack lokiv1.LokiStackSpec, k k8s.Client) (bool, error) { | ||
if stack.Tenants == nil || (stack.Tenants.Mode != lokiv1.OpenshiftLogging && stack.Tenants.Mode != lokiv1.OpenshiftNetwork) { | ||
return false, nil | ||
} | ||
|
||
var svc corev1.Service | ||
key := client.ObjectKey{Name: openshift.MonitoringSVCOperated, Namespace: openshift.MonitoringNS} | ||
|
||
err := k.Get(ctx, key, &svc) | ||
if err != nil && !apierrors.IsNotFound(err) { | ||
return false, kverrors.Wrap(err, "failed to lookup alertmanager service", "name", key) | ||
} | ||
|
||
return err == nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.