kubernetes 如何修改清单中Nifi配置文件的值?

o8x7eapl  于 2023-03-01  发布在  Kubernetes
关注(0)|答案(1)|浏览(133)

我想在配置文件中更改值。我想更改的值为nifi.content.repository. archive.enabled = true to 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

我补充道:

- name: NIFI_CONTENT_REPOSITORY_ARCHIVE_ENABLED
  value: "false"

但是当我在pod中执行exec时,值nifi. content. repository. archive. enabled仍然为真。要更改的值在名为"www.example.com"的文件中。nifi.properties".
我怎样才能改变我的yaml中的值呢?

5vf7fwbs

5vf7fwbs1#

我并不直接熟悉Apache Nifi,但一些研究表明:

  • StatefulSet是比部署更好的方法
  • 可能需要将配置文件加载到pod中以设置该值,而不是尝试将其设置为环境变量-这可以使用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"

相关问题