cetic / helm-nifi

Helm Chart for Apache Nifi
Apache License 2.0
215 stars 228 forks source link

[cetic/nifi] nifi-registry - how to customize providers.xml for nifi-registry backend #184

Closed chwongeric closed 3 years ago

chwongeric commented 3 years ago

Hi cetic/nifi support team,

I am on https://github.com/cetic/helm-nifi/tree/0.7.8 trying to configure nifi-registry backend to integrate with git or s3 as backend. To achieve this, it require modify providers.xml inside nifi-registry pod from following default when deploy using this chart version.

nifi@nifi-registry-0:/opt/nifi-registry/nifi-registry-current$ cat ./conf/providers.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
...
  </flowPersistenceProvider>
  <!--
    <flowPersistenceProvider>
        <class>org.apache.nifi.registry.provider.flow.git.GitFlowPersistenceProvider</class>
        <property name="Flow Storage Directory">./flow_storage</property>
        <property name="Remote To Push"></property>
        <property name="Remote Access User"></property>
        <property name="Remote Access Password"></property>
        <property name="Remote Clone Repository"></property>
    </flowPersistenceProvider>
    -->
...

Could you please provide anyway I can customize this file for nifi-registry when deploy using this chart? This file is not in the default files of helm fetch cetic/nifi, even I try following to extract and add this file, at deploy it does not overwrite any default offered by this chart. Please help! thanks a lot!

/usr/bin/helm fetch cetic/nifi --untar --version 0.7.8
cp ~/tmp/nifi-registry/providers.xml ./bin/tmp/cetic-nifi/nifi/configs/
/usr/bin/helm upgrade nifi ./bin/tmp/cetic-nifi/nifi \
  --install \
  --namespace data-pipeline \
  --values=./helm-charts/nifi/values-dev.yaml \
  --values=./helm-charts/nifi/secrets/secrets-dev.yaml \
  --set properties.webProxyHost=play.daikinlab.com \
  --set persistence.storageClass="gp2-encrypted" \
  --set image.tag=1.12.1 \
  --version 0.7.8 \
;

Describe the bug No way to overwrite nifi-registry pod's providers.xml or customize it for nifi-registry backend

Version of Helm and Kubernetes: % helm version version.BuildInfo{Version:"v3.5.3", GitCommit:"041ce5a2c17a58be0fcd5f5e16fb3e7e95fea622", GitTreeState:"dirty", GoVersion:"go1.16"} % kubectl version Client Version: version.Info{Major:"1", Minor:"20+", GitVersion:"v1.20.4-dirty", GitCommit:"e87da0bd6e03ec3fea7933c4b5263d151aafd07c", GitTreeState:"dirty", BuildDate:"2021-03-15T09:58:13Z", GoVersion:"go1.16.2", Compiler:"gc", Platform:"darwin/amd64"} Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.9", GitCommit:"94f372e501c973a7fa9eb40ec9ebd2fe7ca69848", GitTreeState:"clean", BuildDate:"2020-09-16T13:47:43Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}

What happened: Looking for a way to overwrite nifi-registry pod's providers.xml or customize it for nifi-registry backend

Thank you

chwongeric commented 3 years ago

Update: worked around with some progress but encountered next hurdle. I had attempted to use helm fetch cetic/nifi --untar --version 0.7.8 and locally modify charts/nifi-registry/values.yaml before helm upgrade nifi to get my git config kicked in. However, 1st init container of nifi-registry git-clone always terminated caused pod in crashloop without clear error info nor logs I can trace. Here is the snippet of kubernetes describe pod output and section in values.yaml modified for git integration.

Could experts please help why git-clone container terminated and anything in values.yaml it does not like and need modification? Thanks a lot!

Init Containers: git-clone: Container ID: docker://ea01c997d22c8a1fdc1ea9b235fe3598e61ad1e3a001e150a8a46a56933e420a Image: alpine/git:v2.26.2 Image ID: docker-pullable://alpine/git@sha256:23618034b0be9205d9cc0846eb711b12ba4c9b468efdd8a59aac1d7b1a23363f Port: Host Port: Command: sh -cex git clone $(NIFI_REGISTRY_GIT_URL) "/tmp/flow_storage" || git -C "/tmp/flow_storage" pull cp --dereference /ssh/id_rsa /ssh-dest/

  chown -R 1000:1000 /tmp/flow_storage /ssh-dest

State:          Terminated
  Reason:       Error
  Exit Code:    128
  Started:      Thu, 11 Nov 2021 18:42:28 -0800
  Finished:     Thu, 11 Nov 2021 18:42:28 -0800
Last State:     Terminated
  Reason:       Error
  Exit Code:    128
  Started:      Thu, 11 Nov 2021 18:42:12 -0800
  Finished:     Thu, 11 Nov 2021 18:42:12 -0800
Ready:          False
Restart Count:  2
Environment:
  NIFI_REGISTRY_GIT_URL:       https://user:passwd@bitbucket.org/developers/nifi.git
  NIFI_REGISTRY_GIT_USER:      user
  NIFI_REGISTRY_GIT_PASSWORD:  passwd
Mounts:
  /ssh from git-key (ro)
  /ssh-dest from git-key-fixed (rw)
  /tmp from flow-storage (rw)
  /var/run/secrets/kubernetes.io/serviceaccount from nifi-registry-token-gffcc (ro)

take-data-dir-ownership: Container ID:
Image: alpine:3.6 Image ID:
Port: Host Port: Command: chown -R 1000:1000 /opt/nifi-registry/nifi-registry-current/database /opt/nifi-registry/nifi-registry-current/flow_storage State: Waiting Reason: PodInitializing Ready: False Restart Count: 0 Environment: Mounts: /opt/nifi-registry/nifi-registry-current/database from database (rw) /opt/nifi-registry/nifi-registry-current/flow_storage from flow-storage (rw,path="flow_storage") /var/run/secrets/kubernetes.io/serviceaccount from nifi-registry-token-gffcc (ro)

flowProvider:
  git:
    enabled: true
    url: 'https://user:passwd@bitbucket.org/developers/nifi.git'
    remote: 'origin/master'
    user: 'user'
    password: 'passwd'
    secretName:
    # Global Git configuration See https://git-scm.com/docs/git-config for more details.
    config:
      enabled: false
      secretName: ""
      data: ""
chwongeric commented 3 years ago

I found the problem of above failure caused nifi-registry failed to start is due to git-clone container image's directory /tmp/flow_storage is not empty. This likely due to container image build issue.

Thus I workaround this container issue by manually delete it in statefulset.yaml with following 1 line change to make nifi-registry finally working with git repo:

rm -rf "/tmp/flow_storage" && mkdir -p "/tmp/flow_storage" && git clone $(NIFI_REGISTRY_GIT_URL) "/tmp/flow_storage" || git -C "/tmp/flow_storage" pull