[oracle@nm1 kubernetes]$ pwd
/u01/oracle/.local/lib/python3.6/site-packages/kubernetes
[oracle@nm1 kubernetes]$ cat __init__.py
# Copyright 2022 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__project__ = 'kubernetes'
# The version is auto-updated. Please do not edit.
__version__ = "26.1.0"
from . import client
from . import config
from . import dynamic
from . import watch
from . import stream
from . import utils
from . import leaderelection
[oracle@nm1 ~]$ python3 test.py
Listing pods with their IPs:
Traceback (most recent call last):
File "/u01/oracle/.local/lib/python3.6/site-packages/urllib3/connection.py", line 175, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "/u01/oracle/.local/lib/python3.6/site-packages/urllib3/util/connection.py", line 95, in create_connection
raise err
File "/u01/oracle/.local/lib/python3.6/site-packages/urllib3/util/connection.py", line 85, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/u01/oracle/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 710, in urlopen
chunked=chunked,
File "/u01/oracle/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/u01/oracle/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "/u01/oracle/.local/lib/python3.6/site-packages/urllib3/connection.py", line 363, in connect
self.sock = conn = self._new_conn()
File "/u01/oracle/.local/lib/python3.6/site-packages/urllib3/connection.py", line 187, in _new_conn
self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f335a9bce80>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 16, in <module>
main()
File "test.py", line 9, in main
ret = v1.list_pod_for_all_namespaces(watch=False)
File "/u01/oracle/.local/lib/python3.6/site-packages/kubernetes/client/api/core_v1_api.py", line 17309, in list_pod_for_all_namespaces
return self.list_pod_for_all_namespaces_with_http_info(**kwargs) # noqa: E501
File "/u01/oracle/.local/lib/python3.6/site-packages/kubernetes/client/api/core_v1_api.py", line 17430, in list_pod_for_all_namespaces_with_http_info
collection_formats=collection_formats)
File "/u01/oracle/.local/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 353, in call_api
_preload_content, _request_timeout, _host)
File "/u01/oracle/.local/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 184, in __call_api
_request_timeout=_request_timeout)
File "/u01/oracle/.local/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 377, in request
headers=headers)
File "/u01/oracle/.local/lib/python3.6/site-packages/kubernetes/client/rest.py", line 245, in GET
query_params=query_params)
File "/u01/oracle/.local/lib/python3.6/site-packages/kubernetes/client/rest.py", line 218, in request
headers=headers)
File "/u01/oracle/.local/lib/python3.6/site-packages/urllib3/request.py", line 75, in request
method, url, fields=fields, headers=headers, **urlopen_kw
File "/u01/oracle/.local/lib/python3.6/site-packages/urllib3/request.py", line 96, in request_encode_url
return self.urlopen(method, url, **extra_kw)
File "/u01/oracle/.local/lib/python3.6/site-packages/urllib3/poolmanager.py", line 376, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/u01/oracle/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 828, in urlopen
**response_kw
File "/u01/oracle/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 828, in urlopen
**response_kw
File "/u01/oracle/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 828, in urlopen
**response_kw
File "/u01/oracle/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 788, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/u01/oracle/.local/lib/python3.6/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='10.28.0.1', port=443): Max retries exceeded with url: /api/v1/pods?watch=False (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f335a9bce80>: Failed to establish a new connection: [Errno 111] Connection refused',))
It looks there are some additional requirements. Could you help to understand what is missing, please?
(env_tools) [opc@k8s-registry FMW-K8s]$ python3.6
Python 3.6.8 (default, Nov 18 2021, 10:07:16)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44.0.3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import sys
>>> import time
>>> import logging
>>> import argparse
>>> import re
>>> from subprocess import call
>>> from kubernetes import client, watch, config
>>> from kubernetes.stream import stream
>>> v1 = config.load_incluster_config()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/mnt/oke_shared/repos/FMW-K8s/tools/bin/env_tools/lib64/python3.6/site-packages/kubernetes/config/incluster_config.py", line 121, in load_incluster_config
try_refresh_token=try_refresh_token).load_and_set(client_configuration)
File "/mnt/oke_shared/repos/FMW-K8s/tools/bin/env_tools/lib64/python3.6/site-packages/kubernetes/config/incluster_config.py", line 54, in load_and_set
self._load_config()
File "/mnt/oke_shared/repos/FMW-K8s/tools/bin/env_tools/lib64/python3.6/site-packages/kubernetes/config/incluster_config.py", line 62, in _load_config
raise ConfigException("Service host/port is not set.")
kubernetes.config.config_exception.ConfigException: Service host/port is not set.
>>>
Thank you in advance for any help in this issue.
In the past I was testing the same on Kubernetes 1.23 version and it was working fine.
Hello,
On Kubernetes cluster version 1.25.4 I'm testing the Python kubernetes client 26.1 using test script from https://github.com/kubernetes-client/python/blob/master/examples/in_cluster_config.py
Test:
It looks there are some additional requirements. Could you help to understand what is missing, please?
I also did a manual test as below:
Thank you in advance for any help in this issue.
In the past I was testing the same on Kubernetes 1.23 version and it was working fine.
Regards,
Piotr Michalski
Environment:
kubectl version): 1.25.4python --version): 3.6pip list | grep kubernetes) 26.1