Search in sources :

Example 1 with PrometheusConfig

use of io.stackgres.operator.customresource.prometheus.PrometheusConfig in project stackgres by ongres.

the class ClusterRequiredResourcesGenerator method getPrometheus.

public Optional<Prometheus> getPrometheus(StackGresCluster cluster) {
    boolean isAutobindAllowed = operatorContext.getBoolean(OperatorProperty.PROMETHEUS_AUTOBIND);
    boolean isPrometheusAutobindEnabled = Optional.ofNullable(cluster.getSpec().getPrometheusAutobind()).orElse(false);
    if (isAutobindAllowed && isPrometheusAutobindEnabled) {
        LOGGER.trace("Prometheus auto bind enabled, looking for prometheus installations");
        final Optional<List<PrometheusConfig>> prometheusConfigsOpt = prometheusScanner.findResources();
        return prometheusConfigsOpt.map(prometheusConfigs -> prometheusConfigs.stream().map(ClusterRequiredResourcesGenerator::toPrometheusInstallation).collect(Collectors.toUnmodifiableList())).map(installations -> new Prometheus(!installations.isEmpty(), installations));
    } else {
        return Optional.of(new Prometheus(false, null));
    }
}
Also used : StackGresClusterInitData(io.stackgres.common.crd.sgcluster.StackGresClusterInitData) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) StackGresClusterConfiguration(io.stackgres.common.crd.sgcluster.StackGresClusterConfiguration) StackGresBackup(io.stackgres.common.crd.sgbackup.StackGresBackup) StackGresCluster(io.stackgres.common.crd.sgcluster.StackGresCluster) LoggerFactory(org.slf4j.LoggerFactory) StackGresPostgresConfig(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig) RequiredResourceGenerator(io.stackgres.operator.conciliation.RequiredResourceGenerator) Inject(javax.inject.Inject) OperatorPropertyContext(io.stackgres.operator.configuration.OperatorPropertyContext) ResourceGenerationDiscoverer(io.stackgres.operator.conciliation.ResourceGenerationDiscoverer) ResourceGenerator(io.stackgres.operator.conciliation.ResourceGenerator) Map(java.util.Map) Prometheus(io.stackgres.operator.common.Prometheus) CustomResourceFinder(io.stackgres.common.resource.CustomResourceFinder) CustomResourceScanner(io.stackgres.common.resource.CustomResourceScanner) Decorator(io.stackgres.operator.conciliation.factory.Decorator) StackGresBackupConfig(io.stackgres.common.crd.sgbackupconfig.StackGresBackupConfig) Unchecked(org.jooq.lambda.Unchecked) Logger(org.slf4j.Logger) Resources(com.google.common.io.Resources) StackGresPoolingConfig(io.stackgres.common.crd.sgpooling.StackGresPoolingConfig) Collectors(java.util.stream.Collectors) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) PrometheusConfigSpec(io.stackgres.operator.customresource.prometheus.PrometheusConfigSpec) StandardCharsets(java.nio.charset.StandardCharsets) StackGresProfile(io.stackgres.common.crd.sgprofile.StackGresProfile) BackupPhase(io.stackgres.common.crd.sgbackup.BackupPhase) StackGresClusterSpec(io.stackgres.common.crd.sgcluster.StackGresClusterSpec) List(java.util.List) StackGresClusterScriptEntry(io.stackgres.common.crd.sgcluster.StackGresClusterScriptEntry) PrometheusInstallation(io.stackgres.operator.customresource.prometheus.PrometheusInstallation) DecoratorDiscoverer(io.stackgres.operator.conciliation.factory.DecoratorDiscoverer) ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) StackGresClusterRestore(io.stackgres.common.crd.sgcluster.StackGresClusterRestore) Optional(java.util.Optional) Secret(io.fabric8.kubernetes.api.model.Secret) ResourceFinder(io.stackgres.common.resource.ResourceFinder) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Preconditions(com.google.common.base.Preconditions) OperatorProperty(io.stackgres.common.OperatorProperty) PrometheusConfig(io.stackgres.operator.customresource.prometheus.PrometheusConfig) Prometheus(io.stackgres.operator.common.Prometheus) List(java.util.List)

Aggregations

Preconditions (com.google.common.base.Preconditions)1 Resources (com.google.common.io.Resources)1 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)1 LabelSelector (io.fabric8.kubernetes.api.model.LabelSelector)1 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)1 Secret (io.fabric8.kubernetes.api.model.Secret)1 OperatorProperty (io.stackgres.common.OperatorProperty)1 BackupPhase (io.stackgres.common.crd.sgbackup.BackupPhase)1 StackGresBackup (io.stackgres.common.crd.sgbackup.StackGresBackup)1 StackGresBackupConfig (io.stackgres.common.crd.sgbackupconfig.StackGresBackupConfig)1 StackGresCluster (io.stackgres.common.crd.sgcluster.StackGresCluster)1 StackGresClusterConfiguration (io.stackgres.common.crd.sgcluster.StackGresClusterConfiguration)1 StackGresClusterInitData (io.stackgres.common.crd.sgcluster.StackGresClusterInitData)1 StackGresClusterRestore (io.stackgres.common.crd.sgcluster.StackGresClusterRestore)1 StackGresClusterScriptEntry (io.stackgres.common.crd.sgcluster.StackGresClusterScriptEntry)1 StackGresClusterSpec (io.stackgres.common.crd.sgcluster.StackGresClusterSpec)1 StackGresPostgresConfig (io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig)1 StackGresPoolingConfig (io.stackgres.common.crd.sgpooling.StackGresPoolingConfig)1 StackGresProfile (io.stackgres.common.crd.sgprofile.StackGresProfile)1 CustomResourceFinder (io.stackgres.common.resource.CustomResourceFinder)1