英文:
How to modify a value of a Nifi configuration file in manifest?
问题
我希望在配置文件中更改的值是nifi.content.repository.archive.enabled=true改为false。
我尝试在我的清单中添加以下内容:
apiVersion: apps/v1
kind: Deployment
metadata:
name: tests-nifi
namespace: poc
labels:
name: tests-nifi
app: tests-nifi
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: tests-nifi
template:
metadata:
labels:
app: tests-nifi
spec:
restartPolicy: Always
containers:
- name: nifi
image: apache/nifi
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
name: nifi
env:
- name: "NIFI_SENSITIVE_PROPS_KEY"
value: "nificluster"
- name: ALLOW_ANONYMOUS_LOGIN
value: "no"
- name: SINGLE_USER_CREDENTIALS_USERNAME
value: nifi-user
- name: SINGLE_USER_CREDENTIALS_PASSWORD
value: nifi-user-password
- name: NIFI_WEB_HTTP_HOST
value: "0.0.0.0"
- name: NIFI_WEB_HTTP_PORT
value: "8080"
- name: NIFI_ANALYTICS_PREDICT_ENABLED
value: "true"
- name: NIFI_ELECTION_MAX_CANDIDATES
value: "1"
- name: NIFI_ELECTION_MAX_WAIT
value: "20 sec"
- name: NIFI_JVM_HEAP_INIT
value: "2g"
- name: NIFI_JVM_HEAP_MAX
value: "4g"
- name: NIFI_CONTENT_REPOSITORY_ARCHIVE_ENABLED
value: "false"
livenessProbe:
exec:
command:
- pgrep
- java
initialDelaySeconds: 60
periodSeconds: 30
timeoutSeconds: 10
failureThreshold: 3
successThreshold: 1
readinessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 240
periodSeconds: 30
timeoutSeconds: 10
failureThreshold: 3
successThreshold: 1
resources:
requests:
cpu: 2
ephemeral-storage: 2Gi
memory: 4Gi
limits:
cpu: 8
ephemeral-storage: 2Gi
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:
apiVersion: apps/v1
kind: Deployment
metadata:
name: tests-nifi
namespace: poc
labels:
name : tests-nifi
app : tests-nifi
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: tests-nifi
template:
metadata:
labels:
app: tests-nifi
spec:
restartPolicy: Always
containers:
- name: nifi
image: apache/nifi
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
name: nifi
env:
- name: "NIFI_SENSITIVE_PROPS_KEY"
value: "nificluster"
- name: ALLOW_ANONYMOUS_LOGIN
value: "no"
- name: SINGLE_USER_CREDENTIALS_USERNAME
value: nifi-user
- name: SINGLE_USER_CREDENTIALS_PASSWORD
value: nifi-user-password
- name: NIFI_WEB_HTTP_HOST
value: "0.0.0.0"
- name: NIFI_WEB_HTTP_PORT
value: "8080"
- name: NIFI_ANALYTICS_PREDICT_ENABLED
value: "true"
- name: NIFI_ELECTION_MAX_CANDIDATES
value: "1"
- name: NIFI_ELECTION_MAX_WAIT
value: "20 sec"
- name: NIFI_JVM_HEAP_INIT
value: "2g"
- name: NIFI_JVM_HEAP_MAX
value: "4g"
- name: NIFI_CONTENT_REPOSITORY_ARCHIVE_ENABLED
value: "false"
livenessProbe:
exec:
command:
- pgrep
- java
initialDelaySeconds: 60
periodSeconds: 30
timeoutSeconds: 10
failureThreshold: 3
successThreshold: 1
readinessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 240
periodSeconds: 30
timeoutSeconds: 10
failureThreshold: 3
successThreshold: 1
resources:
requests:
cpu: 2
ephemeral-storage: 2Gi
memory: 4Gi
limits:
cpu: 8
ephemeral-storage: 2Gi
memory: 16Gi
I added:
- name: NIFI_CONTENT_REPOSITORY_ARCHIVE_ENABLED
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)来帮助部署,以便更容易进行配置更改。
一些资源:
- https://github.com/cetic/helm-nifi
- https://learn.microsoft.com/en-us/azure/architecture/guide/data/helm-deployments-apache-nifi
- https://kubernetes.io/docs/concepts/configuration/configmap/
如果不考虑Helm、StatefulSets等,你可以采用最简单的方法将更改应用到你的部署 - 将完整的Apache Nifi配置复制到ConfigMap中,然后将其挂载到部署中,尽管这可能只适用于测试,不应该用于生产环境。
这只是一个示例,不是完整的规范:
---
apiVersion: v1
kind: ConfigMap
metadata:
name: apache-nifi-config
data:
nifi.properties: |
...
nifi.flow.configuration.archive.enabled=false
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tests-nifi
namespace: poc
labels:
name : tests-nifi
app : tests-nifi
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: tests-nifi
template:
metadata:
labels:
app: tests-nifi
spec:
...
containers:
- name: nifi
volumeMounts:
- name: nifi-properties
mountPath: "/nifi-properities-path"
readOnly: true
...
volumes:
- name: "nifi-properties"
configMap:
name: apache-nifi-config
items:
- key: "nifi.properties"
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:
- https://github.com/cetic/helm-nifi
- https://learn.microsoft.com/en-us/azure/architecture/guide/data/helm-deployments-apache-nifi
- https://kubernetes.io/docs/concepts/configuration/configmap/
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:
---
apiVersion: v1
kind: ConfigMap
metadata:
name: apache-nifi-config
data:
nifi.properties: |
...
nifi.flow.configuration.archive.enabled=false
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tests-nifi
namespace: poc
labels:
name : tests-nifi
app : tests-nifi
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: tests-nifi
template:
metadata:
labels:
app: tests-nifi
spec:
...
containers:
- name: nifi
volumeMounts:
- name: nifi-properties
mountPath: "/nifi-properities-path"
readOnly: true
...
volumes:
- name: "nifi-properties"
configMap:
name: apache-nifi-config
items:
- key: "nifi.properties"
path: "nifi.properties"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论