how to send kubectl logs output over mail in azure devops

11/12/2019

I have an azuredevops build job to get the log of a deployment pod.

command: kubectl logs deployment/myapp

I am getting the output in the summary page of azure devops pipeline, but the same I want to send a team with a log as an attachment. I am not getting any option in azure devops for that

-- Vowner
azure-devops
kubernetes

1 Answer

11/12/2019

Basically, your k8s log (pods) will gone after the pods has been terminated (although you can somehow keep it for a little while). For debug purpose or any other purpose you want, you need to Centralized logging your k8s log (use some tools: filebeat, fluentd, fluent-bit to forward your k8s log to elasticsearch).

EX: Some software (tools) for Centralized logging Elasticsearch, Graylog, ...

https://www.elastic.co/fr/what-is/elk-stack

And then you can save, export, analyze your log ... You can do anythings you want with your stored k8s log.

Hope this may help you, guy!

Edit: I use GCP as cloud solution and in GCP, by default, they will use fluentd to forward your k8s log to store in Logging. And the Logging has feature Export, I think you can search somethings similar to Logging in your cloud solution: Azure

-- Thọ Quách
Source: StackOverflow