Kubernetes Python client connection Issue - python-3.x

I have setup Official Kubernetes Python Client (https://github.com/kubernetes-client/python).
I am running Python code to connect to a Kubernetes cluster and it's throwing an error:
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='****', port=6443): Max retries exceeded with url: /api/v1/namespaces/default/pods (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 110] Connection timed out',))
Installed requirements:
cachetools 3.1.0 ,
certifi 2019.3.9 ,
chardet 3.0.4 ,
google-auth 1.6.3 ,
idna 2.8 ,
ipaddress 1.0.22 ,
kubernetes 10.0.0-snapshot ,
oauthlib 3.0.1 ,
pip 19.0.3 ,
pyasn1 0.4.5 ,
pyasn1-modules 0.2.4 ,
python-dateutil 2.8.0 ,
PyYAML 5.1 ,
requests 2.21.0 ,
requests-oauthlib 1.2.0 ,
rsa 4.0 ,
setuptools 41.0.0 ,
six 1.12.0 ,
urllib3 1.24.1 ,
websocket-client 0.56.0 ,
wheel 0.33.1
kubectl is working fine with the same config $HOME/.kube/config and same proxy settings.
Below is my code:
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)

In my case simply loading the config via load_kube_config didn't work as well. I ended up first running a proxy:
kubectl proxy --port=8888
and then changing the host using the Configuration object:
configuration = client.Configuration()
configuration.host = "localhost:8888"
api_client = client.CoreV1Api(client.ApiClient(configuration))

You need to specify the host ID for your client. You can find this in AI Platform Pipelines >> Settings. The code will look similar to this:
import kfp
client = kfp.Client(host='###########-dot-us-east1.pipelines.googleusercontent.com')

Related

Error in connecting python client "Exception during establishing a SSL connection: io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record"

I am trying to get a python ElasticSearch client to connect to a local OpenSearch server that is running via docker. Am unable to connect and keep getting
opensearch-node1 | [2021-09-25T00:09:09,526][ERROR][o.o.s.s.h.n.SecuritySSLNettyHttpServerTransport] [opensearch-node1] Exception during establishing a SSL connection: io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record:
Installed OpenSearch locally sing docker following these instructions https://opensearch.org/downloads.html
Tried various ways to get the python client to connect but all are failing.
# es = Elasticsearch(timeout=600, hosts="http://localhost:9200", http_auth=('admin', 'admin'), use_ssl=False, verify_certs=False)
es = Elasticsearch(timeout=600, hosts=["http://localhost:9200"])
es.ping()
python version: 3.9.7
ElasticSearch python lib: 7.15.0
Has anybody experiences this?
**** Figured it out ****
Need to have a client of at most 7.13.4 as per the docs opensearch.org/docs/clients/index
and as per this issues github.com/opendistro-for-elasticsearch/sample-code/issues/242, have to initiate the client like this for local dev
es = Elasticsearch(['https://admin:admin#localhost:9200/'],
use_ssl=False,
verify_certs=False,
ssl_show_warn=False)

Upgrade of Hyperledger fabric from 1.4.2 to 2.0

I am trying to upgrade our current network setup in fabric 1.4.2 to 2.0. We have a kubernetes setup. I see in the documentation that first we need to upgrade the peer database by using peer node upgrade-dbs and then start the peer. But since this command doesnot exist with peer version 1.4.2 I cannot do it from the running peer pod. when I tried to change the peer image to 2.0 version I get error following error. Error in instantiating ledger provider: unexpected format. db info = [leveldb for channel-IDs at [/var/hyperledger/production/ledgersData/ledgerProvider]], data format = [], expected format = [2.0]
How can I upgrade the peer database and start the peer pod in kubernetes ?
I resolved the issue my manually deleting the couchDB database and then starting the peer with 2.0 image

Installing packages with anaconda behind a http proxy

I am trying to install the package langdect in Anaconda
As I am working in an office, I tried to set up the proxy by creating a .condarc file in C:\Users\my_username
In this file I put
channels:
- defaults
show_channel_urls: True
allow_other_channels: True
proxy_servers:
http: http://username:passwordwith%escape#proxyhost:8080
https: https://username:passwordwith%escape#proxyhost:8080
ssl_verify: True
But i got the following error when executing conda update conda
ProxyError(MaxRetryError("HTTPSConnectionPool(host='repo.anaconda.com', port=443):
Max retries exceeded with url: /pkgs/pro/noarch/repodata.json.bz2
(Caused by ProxyError('Cannot connect to proxy.',
OSError('Tunnel connection failed: 407 au thenticationrequired')))"))
I already tried the solution on this question How to make Anaconda work behind HTTP proxy (not https)?
But I have some questions, is there an easy way to check my proxy blocked out the repository url? What else can I try to make it work?

Helm install from stable got no available release name found error

Installed a k8s cluster by kubespray with vagrant used its default Vagrantfile setting.
OS selected centos.
After the cluster setup finished, ran commands on master host:
$ kubectl version
Client Version: version.Info{Major:"", Minor:"", GitVersion:"v1.9.0+coreos.0", GitCommit:"1b69a2a6c01194421b0aa17747a8c1a81738a8dd", GitTreeState:"clean", BuildDate:"2017-12-19T02:52:15Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"", Minor:"", GitVersion:"v1.9.0+coreos.0", GitCommit:"1b69a2a6c01194421b0aa17747a8c1a81738a8dd", GitTreeState:"clean", BuildDate:"2017-12-19T02:52:15Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
Downloaded newest Helm from github.
$ ./helm init
$ ./helm version
Client: &version.Version{SemVer:"v2.8.0", GitCommit:"14af25f1de6832228539259b821949d20069a222", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.8.0", GitCommit:"14af25f1de6832228539259b821949d20069a222", GitTreeState:"clean"}
$ ./helm search
...
stable/phpbb 0.6.1 3.2.2 Community forum that supports the notion of use...
...
$ ./helm install stable/phpbb
Error: no available release name found
Why can't find when installing?
Have you tried adding --name my-release?

connection error while connecting mongodb using python

PYTHON CODE
from pymongo import MongoClient
if __name__ == "__main__":
client = MongoClient('mongodb://localhost:27017/')
..I even tried
client = MongoClient()
getting this error..
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [WinError 10061] No connection could be made because the target machine actively refused it
I am using Windows 10, the version of pymongo is 3.0.3 and I am using python 3.5

Resources