Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aisuhua/bd70c84ea58537af2c7a7e467ec7ac6d to your computer and use it in GitHub Desktop.
Save aisuhua/bd70c84ea58537af2c7a7e467ec7ac6d to your computer and use it in GitHub Desktop.
How to Copy sosrerport from Node using oc debug? Not ssh!

How to Copy Files from NODE using oc cp?

At Openshift 4.x that recomends using oc debug instead of ssh bellow I'll explain how to do it.

At Terminal 01

Start Node DEBUGING

$ oc debug node/k8sdemo-hxvrp-master-2
# remember to change chroot /host
chroot /host
# start toolbox
toobox
# collect system report
sosreport
# ...
# it will save at folder like: /host/var/tmp/sosreport-k8sdemo-hxvrp-master-2*

At Terminal 02

View Pods Running at current project

$ oc get pods
NAME                               READY   STATUS    RESTARTS   AGE
k8sdemo-hxvrp-master-2-debug   1/1     Running   0          11h

If you want to take a look into Debug Pods do:

$ oc rsh k8sdemo-hxvrp-master-2-debug
sh-4.4# ls -lah /var/tmp/sos*
ls: cannot access '/var/tmp/sos*': No such file or directory
 
# remember to change chroot /host
sh-4.4# chroot /host
sh-4.4# ls -lah /var/tmp/sos*
-rwxrwxrwx. 1 root root 469M Jun 23 15:32 /var/tmp/sosreport-k8sdemo-hxvrp-master-2-03250992-2022-06-23-yzrrjsq.tar.xz
-rwxrwxrwx. 1 root root   65 Jun 23 15:32 /var/tmp/sosreport-k8sdemo-hxvrp-master-2-03250992-2022-06-23-yzrrjsq.tar.xz.sha256

If you have permission problems:

$ oc rsh k8sdemo-hxvrp-master-2-debug
sh-4.4# chroot /host
sh-4.4# chmod 777 /var/tmp/sos*

Copy from DEBUG NODE

See that using normal oc cp you can have the error bellow

$ oc cp k8sdemo-hxvrp-master-2-debug:/host/var/tmp/sosreport-k8sdemo-hxvrp-master-2-03250992-2022-06-23-yzrrjsq.tar.xz .
tar: Removing leading `/' from member names
error: open .: is a directory
 
## >> tip put a name for destination file!
$ oc cp k8sdemo-hxvrp-master-2-debug:/host/var/tmp/sosreport-k8sdemo-hxvrp-master-2-03250992-2022-06-23-yzrrjsq.tar.xz my.tar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment