python icon indicating copy to clipboard operation
python copied to clipboard

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

Open cbaenziger opened this issue 10 months ago • 2 comments

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 avatar Mar 05 '25 23:03 cbaenziger

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))

yliaog avatar Mar 12 '25 18:03 yliaog

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jun 10 '25 19:06 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Jul 10 '25 19:07 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-triage-robot avatar Aug 09 '25 20:08 k8s-triage-robot

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar Aug 09 '25 20:08 k8s-ci-robot