how to copy file, directory from PODs to local host machine.

how to copy file, directory from K8s POD to local machine ?

     Generally we need some data from K8s PODs to our local machine for debugging and for future references. In this blog we will see that how we can copy the data from K8s POD to the local host directory or we can say to our local host machine and vise versa.

Copy data from PODs to the Local machine. 

1- If we are in the POD.

       if you are in the K8s POD already, then you can use SCP commands and their options to send the data file/directory to the local machine. 

From below commands we can login into the PODs.

kubectl exec -it <POD-Name > /bin/bash

After that Go to that path where the file present. use below command to scp the file to the local machine.

scp -r <filename /directory name > root@<local-machine IP >:<local machine path>

for Ex:

scp -r dummy.pcap root@xx.xx.xx.xx:/home/localdirectory/

2- using kubectl cp command:

# Copy /tmp/foo from a remote pod to /tmp/bar locally

kubectl cp <some-namespace>/<some-pod>:/tmp/foo /tmp/bar

we can also use in below format to copy the folder from POD to local host.

kubectl cp server-cudu-f66785456-agbcp:apps/config  /home/name/files/config

Copy local directory to remote POD directory:

# Copy /tmp/foo local file to /tmp/bar in a remote pod in a specific container

kubectl cp /tmp/foo <some-pod>:/tmp/bar -c <specific-container>

# Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace <some-namespace>

kubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/bar

we can also use in below format to copy a folder from the localhost directory to a POD.

kubectl cp /home/name/files/config server-cudu-f56776c55646-abcde:apps/config

How to Check linux OS Version ?

How to Check CentOS Version ?

       There are several reasons, that why we need to check the centos version. For example if we need to downloads a SW package from the internet and install into the system. then we need to know that which version and OS bit is required to download. some times if we debugging some issue, generally we need check the ON version / SW version. 

so here we will see the multiple ways to check the CentOS version.

1- using rpm commands check Centos version:

rpm --query centos-release

2- using "hostnamectl" command:

hostnamectl command is supported by CentOS 7 and above versions. 

This command also display the Machine ID, Boot ID, hostname (server name) and kernel version also.


3- using "cat /etc/os-release"

cat /etc/os-release

For full OS version use command as below.

cat /etc/centos-release

4- How to check the system info.

      By using "lscpu" this command, we can check the number of Core, number of CPU, Number of NUMA node and NUMA setting, modal chipset, CPU Architecture and flags which are enabled in the systems.