Skip to content

AttributeError: 'ApiClient' object has no attribute 'verify_ssl' #2368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cbaenziger opened this issue Mar 5, 2025 · 1 comment
Open
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@cbaenziger
Copy link

cbaenziger commented Mar 5, 2025

What happened (please include outputs or screenshots):
Trying to setup a simple configuration I get the following Exception:

$ ./bin/python test.py 
Traceback (most recent call last):
  File "/home/cwb/kube_python_client/test.py", line 4, in <module>
    dynClient = dynamic.DynamicClient(api_client.ApiClient(configuration=conf))
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cwb/kube_python_client/lib/python3.12/site-packages/kubernetes/client/api_client.py", line 75, in __init__
    self.rest_client = rest.RESTClientObject(configuration)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cwb/kube_python_client/lib/python3.12/site-packages/kubernetes/client/rest.py", line 61, in __init__
    if configuration.verify_ssl:
       ^^^^^^^^^^^^^^^^^^^^^^^^

Code and Kubeconfig:

$ cat test.py
from kubernetes import client, config, dynamic
from kubernetes.client import CustomObjectsApi, api_client
conf = config.kube_config.new_client_from_config(context="cbaenzig@mycluster")
dynClient = dynamic.DynamicClient(api_client.ApiClient(configuration=conf))
$ cat ~/.kube/config 
current-context: cbaenzig@mycluster
kind: Config
preferences: {}
users:
- name: me
  user:
    client-certificate: /tmp/test_key1
    client-key: /tmp/test_key2
clusters:
- cluster:
    server: https://mycluster.example.com:6443
  name: mycluster
contexts:
- context:
    cluster: mycluster
    namespace: default
    user: me
  name: cbaenzig@mycluster

Environment Setup and Test Run:

$ python -m venv  .
$ python -m venv --upgrade-deps .
$ source bin/activate
$ ./bin/python3 -m pip install kubernetes==32.0.1
$ ./bin/python test.py

What you expected to happen:
I expected to have a Dynamic Client object I could use to talk to the API server.

How to reproduce it (as minimally and precisely as possible):
Please see files above. No API server is necessary. Just use any client-certificate and client-key that will de-serialize.

Anything else we need to know?:

Environment:

  • Kubernetes version (kubectl version): <Not installed>
  • OS (e.g., MacOS 10.13.6): Ubuntu 24.04.2 LTS
  • Python version (python --version): Python 3.12.3
  • Python client version (pip list | grep kubernetes): kubernetes 32.0.1
@cbaenziger cbaenziger added the kind/bug Categorizes issue or PR as related to a bug. label Mar 5, 2025
@yliaog
Copy link
Contributor

yliaog commented Mar 12, 2025

The example below given at the page https://github.com/kubernetes-client/python works well. Hence, the issue is at the line: conf = config.kube_config.new_client_from_config(context="cbaenzig@mycluster")

from kubernetes import client, config

config.load_kube_config()

v1 = client.CoreV1Api()
print("Listing pods with their IPs:")
ret = v1.list_pod_for_all_namespaces(watch=False)
for i in ret.items:
print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

2 participants