forked from grafana/loki
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix olm-based deployments on openshift (grafana#96)
- Loading branch information
Showing
22 changed files
with
246 additions
and
114 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package gateway | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/ViaQ/logerr/kverrors" | ||
lokiv1beta1 "github.com/ViaQ/loki-operator/api/v1beta1" | ||
"github.com/ViaQ/loki-operator/internal/external/k8s" | ||
"github.com/ViaQ/loki-operator/internal/status" | ||
configv1 "github.com/openshift/api/config/v1" | ||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
// GetOpenShiftBaseDomain returns the cluster DNS base domain on OpenShift | ||
// clusters to auto-create redirect URLs for OpenShift Auth or an error. | ||
// If the config.openshift.io/DNS object is not found the whole lokistack | ||
// resoure is set to a degraded state. | ||
func GetOpenShiftBaseDomain(ctx context.Context, k k8s.Client, req ctrl.Request) (string, error) { | ||
var cluster configv1.DNS | ||
key := client.ObjectKey{Name: "cluster"} | ||
if err := k.Get(ctx, key, &cluster); err != nil { | ||
|
||
if apierrors.IsNotFound(err) { | ||
return "", status.SetDegradedCondition(ctx, k, req, | ||
"Missing cluster DNS configuration to read base domain", | ||
lokiv1beta1.ReasonMissingGatewayOpenShiftBaseDomain, | ||
) | ||
} | ||
return "", kverrors.Wrap(err, "failed to lookup lokistack gateway base domain", | ||
"name", key) | ||
} | ||
|
||
return cluster.Spec.BaseDomain, nil | ||
} |
Oops, something went wrong.