39 lines
1.1 KiB
Java
39 lines
1.1 KiB
Java
package dev.dinauer.monitoring;
|
|
|
|
import java.util.List;
|
|
|
|
import jakarta.enterprise.context.ApplicationScoped;
|
|
import jakarta.inject.Inject;
|
|
|
|
import org.jboss.resteasy.reactive.common.NotImplementedYet;
|
|
|
|
import io.fabric8.kubernetes.api.model.Pod;
|
|
|
|
import dev.dinauer.monitoring.entity.MonitoringConfig;
|
|
import dev.dinauer.monitoring.entity.TargetConfig;
|
|
import dev.dinauer.service.PodService;
|
|
|
|
@ApplicationScoped
|
|
public class MonitoringService
|
|
{
|
|
@Inject
|
|
PodService podService;
|
|
|
|
public List<Pod> findRunningPodsByMonitoringConfig(MonitoringConfig config)
|
|
{
|
|
TargetConfig targetConfig = config.getTargetConfig();
|
|
switch (targetConfig.getType())
|
|
{
|
|
case LABEL ->
|
|
{
|
|
return podService.findByNamespaceAndLabels(targetConfig.getNamespace(), targetConfig.getLabels()).stream().filter(pod -> pod.getStatus().getPhase().equals("Running")).toList();
|
|
}
|
|
case DEPLOYMENT, STATEFUL_SET ->
|
|
{
|
|
throw new NotImplementedYet();
|
|
}
|
|
}
|
|
throw new RuntimeException("Invalid monitoring config type");
|
|
}
|
|
}
|