use of io.neo9.ingress.access.customresources.external.istio.Sidecar in project ingress-access-operator by neo9.
the class IstioSidecarReconciler method reconcile.
public void reconcile() {
Sidecar oldSidecar = sidecarRepository.getSidecar(additionalWatchersConfig.updateIstioIngressSidecar().getIngressNamespace(), SIDECAR_NAME);
if (nonNull(oldSidecar) && !isManagedByOperator(oldSidecar)) {
throw new ResourceNotManagedByOperatorException(getResourceNamespaceAndName(oldSidecar));
}
List<Namespace> namespacesWatchedByIstio = namespaceRepository.listNamespacesWithLabel(ISTIO_WATCH_NAMESPACE_LABEL_KEY, ISTIO_WATCH_NAMESPACE_LABEL_VALUE);
List<String> namespaceForSidecar = Stream.concat(additionalWatchersConfig.updateIstioIngressSidecar().getAdditionalEgressRulesEntries().stream(), namespacesWatchedByIstio.stream().map(namespace -> namespace.getMetadata().getName())).map(s -> String.format("%s/*", s)).distinct().collect(Collectors.toList());
log.trace("computed namespace list : {}", namespaceForSidecar);
Sidecar sidecar = new Sidecar();
sidecar.getMetadata().setNamespace(additionalWatchersConfig.updateIstioIngressSidecar().getIngressNamespace());
sidecar.getMetadata().setName(SIDECAR_NAME);
sidecar.getMetadata().setLabels(Map.of(MANAGED_BY_OPERATOR_KEY, MANAGED_BY_OPERATOR_VALUE));
EgressSpec egressSpec = new EgressSpec(namespaceForSidecar);
SidecarSpec sidecarSpec = new SidecarSpec();
sidecarSpec.setEgress(List.of(egressSpec));
sidecar.setSpec(sidecarSpec);
sidecarRepository.createOrReplace(sidecar);
}
Aggregations