2

I have deployed Nifi on Kubernetes using cetic/helm-nifi helm chart. I have to insert log data to a MySQL database using a PutDatabaseRecord process. To do that, inside of PutDatabaseRecord process, I have to configure Database Connection URL, Database Driver Class Name & Database Driver Location(s).

enter image description here

As the Database Driver Location, I downloaded the connector jar (https://dev.mysql.com/downloads/connector/j/) inside the pod and configured the location of the MySQL connector jar file inside the PutDatabaseRecord process. In that way, if the pod is getting restart, I have to download connector manually inside the pod again. It is not a recommended way to do that. Appreciate if you can suggest a solution for this.

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37

1 Answers1

0

It would be really helpful to see your Kubernetes configuration, but overall you can use ConfigMaps for this purpose - as it is standard Kubernetes resource for storing configuration data. It is described in more details here. Below is the example of ConfigMap, where MySQL connector jar file is mounted to the pod:


  containers:
    - name: container
      volumeMounts:
      - name: config
        mountPath: /usr/local/mysql-connector-java.jar
  volumes:
    - name: config
      configMap:
        name: config-map           
        items: 
        - key: mysql-connector-java.jar
          path: mysql-connector-java.jar
        

But ConfigMap will work for you only if you are storing the connector jar file, which size is not exceeding 1 MiB.

Otherwise, there is one more option - mounting a persistent volume with a MySQL connector jar file - as described here and here. The jar file will be copied to the pod once persistent volume is mounted into it - and it can be re-mounted to the pod after its restart/re-creation.

anarxz
  • 817
  • 1
  • 14