Communication between docker instances of Apache Nifi (SiteToSiteProvenance)


Like in case of SiteToSiteProvenance where one instance of Nifi needs to communicate with the other instance of Nifi. This has no problem with non docker instances. Where we just set the nifi.remote.input.host=#host# property in nifi.properties.

But when we start the docker instances, it dynamically sets the docker host in nifi.properties for property
nifi.remote.input.host and nifi.web.http.host
And this does not allow to start SiteToSiteProvenance from controller settings.

It throws,

SiteToSiteProvenanceReportingTask[id=..] org.apache.nifi.remote.client.PeerSelector@.. Unable to refresh Remote Group's peers due to Remote instance of NiFi is not configured to allow RAW Socket site-to-site communications

To resolve this follow below steps

STEP 1
To enable docker instance communication, we need to set some environment variables in the docker-compose file or while starting the docker with "docker run..." command.

NIFI_WEB_HTTP_HOST and NIFI_REMOTE_INPUT_HOST

This will have IP/hostname of the machine on which this NIFI instance is running

Below is the example of docker-compose of Apache nifi instance

version: "2"
services:
  nifi:
    image: nifi
  ports:
      - "8884:8884"
    environment:
      - NIFI_WEB_HTTP_PORT=8884
      - NIFI_VARIABLE_REGISTRY_PROPERTIES=./conf/custom.properties
      - NIFI_WEB_HTTP_HOST=192.168.0.1
      - NIFI_REMOTE_INPUT_HOST=192.168.0.1
    volumes:
      - ./conf:/opt/nifi/nifi-current/conf
      - ./content_repository:/opt/nifi/nifi-current/content_repository
      - ./database_repository:/opt/nifi/nifi-current/database_repository
      - ./flowfile_repository:/opt/nifi/nifi-current/flowfile_repository
      - ./provenance_repository:/opt/nifi/nifi-current/provenance_repository
      - ./state:/opt/nifi/nifi-current/state

For Kubernetes,
Set
NIFI_WEB_HTTP_HOST=0.0.0.0
NIFI_REMOTE_INPUT_HOST=0.0.0.0

And access with kubernetes service name to access the nifi instance

STEP 2
Set this property to appropriate network interface. Like in my case I have set it to
nifi.web.http.network.interface.default=eth0
nifi.web.https.network.interface.default=eth0

STEP 3
Change Communication protocol in SiteToSiteProvenance configuration in controller setting from "RAW" to "HTTP"



Comments