Extends load-environ-typed to get info right from Kubernetes API
Project description
load-environ-typed-kubernetes
Extends load-environ-typed to get info right from Kubernetes API
Getting started
from typing import Dict
from load_environ_typed import load
from load_environ_typed_kubernetes.loaders import KubernetesLoader
from dataclasses import dataclass
@dataclass
class MyEnviron:
my_config_map: Dict[str, str]
my_secret: Dict[str, str]
kubernetes = KubernetesLoader(in_cluster=True)
environ = load(MyEnviron, loaders={
'my_config_map': kubernetes.load_config_map,
'my_secret': kubernetes.load_secret,
})
Contributing
Make sure you have kubectl installed via https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/.
Install a local kubernetes cluster, for example using https://kind.sigs.k8s.io/.
kind create cluster --name load-environ-typed-kubernetes
kubectl create namespace load-environ-typed-kubernetes-test
# Create the configmap and secrets
kubectl --namespace load-environ-typed-kubernetes-test apply -f tests/configmap.yaml
kubectl --namespace load-environ-typed-kubernetes-test apply -f tests/secret.yaml
# Create a role that can access the configmap and secrets
kubectl --namespace load-environ-typed-kubernetes-test apply -f tests/serviceaccount.yaml
kubectl --namespace load-environ-typed-kubernetes-test apply -f tests/role.yaml
kubectl --namespace load-environ-typed-kubernetes-test apply -f tests/rolebinding.yaml
Check out this repo, and then use the following steps to test it:
python3 -m venv venv
venv/bin/pip install .
venv/bin/pip install -r requirements-dev.txt
make test
Run a test container on Kubernetes:
docker build -f tests/docker/Dockerfile . -t load-environ-typed-kubernetes-test:0.0.1
kind load docker-image --name load-environ-typed-kubernetes load-environ-typed-kubernetes-test:0.0.1
kubectl --namespace load-environ-typed-kubernetes-test apply -f tests/pod.yaml
Alternatively:
make reload-pod-on-kind
Deploying
First, update pyproject.toml with the new version number, and commit that.
Then:
rm -f dist/* # Clean old build files
venv/bin/python -m build
venv/bin/python -m twine upload dist/*
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 load_environ_typed_kubernetes-0.0.1.tar.gz.
File metadata
- Download URL: load_environ_typed_kubernetes-0.0.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4816962e4d8543a5bd34cffced2ac0afa2185c3ad52320e575d0b067f9662ca9
|
|
| MD5 |
6f54c6c0447c245e79ea6b76d31a7be5
|
|
| BLAKE2b-256 |
d7c14001519f582d4cc68d5dfcefb5e189dd03ec37efa564e04a80f9bfc2f093
|
File details
Details for the file load_environ_typed_kubernetes-0.0.1-py3-none-any.whl.
File metadata
- Download URL: load_environ_typed_kubernetes-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b7282e4b4aba8d57f100ead63dd60f2e428150fa781cfde3975f7b55f69c8eb
|
|
| MD5 |
c62c1f485bdc25bb86f6835da6ab5b62
|
|
| BLAKE2b-256 |
8fe61518ff5dd59b32b07494037932a8b79a48a71fd0fc7d4716c51b5f8b6110
|