项目作者: yokawasa

项目描述 :
Kubernetes ConfigMap Exporter
高级语言: Shell
项目地址: git://github.com/yokawasa/kube-configmap-exporter.git
创建时间: 2018-11-15T06:24:36Z
项目社区:https://github.com/yokawasa/kube-configmap-exporter

开源协议:Apache License 2.0

下载


kube-configmap-exporter

Kubernetes ConfigMap Exporter

Usage

  1. Usage: kube-configmap-exporter <name> -t <dir> options
  2. Options:
  3. <name> ConfigMap name to export
  4. -n, --namespace <name> Namespace ('default' by default)
  5. -t, --to <dir> Directory onto which each configmap data is stored
  6. as a file named each configmap key
  7. -h, --help Show this message
  8. -v, --version Show this command's version
  9. Example:
  10. # Export configmap "mycm" in namespace "myns" onto directory "/tmp/"
  11. kube-configmap-exporter mycm -n myns -t /tmp

Prerequisite

  • kubectl - kube-configmap-exporter uses kubectl to access Kubernetes API to import or to export ConfigMap
  • jq - kube-configmap-exporter uses jq in exporting ConfigMap

Installation

  1. sudo git clone https://github.com/yokawasa/kube-configmap-exporter /opt/kube-configmap-exporter
  2. sudo ln -s /opt/kube-configmap-exporter/kube-configmap-exporter /usr/local/bin/kube-configmap-exporter

Quickstart

Get copy of kube-configmap-exporter

  1. $ git clone https://github.com/yokawasa/kube-configmap-exporter
  2. cd kube-configmap-exporter

You have the following test files under tests/files directry:

  1. $ tree tests/files
  2. tests/files
  3. ├── database.yml
  4. ├── nginx.conf
  5. └── uwsgi.ini

Now you create ConfigMap named mycm and import these files above into it by using kubectl.

  1. $ kubectl create configmap mycm --from-file tests/files

Then, check how these config files are imported into the ConfigMap mycm.

  1. $ kubectl get cm my-config -o json
  2. {
  3. "apiVersion": "v1",
  4. "data": {
  5. "database.yml": "....",
  6. "nginx.conf": "....",
  7. "uwsgi.ini": "...."
  8. },
  9. "kind": "ConfigMap",
  10. "metadata": {
  11. "creationTimestamp": "2018-11-15T14:52:00Z",
  12. "name": "mycm",
  13. "namespace": "default",
  14. "resourceVersion": "2843317",
  15. "selfLink": "/api/v1/namespaces/default/configmaps/mycm",
  16. "uid": "01a14c9b-e8e6-11e8-b8ca-166cb263b9b6"
  17. }
  18. }

Finally, you export ConfigMap mycm onto a directory named tests/exports using kube-configmap-exporter

  1. $ mkdir tests/exports
  2. $ kube-configmap-exporter mycm -t tests/exports

Let’s check exported files in tests/exports directory.

  1. $ tree tests/exports
  2. exports
  3. ├── database.yml
  4. ├── nginx.conf
  5. └── uwsgi.ini

License

This project is Apache Licensed

Contributing

Bug reports, pull requests, and any feedback are welcome on GitHub at https://github.com/yokawasa/kube-configmap-exporter.