WoozyMasta / kube-dump

Backup a Kubernetes cluster as a yaml manifest
https://kube-dump.woozymasta.ru
GNU General Public License v3.0
325 stars 67 forks source link

Cannot restrict dumps to a single namespace #31

Closed mojochao closed 2 years ago

mojochao commented 2 years ago

I'm trying to dump namespaced resources from a single namespace with the following command

$ kube-dump ns -n recsapi
Dump data directory /Users/agooch/tmp/data created
Dump data in /Users/agooch/tmp/data directory

Dump namespace admin-console started
STATE          RESOURCE                      NAME
Success        configmaps                    kube-root-ca.crt
Success        secrets                       default-token-jgsgt
<ctrl-c>
$

The admin-console namespace is the first namespace in my cluster when sorted alphabetically, so it appears to be acting on all namespaces.

I've reviewed the help docs, but can find nothing to indicate I'm using it incorrectly. Has anyone experienced this? Am I doing it wrong?

Many thanks in advance.

WoozyMasta commented 2 years ago

Hello, thanks for the info.

I have not been able to replicate this behaviour. Can you provide more information? How do you run this, downloaded script or in a container? What version are you using?

Have you tried checking this way?

docker run --tty --interactive --rm \
  --volume $HOME/.kube:/.kube \
  --volume $HOME/dump:/dump \
  woozymasta/kube-dump:1.1.1 \
  ns -n tools -r deployment -d /dump --kube-config /.kube/config

image

There is such a hunch that you are running the script locally and you have either a very old or experimental version of yq / jq. Such versions are currently used in container version 1.1.1:

# jq --version
jq-master-v3.15.0_alpha20210804-4073-gb39e1241e8
# yq --version
yq (https://github.com/mikefarah/yq/) version 4.14.1
# bash --version
GNU bash, version 5.1.8(1)-release (x86_64-alpine-linux-musl)