Files & Shell to containers
Copy files
- Copy files between source and destination
# kubectl - Copy files from source to destination
# kubectl cp SOURCE_PATH DEST_PATH
kubectl cp /tmp/test.txt nginx-pod:/var/www/html/test.txt
# oc - Copy files from source to destination
# oc cp SOURCE_PATH DEST_PATH
oc cp /tmp/test.txt nginx-pod:/var/www/html/test.txt
Rsync Files
- Synchronise file between source and destination
- if rsync is not found, a tar archive is created instead
# rsync binary must exist in both local and container filesystem
# oc rsync SOURCE_PATH DEST_PATH
oc rsync /tmp/test.txt nginx-pod:/var/www/html/test.txt
Exec into files
# kubectl
kubectl exec -it nginx-pod -- /bin/sh
OCP RSH
- SSH into a pod or containers pod
oc rsh nginx-pod
# to rsh into specific container in a pod
oc rsh nginx-pod --container some-container