Search in sources :

Example 1 with Sidecar

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);
}
Also used : ResourceNotManagedByOperatorException(io.neo9.ingress.access.exceptions.ResourceNotManagedByOperatorException) EgressSpec(io.neo9.ingress.access.customresources.external.istio.spec.EgressSpec) SidecarSpec(io.neo9.ingress.access.customresources.external.istio.spec.SidecarSpec) Namespace(io.fabric8.kubernetes.api.model.Namespace) Sidecar(io.neo9.ingress.access.customresources.external.istio.Sidecar)

Aggregations

Namespace (io.fabric8.kubernetes.api.model.Namespace)1 Sidecar (io.neo9.ingress.access.customresources.external.istio.Sidecar)1 EgressSpec (io.neo9.ingress.access.customresources.external.istio.spec.EgressSpec)1 SidecarSpec (io.neo9.ingress.access.customresources.external.istio.spec.SidecarSpec)1 ResourceNotManagedByOperatorException (io.neo9.ingress.access.exceptions.ResourceNotManagedByOperatorException)1