kubernetesfluent-bit

Adding tolerations to fluentbit pod and making it persistent


I am using fluentbit as a pod deployment where I am creating many fluentbit pods which are attached to azure blob containers. Since multiple pods exist I tried adding tolerations as I did on daemonset deployment but it did not work and failed. Also every time I delete and start the pods reinvests all the the again. Please advise on fixing these issues.

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"               

Getting the error as below

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

Solution

  • The tolerations attribute needs to be set on the pod, but you are attempting to set it on a container (that's why you see the error "unknown field "tolerations" in io.k8s.api.core.v1.Container"). You would need to write:

    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"