use of org.bf2.operator.events.ResourceEventSource in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class InformerManager method onStart.
@PostConstruct
protected void onStart() {
deploymentInformer = resourceInformerFactory.create(Deployment.class, filter(kubernetesClient.apps().deployments()), eventSource);
serviceInformer = resourceInformerFactory.create(Service.class, filterManagedByFleetshardOrStrimzi(kubernetesClient.services()), eventSource);
configMapInformer = resourceInformerFactory.create(ConfigMap.class, filter(kubernetesClient.configMaps()), eventSource);
secretInformer = resourceInformerFactory.create(Secret.class, filter(kubernetesClient.secrets()), eventSource);
// pvcs have an owner reference set to the kafka, not managedkakfa, so we need some lookup logic in the handleEvent
pvcInformer = resourceInformerFactory.create(PersistentVolumeClaim.class, kubernetesClient.persistentVolumeClaims().inAnyNamespace().withLabel("app.kubernetes.io/name", "kafka"), new ResourceEventSource() {
@Override
protected void handleEvent(HasMetadata resource, Action action) {
if (kafkaInformer != null) {
// TODO: could index by uid, or use namespace
String name = OperandUtils.getOrDefault(resource.getMetadata().getLabels(), "strimzi.io/cluster", null);
if (name != null) {
Kafka kafka = kafkaInformer.getByKey(Cache.namespaceKeyFunc(resource.getMetadata().getNamespace(), name));
if (kafka != null) {
handleEvent(kafka, Action.MODIFIED);
}
}
}
}
});
if (isOpenShift()) {
routeInformer = resourceInformerFactory.create(Route.class, filterManagedByFleetshardOrStrimzi(openShiftSupport.adapt(kubernetesClient).routes()), eventSource);
}
}
Aggregations