kubernetes 为fluentbit pod添加容错并使其持久化

hfsqlsce  于 2023-06-05  发布在  Kubernetes
关注(0)|答案(1)|浏览(173)

我正在使用fluentbit作为pod部署,在那里我创建了许多fluentbit pod,这些pod连接到azure blob容器。由于存在多个pod,我尝试添加tolerance,就像我在daemonset部署中所做的那样,但它不起作用并失败了。此外,每次我删除和启动豆荚重新投资所有的一次。请就如何解决这些问题提供建议。

apiVersion: v1
kind: Pod
metadata:
  name: deployment 
spec:
  volumes:
    - name: config_map_name
      configMap:
        name: config_map_name
    - name: pvc_name
      persistentVolumeClaim:
        claimName: pvc_name       
  containers:
    - name: fluentbit-logger
      image: fluent/fluent-bit:2.1.3
      env:
        - name: FLUENTBIT_USER
          valueFrom:
            secretKeyRef:
              name: fluentbit-secret
              key: user
        - name: FLUENTBIT_PWD
          valueFrom:
            secretKeyRef:
              name: fluentbit-secret
              key: pwd              
      resources:
        requests:
          memory: "32Mi"
          cpu: "50m"
        limits:
          memory: "64Mi"
          cpu: "100m"
      securityContext:
        runAsUser: 0
        privileged: true
      volumeMounts:
        - name: config_map_name
          mountPath: "/fluent-bit/etc"
        - name: pvc_name
          mountPath: mount_path  
      tolerations: 
      - key: "dedicated"
        operator: "Equal"
        value: "sgelk"
        effect: "NoSchedule"

      - key: "dedicated"
        operator: "Equal"
        value: "kafka"
        effect: "NoSchedule"

得到如下错误

error: error validating "/tmp/fluentbit-deploy.yaml": error validating data: ValidationError(Pod.spec.containers[0]): unknown field "tolerations" in io.k8s.api.core.v1.Container; if you choose to ignore these errors, turn validation off with --validate=false
jutyujz0

jutyujz01#

tolerations属性需要在pod上设置,但您正在尝试在容器上设置它(这就是为什么您会看到错误“unknown field“tolerations”in io.k8s.api.core.v1.Container”)。你需要写:

apiVersion: v1
kind: Pod
metadata:
  name: deployment
spec:
  volumes:
    - name: config_map_name
      configMap:
        name: config_map_name
    - name: pvc_name
      persistentVolumeClaim:
        claimName: pvc_name
  containers:
    - name: fluentbit-logger
      image: fluent/fluent-bit:2.1.3
      env:
        - name: FLUENTBIT_USER
          valueFrom:
            secretKeyRef:
              name: fluentbit-secret
              key: user
        - name: FLUENTBIT_PWD
          valueFrom:
            secretKeyRef:
              name: fluentbit-secret
              key: pwd
      resources:
        requests:
          memory: "32Mi"
          cpu: "50m"
        limits:
          memory: "64Mi"
          cpu: "100m"
      securityContext:
        runAsUser: 0
        privileged: true
      volumeMounts:
        - name: config_map_name
          mountPath: "/fluent-bit/etc"
        - name: pvc_name
          mountPath: mount_path
  tolerations:
  - key: "dedicated"
    operator: "Equal"
    value: "sgelk"
    effect: "NoSchedule"

  - key: "dedicated"
    operator: "Equal"
    value: "kafka"
    effect: "NoSchedule"

相关问题