https://github.com/dhtech/python-konfig
Python library to provide simple access to read and update config maps in Kubernetes
https://github.com/dhtech/python-konfig
kubernetes
Last synced: 5 months ago
JSON representation
Python library to provide simple access to read and update config maps in Kubernetes
- Host: GitHub
- URL: https://github.com/dhtech/python-konfig
- Owner: dhtech
- License: mit
- Created: 2018-04-12T18:03:59.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-12T19:28:32.000Z (about 8 years ago)
- Last Synced: 2025-10-27T02:15:00.192Z (7 months ago)
- Topics: kubernetes
- Language: Python
- Size: 6.84 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# konfig
konfig is a library to make it simple for Python applications to read and write config maps.
It uses the service account inside the pod to access the API and supports no other way of
reading the credentials.
The library aims to solve the problem that some applications have that they only need
a relatively tiny amount of storage that is rarely updated.
## Install
```
pip install python-konfig
# or
pip3 install python-konfig
```
## Usage
Give the service account access to read a config map:
```
kubectl create configmap test-config --from-literal=test1=1
kubectl create role test-config-writer --verb=get,update --resource=configmaps --resource-name=test-config
kubectl create rolebinding sa-test-config-writer --serviceaccount=default:default --role=test-config-writer
```
Read / write the config map:
```
import konfig
# configmap takes 3 arguments:
# - name
# - namespace (defaults to KONFIG_NAMESPACE, or 'default')
# - server (defaults to KONFIG_SERVER, or 'https://kubernetes.default')
configmap = konfig.configmap('test-config', namespace='default')
myconfig = configmap.read()
print(myconfig)
myconfig['test1'] = int(myconfig['test1']) + 1
configmap.update(myconfig)
```
Enjoy!
## Known Issues
In Python 2.7 requests is having some issues with IP SANs,
see https://bugs.python.org/issue23239. Use DNS hostname instead.