如何在清单中修改NiFi配置文件的值?

huangapple go评论89阅读模式
英文:

How to modify a value of a Nifi configuration file in manifest?

问题

我希望在配置文件中更改的值是nifi.content.repository.archive.enabled=true改为false。

我尝试在我的清单中添加以下内容:

  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: tests-nifi
  5. namespace: poc
  6. labels:
  7. name: tests-nifi
  8. app: tests-nifi
  9. spec:
  10. replicas: 1
  11. strategy:
  12. type: Recreate
  13. selector:
  14. matchLabels:
  15. app: tests-nifi
  16. template:
  17. metadata:
  18. labels:
  19. app: tests-nifi
  20. spec:
  21. restartPolicy: Always
  22. containers:
  23. - name: nifi
  24. image: apache/nifi
  25. imagePullPolicy: IfNotPresent
  26. ports:
  27. - containerPort: 8080
  28. name: nifi
  29. env:
  30. - name: "NIFI_SENSITIVE_PROPS_KEY"
  31. value: "nificluster"
  32. - name: ALLOW_ANONYMOUS_LOGIN
  33. value: "no"
  34. - name: SINGLE_USER_CREDENTIALS_USERNAME
  35. value: nifi-user
  36. - name: SINGLE_USER_CREDENTIALS_PASSWORD
  37. value: nifi-user-password
  38. - name: NIFI_WEB_HTTP_HOST
  39. value: "0.0.0.0"
  40. - name: NIFI_WEB_HTTP_PORT
  41. value: "8080"
  42. - name: NIFI_ANALYTICS_PREDICT_ENABLED
  43. value: "true"
  44. - name: NIFI_ELECTION_MAX_CANDIDATES
  45. value: "1"
  46. - name: NIFI_ELECTION_MAX_WAIT
  47. value: "20 sec"
  48. - name: NIFI_JVM_HEAP_INIT
  49. value: "2g"
  50. - name: NIFI_JVM_HEAP_MAX
  51. value: "4g"
  52. - name: NIFI_CONTENT_REPOSITORY_ARCHIVE_ENABLED
  53. value: "false"
  54. livenessProbe:
  55. exec:
  56. command:
  57. - pgrep
  58. - java
  59. initialDelaySeconds: 60
  60. periodSeconds: 30
  61. timeoutSeconds: 10
  62. failureThreshold: 3
  63. successThreshold: 1
  64. readinessProbe:
  65. tcpSocket:
  66. port: 8080
  67. initialDelaySeconds: 240
  68. periodSeconds: 30
  69. timeoutSeconds: 10
  70. failureThreshold: 3
  71. successThreshold: 1
  72. resources:
  73. requests:
  74. cpu: 2
  75. ephemeral-storage: 2Gi
  76. memory: 4Gi
  77. limits:
  78. cpu: 8
  79. ephemeral-storage: 2Gi
  80. memory: 16Gi

但当我在Pod中执行时,值nifi.content.repository.archive.enabled仍然为true。要更改的值位于名为“nifi.properties”的文件中。如何更改YAML文件中的值?

英文:

I have value that I would like to change in configuration file.
The value I would like to change is nifi.content.repository.archive.enabled=true to false.

I tried the following in my manifest, adding:

  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: tests-nifi
  5. namespace: poc
  6. labels:
  7. name : tests-nifi
  8. app : tests-nifi
  9. spec:
  10. replicas: 1
  11. strategy:
  12. type: Recreate
  13. selector:
  14. matchLabels:
  15. app: tests-nifi
  16. template:
  17. metadata:
  18. labels:
  19. app: tests-nifi
  20. spec:
  21. restartPolicy: Always
  22. containers:
  23. - name: nifi
  24. image: apache/nifi
  25. imagePullPolicy: IfNotPresent
  26. ports:
  27. - containerPort: 8080
  28. name: nifi
  29. env:
  30. - name: "NIFI_SENSITIVE_PROPS_KEY"
  31. value: "nificluster"
  32. - name: ALLOW_ANONYMOUS_LOGIN
  33. value: "no"
  34. - name: SINGLE_USER_CREDENTIALS_USERNAME
  35. value: nifi-user
  36. - name: SINGLE_USER_CREDENTIALS_PASSWORD
  37. value: nifi-user-password
  38. - name: NIFI_WEB_HTTP_HOST
  39. value: "0.0.0.0"
  40. - name: NIFI_WEB_HTTP_PORT
  41. value: "8080"
  42. - name: NIFI_ANALYTICS_PREDICT_ENABLED
  43. value: "true"
  44. - name: NIFI_ELECTION_MAX_CANDIDATES
  45. value: "1"
  46. - name: NIFI_ELECTION_MAX_WAIT
  47. value: "20 sec"
  48. - name: NIFI_JVM_HEAP_INIT
  49. value: "2g"
  50. - name: NIFI_JVM_HEAP_MAX
  51. value: "4g"
  52. - name: NIFI_CONTENT_REPOSITORY_ARCHIVE_ENABLED
  53. value: "false"
  54. livenessProbe:
  55. exec:
  56. command:
  57. - pgrep
  58. - java
  59. initialDelaySeconds: 60
  60. periodSeconds: 30
  61. timeoutSeconds: 10
  62. failureThreshold: 3
  63. successThreshold: 1
  64. readinessProbe:
  65. tcpSocket:
  66. port: 8080
  67. initialDelaySeconds: 240
  68. periodSeconds: 30
  69. timeoutSeconds: 10
  70. failureThreshold: 3
  71. successThreshold: 1
  72. resources:
  73. requests:
  74. cpu: 2
  75. ephemeral-storage: 2Gi
  76. memory: 4Gi
  77. limits:
  78. cpu: 8
  79. ephemeral-storage: 2Gi
  80. memory: 16Gi

I added:

  1. - name: NIFI_CONTENT_REPOSITORY_ARCHIVE_ENABLED
  2. value: "false"

But when I do exec in the pod the value nifi.content.repository.archive.enabled is still true. The value to change is in the file named "nifi.properties".

How can I do it to change the value in my yaml ?

答案1

得分: 1

我不太熟悉Apache Nifi,但一些研究建议:

  • StatefulSet比部署(Deployment)更合适。
  • 配置文件可能需要加载到Pod中以设置该值,而不是尝试将其设置为环境变量 - 这可以通过ConfigMap来完成。
  • 你可以考虑使用Helm图表(Helm chart)来帮助部署,以便更容易进行配置更改。

一些资源:

如果不考虑Helm、StatefulSets等,你可以采用最简单的方法将更改应用到你的部署 - 将完整的Apache Nifi配置复制到ConfigMap中,然后将其挂载到部署中,尽管这可能只适用于测试,不应该用于生产环境。

这只是一个示例,不是完整的规范:

  1. ---
  2. apiVersion: v1
  3. kind: ConfigMap
  4. metadata:
  5. name: apache-nifi-config
  6. data:
  7. nifi.properties: |
  8. ...
  9. nifi.flow.configuration.archive.enabled=false
  10. ---
  11. apiVersion: apps/v1
  12. kind: Deployment
  13. metadata:
  14. name: tests-nifi
  15. namespace: poc
  16. labels:
  17. name : tests-nifi
  18. app : tests-nifi
  19. spec:
  20. replicas: 1
  21. strategy:
  22. type: Recreate
  23. selector:
  24. matchLabels:
  25. app: tests-nifi
  26. template:
  27. metadata:
  28. labels:
  29. app: tests-nifi
  30. spec:
  31. ...
  32. containers:
  33. - name: nifi
  34. volumeMounts:
  35. - name: nifi-properties
  36. mountPath: "/nifi-properities-path"
  37. readOnly: true
  38. ...
  39. volumes:
  40. - name: "nifi-properties"
  41. configMap:
  42. name: apache-nifi-config
  43. items:
  44. - key: "nifi.properties"
  45. path: "nifi.properties"
英文:

I'm not directly familiar with Apache Nifi, but a little bit of research suggests:

  • A StatefulSet is a better approach than a deployment
  • The configuration file likely needs to be loaded into the pod to set that value, rather then trying to set it as an environment variable - this would be done with a ConfigMap
  • You could look at using a helm chart to help deploy it, along with being able to make configuration changes a bit easier.

Some resources:

The shortest path for you to apply your change (if not looking at helm, statefulsets, etc), is to copy your full apache nifi config(s) into a ConfigMap and mount that into your deployment - though this is likely only good for your test and shouldn't be used for production.

Just an example, not a complete spec:

  1. ---
  2. apiVersion: v1
  3. kind: ConfigMap
  4. metadata:
  5. name: apache-nifi-config
  6. data:
  7. nifi.properties: |
  8. ...
  9. nifi.flow.configuration.archive.enabled=false
  10. ---
  11. apiVersion: apps/v1
  12. kind: Deployment
  13. metadata:
  14. name: tests-nifi
  15. namespace: poc
  16. labels:
  17. name : tests-nifi
  18. app : tests-nifi
  19. spec:
  20. replicas: 1
  21. strategy:
  22. type: Recreate
  23. selector:
  24. matchLabels:
  25. app: tests-nifi
  26. template:
  27. metadata:
  28. labels:
  29. app: tests-nifi
  30. spec:
  31. ...
  32. containers:
  33. - name: nifi
  34. volumeMounts:
  35. - name: nifi-properties
  36. mountPath: "/nifi-properities-path"
  37. readOnly: true
  38. ...
  39. volumes:
  40. - name: "nifi-properties"
  41. configMap:
  42. name: apache-nifi-config
  43. items:
  44. - key: "nifi.properties"
  45. path: "nifi.properties"

huangapple
  • 本文由 发表于 2023年2月26日 22:09:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/75572546.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定