Transfer file from kubernetes cluster to other ec2 machine

10/29/2018

I have a pod in a Kubernetes(k8s) which has a Java application running on it in a docker container. This application produces logs. I want to move these log files to another amazon EC2 machine. Both the machines are linux based. How can this be done. Is it possible to do so using simple scp command?

-- mohd shoaib
docker
kubernetes

3 Answers

10/29/2018

To copy a file from a pod to a machine via scp you can use the following command:

kubectl cp <namespace>/<pod>:/path/inside/container /path/on/your/host
-- Keith Burdis
Source: StackOverflow

10/29/2018

You can copy file(s) from a Kubernetes Container by using the kubectl cp command.

Example:

kubectl cp <mypodname>:/var/log/syslog .

-- yomateo
Source: StackOverflow

10/29/2018

For moving logs from pods to your log store , you can use the following options to do it all the time for you , instead of one time copy:

  • filebeat
  • fluentd
  • fluentbit

https://github.com/fluent/fluent-bit-kubernetes-logging

https://docs.fluentd.org/v0.12/articles/kubernetes-fluentd

-- Ijaz Ahmad Khan
Source: StackOverflow