当前位置:网站首页>How can PostgreSQL in k8s export query results and import them to the database on the local windows machine

How can PostgreSQL in k8s export query results and import them to the database on the local windows machine

2022-06-09 13:14:00 MonkeyKing_ sunyuhua

Project under development , Need to put k8s Download the data in to the local database , Do some testing .

Get into postgresql, The query

kubectl get po -n infra
kubectl exec -it   postgres-0 -n infra -- bash
\c fs_resource_usage

 Insert picture description here
 Insert picture description here

such as : You need to put the front of the above data 10 Strip export

Use postgresql The order of , Save the query results to pod Below directory

 COPY(select * from event where resource_type='COMPUTE'  ORDER BY created_at desc limit 10) to '/tmp/tmp.csv' with csv header;

Execute the above command , Will be in pod The Great Wall tmp.csv file
 Insert picture description here

Use kubectl exec The order will pod Copy the file on to windows On the machine .

kubectl exec -n infra postgres-0 -- tar cf - tmp/ | tar xf - -C C:\\Users\\sunyuhua\\tmp

 Insert picture description here

Note appended : There are many commands for copying , Can pass kubectl cp --help see
 Insert picture description here

原网站

版权声明
本文为[MonkeyKing_ sunyuhua]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206091220175001.html