npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kdump

v1.0.17

Published

Dumps all api-resources to yaml-files for all contexts and namespaces

Downloads

29

Readme

kdump

Dumps all kubernetes api resources (pods, deployments, namespaces, etc..) to files in yaml form.

Quick and dirty hack. Don't expect pretty code :).

My use case: poor man's etcd -> git sync

Dumps all api-resources from all configured contexts.

  • Calls kubectl api-resources to figure out what it has access to, then starts downloading all of it using kubectl get <resource> -o yaml > <file>.

WARNING: also dumps secrets. If you use this in for example a backup script and then commit to git (my use case), be sure to put *secret* in your .gitignore (or encrypt them)

Options
╰─>$ kdump --help
Options:
  --version                    Show version number                     [boolean]
  --context, -c                Specify contexts. If omitted - use all available
                                                                         [array]
  --exclude-context, --ec      Exclude contexts                          [array]
  --namespace, -n              Specify namespaces. If omitted - use all
                               available                                 [array]
  --exclude-namespace, --en    Exclude namespaces                        [array]
  --exclude-global, --eg       Exclude global (non-namespaced) data
                                                      [boolean] [default: false]
  --namespaced-resource, --nr  Specify namespaced resources. If omitted - use
                               all available                             [array]
  --global-resource, --gr      Specify global resources. If omitted - use all
                               available                                 [array]
  --exclude-resource, --er     Exclude resource                          [array]
  --include-secrets            If to include secrets, default false. you will
                               need to include encrypt-password or set
                               encrypt-secrets false  [boolean] [default: false]
  --encrypt-secrets            If to encrypt the secrets resource. Default and
                               recommended. To decrypt:
                               openssl enc -d -aes-256-cbc -iv hexIV -K hexKey
                                                       [boolean] [default: true]
  --encrypt-password, -p       Password for aes-256-cbc encryption of secrets
                               resource. This must be 32 bytes hex (64
                               characters).You can generate one using:
                               openssl rand -hex 32                     [string]
  --encrypt-algorithm          Encryption algorithm to use for secrets
                                               [string] [default: "aes-256-cbc"]
  --prev-dump-dir              Directory with contents of previous dump. Useful
                               to compare encrypted secrets to only replace file
                               if something actually changed. (otherwise you
                               will get a git diff every time because encryption
                               IV changes)                              [string]
  --output-dir, -o             Output directory                         [string]
  --include-empty-resources    If to write yaml files for resources with no
                               entries                [boolean] [default: false]
  --help                       Show help                               [boolean]

Output: Downloaded directory/file structure

.
├── context1
│   ├── <non-namespaced-resources..>.yml
│   ├── context1_namespace1
│   |   ├── <namespaced-resources..>.yml
│   ├── context1_namespace2
│       ├── <namespaced-resources..>.yml
└── context2
    ├── <non-namespaced-resources..>.yml
    ├── context2_namespace1
    |   ├── <namespaced-resources..>.yml
    ├── context2_namespace2
        ├── <namespaced-resources..>.yml

Warning

Written in Node.js, which I am a beginner in. All advice on style and best practices very welcome! Expect things to break :S.

Example

A rancher2 (kubernetes management platform) setup with 2 clusters (test and prod), each with a default namespace:

cd somewhere

kdump

tree -->

├── prod
│   ├── apiservices.yml
│   ├── bgpconfigurations.yml
│   ├── cattle-system
│   │   ├── alertmanagers.yml
│   │   ├── clusterauthtokens.yml
│   │   ├── clusteruserattributes.yml
│   │   ├── configmaps.yml
│   │   ├── controllerrevisions.yml
│   │   ├── cronjobs.yml
│   │   ├── daemonsets.yml
│   │   ├── deployments.yml
│   │   ├── endpoints.yml
│   │   ├── events.yml
│   │   ├── horizontalpodautoscalers.yml
│   │   ├── ingresses.yml
│   │   ├── jobs.yml
│   │   ├── leases.yml
│   │   ├── limitranges.yml
│   │   ├── networkpolicies.yml
│   │   ├── persistentvolumeclaims.yml
│   │   ├── poddisruptionbudgets.yml
│   │   ├── pods.yml
│   │   ├── podtemplates.yml
│   │   ├── prometheuses.yml
│   │   ├── prometheusrules.yml
│   │   ├── replicasets.yml
│   │   ├── replicationcontrollers.yml
│   │   ├── resourcequotas.yml
│   │   ├── rolebindings.yml
│   │   ├── roles.yml
│   │   ├── secrets.yml
│   │   ├── serviceaccounts.yml
│   │   ├── servicemonitors.yml
│   │   ├── services.yml
│   │   └── statefulsets.yml
│   ├── certificatesigningrequests.yml
│   ├── clusterinformations.yml
│   ├── clusterrolebindings.yml
│   ├── clusterroles.yml
│   ├── componentstatuses.yml
│   ├── csidrivers.yml
│   ├── csinodes.yml
│   ├── customresourcedefinitions.yml
│   ├── default
│   │   ├── alertmanagers.yml
│   │   ├── clusterauthtokens.yml
│   │   ├── clusteruserattributes.yml
│   │   ├── configmaps.yml
│   │   ├── controllerrevisions.yml
│   │   ├── cronjobs.yml
│   │   ├── daemonsets.yml
│   │   ├── deployments.yml
│   │   ├── endpoints.yml
│   │   ├── events.yml
│   │   ├── horizontalpodautoscalers.yml
│   │   ├── ingresses.yml
│   │   ├── jobs.yml
│   │   ├── leases.yml
│   │   ├── limitranges.yml
│   │   ├── networkpolicies.yml
│   │   ├── persistentvolumeclaims.yml
│   │   ├── poddisruptionbudgets.yml
│   │   ├── pods.yml
│   │   ├── podtemplates.yml
│   │   ├── prometheuses.yml
│   │   ├── prometheusrules.yml
│   │   ├── replicasets.yml
│   │   ├── replicationcontrollers.yml
│   │   ├── resourcequotas.yml
│   │   ├── rolebindings.yml
│   │   ├── roles.yml
│   │   ├── secrets.yml
│   │   ├── serviceaccounts.yml
│   │   ├── servicemonitors.yml
│   │   ├── services.yml
│   │   └── statefulsets.yml
│   ├── felixconfigurations.yml
│   ├── globalnetworkpolicies.yml
│   ├── globalnetworksets.yml
│   ├── hostendpoints.yml
│   ├── ingress-nginx
│   │   ├── alertmanagers.yml
│   │   ├── clusterauthtokens.yml
│   │   ├── clusteruserattributes.yml
│   │   ├── configmaps.yml
│   │   ├── controllerrevisions.yml
│   │   ├── cronjobs.yml
│   │   ├── daemonsets.yml
│   │   ├── deployments.yml
│   │   ├── endpoints.yml
│   │   ├── events.yml
│   │   ├── horizontalpodautoscalers.yml
│   │   ├── ingresses.yml
│   │   ├── jobs.yml
│   │   ├── leases.yml
│   │   ├── limitranges.yml
│   │   ├── networkpolicies.yml
│   │   ├── persistentvolumeclaims.yml
│   │   ├── poddisruptionbudgets.yml
│   │   ├── pods.yml
│   │   ├── podtemplates.yml
│   │   ├── prometheuses.yml
│   │   ├── prometheusrules.yml
│   │   ├── replicasets.yml
│   │   ├── replicationcontrollers.yml
│   │   ├── resourcequotas.yml
│   │   ├── rolebindings.yml
│   │   ├── roles.yml
│   │   ├── secrets.yml
│   │   ├── serviceaccounts.yml
│   │   ├── servicemonitors.yml
│   │   ├── services.yml
│   │   └── statefulsets.yml
│   ├── ippools.yml
│   ├── kube-node-lease
│   │   ├── alertmanagers.yml
│   │   ├── clusterauthtokens.yml
│   │   ├── clusteruserattributes.yml
│   │   ├── configmaps.yml
│   │   ├── controllerrevisions.yml
│   │   ├── cronjobs.yml
│   │   ├── daemonsets.yml
│   │   ├── deployments.yml
│   │   ├── endpoints.yml
│   │   ├── events.yml
│   │   ├── horizontalpodautoscalers.yml
│   │   ├── ingresses.yml
│   │   ├── jobs.yml
│   │   ├── leases.yml
│   │   ├── limitranges.yml
│   │   ├── networkpolicies.yml
│   │   ├── persistentvolumeclaims.yml
│   │   ├── poddisruptionbudgets.yml
│   │   ├── pods.yml
│   │   ├── podtemplates.yml
│   │   ├── prometheuses.yml
│   │   ├── prometheusrules.yml
│   │   ├── replicasets.yml
│   │   ├── replicationcontrollers.yml
│   │   ├── resourcequotas.yml
│   │   ├── rolebindings.yml
│   │   ├── roles.yml
│   │   ├── secrets.yml
│   │   ├── serviceaccounts.yml
│   │   ├── servicemonitors.yml
│   │   ├── services.yml
│   │   └── statefulsets.yml
│   ├── kube-public
│   │   ├── alertmanagers.yml
│   │   ├── clusterauthtokens.yml
│   │   ├── clusteruserattributes.yml
│   │   ├── configmaps.yml
│   │   ├── controllerrevisions.yml
│   │   ├── cronjobs.yml
│   │   ├── daemonsets.yml
│   │   ├── deployments.yml
│   │   ├── endpoints.yml
│   │   ├── events.yml
│   │   ├── horizontalpodautoscalers.yml
│   │   ├── ingresses.yml
│   │   ├── jobs.yml
│   │   ├── leases.yml
│   │   ├── limitranges.yml
│   │   ├── networkpolicies.yml
│   │   ├── persistentvolumeclaims.yml
│   │   ├── poddisruptionbudgets.yml
│   │   ├── pods.yml
│   │   ├── podtemplates.yml
│   │   ├── prometheuses.yml
│   │   ├── prometheusrules.yml
│   │   ├── replicasets.yml
│   │   ├── replicationcontrollers.yml
│   │   ├── resourcequotas.yml
│   │   ├── rolebindings.yml
│   │   ├── roles.yml
│   │   ├── secrets.yml
│   │   ├── serviceaccounts.yml
│   │   ├── servicemonitors.yml
│   │   ├── services.yml
│   │   └── statefulsets.yml
│   ├── kube-system
│   │   ├── alertmanagers.yml
│   │   ├── clusterauthtokens.yml
│   │   ├── clusteruserattributes.yml
│   │   ├── configmaps.yml
│   │   ├── controllerrevisions.yml
│   │   ├── cronjobs.yml
│   │   ├── daemonsets.yml
│   │   ├── deployments.yml
│   │   ├── endpoints.yml
│   │   ├── events.yml
│   │   ├── horizontalpodautoscalers.yml
│   │   ├── ingresses.yml
│   │   ├── jobs.yml
│   │   ├── leases.yml
│   │   ├── limitranges.yml
│   │   ├── networkpolicies.yml
│   │   ├── persistentvolumeclaims.yml
│   │   ├── poddisruptionbudgets.yml
│   │   ├── pods.yml
│   │   ├── podtemplates.yml
│   │   ├── prometheuses.yml
│   │   ├── prometheusrules.yml
│   │   ├── replicasets.yml
│   │   ├── replicationcontrollers.yml
│   │   ├── resourcequotas.yml
│   │   ├── rolebindings.yml
│   │   ├── roles.yml
│   │   ├── secrets.yml
│   │   ├── serviceaccounts.yml
│   │   ├── servicemonitors.yml
│   │   ├── services.yml
│   │   └── statefulsets.yml
│   ├── mutatingwebhookconfigurations.yml
│   ├── namespaces.yml
│   ├── nodes.yml
│   ├── persistentvolumes.yml
│   ├── podsecuritypolicies.yml
│   ├── priorityclasses.yml
│   ├── runtimeclasses.yml
│   ├── storageclasses.yml
│   ├── validatingwebhookconfigurations.yml
│   └── volumeattachments.yml
└── test
    ├── apiservices.yml
    ├── bgpconfigurations.yml
    ├── cattle-system
    │   ├── alertmanagers.yml
    │   ├── clusterauthtokens.yml
    │   ├── clusteruserattributes.yml
    │   ├── configmaps.yml
    │   ├── controllerrevisions.yml
    │   ├── cronjobs.yml
    │   ├── daemonsets.yml
    │   ├── deployments.yml
    │   ├── endpoints.yml
    │   ├── events.yml
    │   ├── horizontalpodautoscalers.yml
    │   ├── ingresses.yml
    │   ├── jobs.yml
    │   ├── leases.yml
    │   ├── limitranges.yml
    │   ├── networkpolicies.yml
    │   ├── persistentvolumeclaims.yml
    │   ├── poddisruptionbudgets.yml
    │   ├── pods.yml
    │   ├── podtemplates.yml
    │   ├── prometheuses.yml
    │   ├── prometheusrules.yml
    │   ├── replicasets.yml
    │   ├── replicationcontrollers.yml
    │   ├── resourcequotas.yml
    │   ├── rolebindings.yml
    │   ├── roles.yml
    │   ├── secrets.yml
    │   ├── serviceaccounts.yml
    │   ├── servicemonitors.yml
    │   ├── services.yml
    │   └── statefulsets.yml
    ├── certificatesigningrequests.yml
    ├── clusterinformations.yml
    ├── clusterrolebindings.yml
    ├── clusterroles.yml
    ├── componentstatuses.yml
    ├── csidrivers.yml
    ├── csinodes.yml
    ├── customresourcedefinitions.yml
    ├── default
    │   ├── alertmanagers.yml
    │   ├── clusterauthtokens.yml
    │   ├── clusteruserattributes.yml
    │   ├── configmaps.yml
    │   ├── controllerrevisions.yml
    │   ├── cronjobs.yml
    │   ├── daemonsets.yml
    │   ├── deployments.yml
    │   ├── endpoints.yml
    │   ├── events.yml
    │   ├── horizontalpodautoscalers.yml
    │   ├── ingresses.yml
    │   ├── jobs.yml
    │   ├── leases.yml
    │   ├── limitranges.yml
    │   ├── networkpolicies.yml
    │   ├── persistentvolumeclaims.yml
    │   ├── poddisruptionbudgets.yml
    │   ├── pods.yml
    │   ├── podtemplates.yml
    │   ├── prometheuses.yml
    │   ├── prometheusrules.yml
    │   ├── replicasets.yml
    │   ├── replicationcontrollers.yml
    │   ├── resourcequotas.yml
    │   ├── rolebindings.yml
    │   ├── roles.yml
    │   ├── secrets.yml
    │   ├── serviceaccounts.yml
    │   ├── servicemonitors.yml
    │   ├── services.yml
    │   └── statefulsets.yml
    ├── felixconfigurations.yml
    ├── globalnetworkpolicies.yml
    ├── globalnetworksets.yml
    ├── hostendpoints.yml
    ├── ingress-nginx
    │   ├── alertmanagers.yml
    │   ├── clusterauthtokens.yml
    │   ├── clusteruserattributes.yml
    │   ├── configmaps.yml
    │   ├── controllerrevisions.yml
    │   ├── cronjobs.yml
    │   ├── daemonsets.yml
    │   ├── deployments.yml
    │   ├── endpoints.yml
    │   ├── events.yml
    │   ├── horizontalpodautoscalers.yml
    │   ├── ingresses.yml
    │   ├── jobs.yml
    │   ├── leases.yml
    │   ├── limitranges.yml
    │   ├── networkpolicies.yml
    │   ├── persistentvolumeclaims.yml
    │   ├── poddisruptionbudgets.yml
    │   ├── pods.yml
    │   ├── podtemplates.yml
    │   ├── prometheuses.yml
    │   ├── prometheusrules.yml
    │   ├── replicasets.yml
    │   ├── replicationcontrollers.yml
    │   ├── resourcequotas.yml
    │   ├── rolebindings.yml
    │   ├── roles.yml
    │   ├── secrets.yml
    │   ├── serviceaccounts.yml
    │   ├── servicemonitors.yml
    │   ├── services.yml
    │   └── statefulsets.yml
    ├── ippools.yml
    ├── kube-node-lease
    │   ├── alertmanagers.yml
    │   ├── clusterauthtokens.yml
    │   ├── clusteruserattributes.yml
    │   ├── configmaps.yml
    │   ├── controllerrevisions.yml
    │   ├── cronjobs.yml
    │   ├── daemonsets.yml
    │   ├── deployments.yml
    │   ├── endpoints.yml
    │   ├── events.yml
    │   ├── horizontalpodautoscalers.yml
    │   ├── ingresses.yml
    │   ├── jobs.yml
    │   ├── leases.yml
    │   ├── limitranges.yml
    │   ├── networkpolicies.yml
    │   ├── persistentvolumeclaims.yml
    │   ├── poddisruptionbudgets.yml
    │   ├── pods.yml
    │   ├── podtemplates.yml
    │   ├── prometheuses.yml
    │   ├── prometheusrules.yml
    │   ├── replicasets.yml
    │   ├── replicationcontrollers.yml
    │   ├── resourcequotas.yml
    │   ├── rolebindings.yml
    │   ├── roles.yml
    │   ├── secrets.yml
    │   ├── serviceaccounts.yml
    │   ├── servicemonitors.yml
    │   ├── services.yml
    │   └── statefulsets.yml
    ├── kube-public
    │   ├── alertmanagers.yml
    │   ├── clusterauthtokens.yml
    │   ├── clusteruserattributes.yml
    │   ├── configmaps.yml
    │   ├── controllerrevisions.yml
    │   ├── cronjobs.yml
    │   ├── daemonsets.yml
    │   ├── deployments.yml
    │   ├── endpoints.yml
    │   ├── events.yml
    │   ├── horizontalpodautoscalers.yml
    │   ├── ingresses.yml
    │   ├── jobs.yml
    │   ├── leases.yml
    │   ├── limitranges.yml
    │   ├── networkpolicies.yml
    │   ├── persistentvolumeclaims.yml
    │   ├── poddisruptionbudgets.yml
    │   ├── pods.yml
    │   ├── podtemplates.yml
    │   ├── prometheuses.yml
    │   ├── prometheusrules.yml
    │   ├── replicasets.yml
    │   ├── replicationcontrollers.yml
    │   ├── resourcequotas.yml
    │   ├── rolebindings.yml
    │   ├── roles.yml
    │   ├── secrets.yml
    │   ├── serviceaccounts.yml
    │   ├── servicemonitors.yml
    │   ├── services.yml
    │   └── statefulsets.yml
    ├── kube-system
    │   ├── alertmanagers.yml
    │   ├── clusterauthtokens.yml
    │   ├── clusteruserattributes.yml
    │   ├── configmaps.yml
    │   ├── controllerrevisions.yml
    │   ├── cronjobs.yml
    │   ├── daemonsets.yml
    │   ├── deployments.yml
    │   ├── endpoints.yml
    │   ├── events.yml
    │   ├── horizontalpodautoscalers.yml
    │   ├── ingresses.yml
    │   ├── jobs.yml
    │   ├── leases.yml
    │   ├── limitranges.yml
    │   ├── networkpolicies.yml
    │   ├── persistentvolumeclaims.yml
    │   ├── poddisruptionbudgets.yml
    │   ├── pods.yml
    │   ├── podtemplates.yml
    │   ├── prometheuses.yml
    │   ├── prometheusrules.yml
    │   ├── replicasets.yml
    │   ├── replicationcontrollers.yml
    │   ├── resourcequotas.yml
    │   ├── rolebindings.yml
    │   ├── roles.yml
    │   ├── secrets.yml
    │   ├── serviceaccounts.yml
    │   ├── servicemonitors.yml
    │   ├── services.yml
    │   └── statefulsets.yml
    ├── mutatingwebhookconfigurations.yml
    ├── namespaces.yml
    ├── nodes.yml
    ├── persistentvolumes.yml
    ├── podsecuritypolicies.yml
    ├── priorityclasses.yml
    ├── runtimeclasses.yml
    ├── storageclasses.yml
    ├── validatingwebhookconfigurations.yml
    └── volumeattachments.yml

14 directories, 435 files```