Open
Description
What happened (please include outputs or screenshots):
I want to remove a key from a secret. So I'm creating the patch data with a None
value for this key. This key is not deleted (secret is unchanged).
What you expected to happen:
The key is deleted.
How to reproduce it (as minimally and precisely as possible):
Create a secret my-secret
in some namespace mpw
. It should contain a key test
with some value.
Then run this program:
import kubernetes
import yaml
with open("my-kubeconfig.yaml", encoding="utf-8") as k_config_file:
k_config = yaml.safe_load(k_config_file)
k8s_api_client = kubernetes.config.new_client_from_config_dict(k_config)
core_v1_api = kubernetes.client.CoreV1Api(k8s_api_client)
secret_data = {
"test": None,
}
core_v1_api.patch_namespaced_secret("my-secret", "mpw", kubernetes.client.V1Secret(string_data=secret_data))
Anything else we need to know?:
Note that I'm passing the secret_data
to the parameter string_data. When I passing it to data, the key is deleted as expected.
Environment:
- Kubernetes version (
kubectl version
): Server Version: v1.29.3 - OS (e.g., MacOS 10.13.6): MacOS 14.6.1
- Python version (
python --version
): Python 3.11.9 - Python client version (
pip list | grep kubernetes
): kubernetes 30.1.0