Pydaconf plugin for Kubernetes Secrets
Project description
Pydaconf Kubernetes Secrets Plugin
Pydaconf plugin for Kubernetes Secrets
Pydaconf
For more information about Pydaconf see the Docs.
Installation
Install using pip install pydaconf-plugins-k8s
A Simple Example
- Create config file in toml, yaml or json
secret: K8S_SECRET:///secret_name=my-secret,key=username
- Create Pydantic Model and load the configuration
from pydaconf import PydaConf
from pydantic import BaseModel
class Config(BaseModel):
secret: str
provider = PydaConf[Config]()
provider.from_file("config.yaml")
print(provider.config.secret)
Supported parameters
Parameters can be passed in the configuration value in the following format:
K8S_SECRET:///param1=value1,param2=value2
| Parameter | Description |
|---|---|
| secret_name | The name of the kubernetes secret |
| key | The key of the specific secret element |
| namespace | If not provided, the plugin will try to load it from the POD file system. If not available, the 'default' namespace will be used |
| watch | Watch the secret for any updates. |
OnUpdate callback
The plugin can monitor secret update events and notify the on_update_callback. It starts a background thread and subscribes to updates. When an update occurs, it notifies the on_update_callback, ensuring the value in the configuration stays up to date and next time when you access it, it will be the updated version. You can also subscribe to updates using the .on_update method.
from pydaconf import PydaConf
from pydantic import BaseModel
def on_change_callback(key: str, value: str):
print(f"Configuration updated: {key} -> {value}")
class Config(BaseModel):
api_key: str
provider = PydaConf[Config]()
provider.from_file("config.yaml")
# Subscribe to updates for api_key
provider.on_update(".api_key", on_change_callback)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydaconf_plugins_k8s-0.1.0.tar.gz.
File metadata
- Download URL: pydaconf_plugins_k8s-0.1.0.tar.gz
- Upload date:
- Size: 51.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
715938458de3d56584bbf48f695435ab3cedd00f03eab2e1b8463947aa11e232
|
|
| MD5 |
37c89ab6c6978410454d89f3c5426838
|
|
| BLAKE2b-256 |
1169d0a844eced7f25426a795855ad232526476acc41ebc826a32d5388fe9057
|
File details
Details for the file pydaconf_plugins_k8s-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pydaconf_plugins_k8s-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfe42d1392660fabc017a10ba950759604549c32fa7abaa949ae80cfd90e99ee
|
|
| MD5 |
3e093a73759a73f030b4b520f3a3cc1c
|
|
| BLAKE2b-256 |
35e223f248ec850c2e5137d4da22c7878962f71a8434e14276a646027a4ac37c
|