Skip to content

Latest commit

 

History

History
66 lines (57 loc) · 1.83 KB

File metadata and controls

66 lines (57 loc) · 1.83 KB

main purpuses

rotate log for ingress nginx send ingress nginx logs to kibana via redis

Please do test on test environment first

install

build filebeat image for rotate nginx log, then push to your private registry or dockerhub

cd filebeat-with-logrotate
docker build -t filebeat-log-rotate .

create config map sh kubectl apply -f configmap.yaml

update ingress-nginx-controller deployment plain update your filebeat-with-logrotate image on deployment-ingress-nginx-controller.yaml

  • add to controller container
        volumeMounts:
        - mountPath: /usr/local/certificates/
          name: webhook-cert
          readOnly: true
        - mountPath: var/log/nginx/
  • add new filebeat sidecar container
      - image: https://registry-gitlab/path/to/filebeat-with-logrotate
        imagePullPolicy: IfNotPresent
        name: filebeat-sidecar
        resources: {}
        securityContext:
          runAsUser: 0
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: var/log/nginx/
          name: nginx-logs
        - mountPath: /usr/share/filebeat/filebeat.yml
          name: filebeat-config
          subPath: filebeat.yml
  • controller deployment config
      volumes:
      - name: webhook-cert
        secret:
          defaultMode: 420
          secretName: ingress-nginx-admission
      - emptyDir: {}
        name: nginx-logs
      - configMap:
          defaultMode: 420
          items:                                                                                                                       
          - key: filebeat.yml
            path: filebeat.yml
          name: ingress-configmap
        name: filebeat-config

Then apply your modified deployment ingress-nginx-controller