Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick #16373 to 7.x: Make k8s meta processor initialisation asynchronous #16419

Merged
merged 1 commit into from
Feb 20, 2020

Conversation

ChrsMark
Copy link
Member

Cherry-pick of PR #16373 to 7.x branch. Original message:

What does this PR do?

This PR changes add_kubernetes_metadata processor so as to get initialised asynchronously and being able to handle node not ready situations.

Why is it important?

This will be solve the problem of having to restart Beat in case the processor was not initialised if the node was not ready yet when Beat started.

How to test this PR locally

With the use of Minikube:

  1. minikube start
  2. Have a minikube ssh in one tab so as to handle k8s health up and down
  3. Build Filebeat on the host where Minikube runs
  4. Use the kubeconfig of Minikube: export KUBECONFIG=~/.kube/config
  5. Make sure that add_kubernetes_metadata processor is enabled:
processors:
  - add_kubernetes_metadata: ~
  1. Start filebeat and expect to see 2020-02-18T12:25:12.825+0200 INFO add_kubernetes_metadata/kubernetes.go:77 add_kubernetes_metadata: kubernetes env detected, with version: v1.17.0 in your logs, meaning that processor was able to reach k8s API.
  2. Stop filebeat
  3. In the session you have inside Minikube vm run sudo systemctl stop docker to bring docker down and make k8s API unreachable
  4. Start filebeat again and you should see (after ~30secs) sth like 2020-02-18T12:27:16.958+0200 INFO add_kubernetes_metadata/kubernetes.go:89 add_kubernetes_metadata: could not detect kubernetes env: Get https://192.168.64.6:8443/version?timeout=32s: dial tcp 192.168.64.6:8443: connect: connection refused
  5. Stop filebeat and start it again.
  6. Wait 3-4 seconds and go to Minkube vm and start docker daemon again: sudo systemctl start docker.
  7. In Filebeat's logs you should expect to see that the processor reached k8s API like in step 6.

Related issues

@ChrsMark ChrsMark merged commit d62349f into elastic:7.x Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants