简体   繁体   中英

Trying to copy files to Pods with `kubectl cp`, But getting Error: unknown flag: --all-namespaces

Trying to copy and execute a bash script in a POD (which has one container)

kubectl cp ../docker/scripts/upload_javadumps.sh ${POD}:/opt -n apm

This commands works perfectly, But we have multiple Namespaces, Hence I wanted to use --all-namespaces like shown below which errors out saying, Error: unknown flag: --all-namespaces

How Do I use --all-namspaces in kubectl cp command?


kubectl cp ../docker/scripts/upload_javadumps.sh  ${POD}:/opt --all-namespaces
echo "Successfully copied the upload_javadumps.sh script"```

For kubectl cp flag --all-namespaces doesn't exist, you can check it with kubectl cp -h .

In your case I would go with simple bash loop like this:

for ns in namespace1 namespace2; do kubectl cp ../docker/scripts/upload_javadumps.sh ${POD}:/opt -n $ns;done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM