How to connect to MongoDB in Kubernetes pod with Pymongo - python-3.x

I wanna connect to a mongodb in a kubectl pod using pymongo.
I've tried this https://kubernetes.io/blog/2017/01/running-mongodb-on-kubernetes-with-statefulsets/
but it just doesn't work.
I even used a post forwarding like:
kubectl port-forward [pod]-2 27017:27017
and tried to connect using localhost hostname (which works in mongodb tools like mongoshell) but it also gives me the same errors.
The errors I get are:
raise ServerSelectionTimeoutError(
pymongo.errors.ServerSelectionTimeoutError: [pod]-0.[service]:27017: [Errno 11001] getaddrinfo failed,[pod]-1.[service]:27017: [Errno 11001] getaddrinfo failed,[pod]-2.[service]:27017: [Errno 11001] getaddrinfo failed, Timeout: 30s, Topology Description: <TopologyDescription id: xxxxxxxxx, topology_type: Unknown, servers: [<ServerDescription ('[pod]-0.[service]', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('[pod]-0.[service]:27017: [Errno 11001] getaddrinfo failed')>, etc...]>
Notes [pod] and [services] are the pod and service names (but hidden) I'm using.
Do you have any ideas of what I'm doing wrong?
I used the last version of python3, last version of pymongo and windows10.

That article is very old. I'd recommend looking at MongoDB Community Kubernetes Operator: https://github.com/mongodb/mongodb-kubernetes-operator.
Follow https://github.com/mongodb/mongodb-kubernetes-operator/blob/master/docs/install-upgrade.md to install;
Then https://github.com/mongodb/mongodb-kubernetes-operator/blob/master/docs/deploy-configure.md to deploy a cluster;
The instructions will show how to get a connection string (in the format mongodb+srv://<username>:<password>#example-mongodb-svc.mongodb.svc.cluster.local/admin?ssl=true); use this connection string in your pymongo code.

Related

Az login urllib3 [Errno 11001] getaddrinfo failed

I am trying to log into Azure on Powershell using "az login". However, I get the following error:
<urllib3.connection.HTTPSConnection object at 0x04B37760>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed
Any insight on how to resolve this?
<urllib3.connection.HTTPSConnection object at 0x04B37760>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed
This error will occur due to proxy (Internal Proxy or Corporate Proxy).
Try setting the environment variable in command prompt before running to azure login cmdlets:
set HTTPS_PROXY=myProxy.a200.mh.gro:80
I am trying to log into Azure on Powershell using “az login”
As you said, running az login cmdlet in PowerShell for setting the HTTPS_PROXY in environment variable:
$env:HTTPS_PROXY='myProxy.a200.mh.gro:80'
Then run the az login or az login --use-device-code to login to the Azure using CLI in PowerShell.
Refer to this similar issue.

K8s Error: ImagePullBackOff || read: connection refused

Can you please assist when deploying we getting ImagePullBackOff for our pods.
running kubectl get <pod-name> -n namespace -o yaml am getting below error.
containerStatuses:
- image: mycontainer-registry.io/company/my-app:1.0.0-integration-62c7e30532bd430477731a01a962372166fd5644
imageID: ""
lastState: {}
name: dmd-base
ready: false
restartCount: 0
started: false
state:
waiting:
message: Back-off pulling image "mycontainer-registry.io/company/my-app:1.0.0-integration-62c7e30532bd430477731a01a962372166fd5644"
reason: ImagePullBackOff
hostIP: x.x.x.53
phase: Pending
podIP: x.x.x.237
and running kubectl describe pod <pod-name> -n namespace am getting below error infomation
Normal Scheduled 85m default-scheduler Successfully assigned dmd-int/app-app-base-5b4b75756c-lrcp6 to aks-agentpool-35064155-vmss00000a
Warning Failed 85m kubelet Failed to pull image "mycontainer-registry.io/company/my-app:1.0.0-integration-62c7e30532bd430477731a01a962372166fd5644":
[rpc error: code = Unknown desc = failed to pull and unpack image "mycontainer-registry.io/company/my-app:1.0.0-integration-62c7e30532bd430477731a01a962372166fd5644":
failed to resolve reference "mycontainer-registry.io/commpany/my-app:1.0.0-integration-62c7e30532bd430477731a01a962372166fd5644":
failed to do request: Head "https://mycontainer-registry.azurecr.io/v2/company/my-app/manifests/1.0.0-integration-62c7e30532bd430477731a01a962372166fd5644":
dial tcp: lookup mycontainer-registry.azurecr.io on [::1]:53: read udp [::1]:56109->[::1]:53: read: connection refused,
rpc error: code = Unknown desc = failed to pull and unpack image "mycontainer-registry.io/company/my-app:1.0.0-integration-62c7e30532bd430477731a01a962372166fd5644":
failed to resolve reference "mycontainer-registry.io/company/my-app:1.0.0-integration-62c7e30532bd430477731a01a962372166fd5644":
failed to do request: Head "https://mycontainer-registry.io/v2/company/my-app/manifests/1.0.0-integration-62c7e30532bd430477731a01a962372166fd5644":
dial tcp: lookup mycontainer-registry.io on [::1]:53: read udp [::1]:60759->[::1]:53: read: connection refused]`
From the described logs I can see the issue is a connection but I can't tell where the issue is with connectivity, we running our apps in a Kubernetes cluster on Azure.
If anyone has come across this issue can you please assist the application has been running successfully throughout the past months we just got this issue this morning.
There is a known Azure outage multiple regions today.
Some DNS issue that also affects image pulls.
https://status.azure.com/en-us/status

Can't edit the cluster created by mlflow model serving

I'm trying to deploy Machine learning model into databricks production using mlflow. while in that process, I have registered the model to mlflow models. After that it created the cluster but then it was in pending state forever. when I checked the model events, I see a problem with https proxy, we have global init scripts which contain proxy information.
Ref: https://docs.databricks.com/applications/mlflow/model-serving.html
so the only way for us to edit the cluster and add them but in that process we are getting an error "error: Cannot edit cluster created by ModelServing".
[Errno 101] Network is unreachable',)': /simple/mlflow/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f258247f710>: Failed to establish a new connection:
In the "Model Events page", I see the above logs,
The important error here is
Failed to establish a new connection: [Errno 101] Network is unreachable
The complaint that pip could not find a version that satisfies the requirement is caused by the failure to connect to the pip repo.
Notice that the installation of the yum packages, e.g. python-pip, succeeded. After a bit of checking, the user discovered that the problem was that he was using a yum proxy, but no proxy was configured for pip. He was able to solve the problem by setting HTTP and HTTPS proxies in his environment:
export HTTPS_PROXY=http://x.x.x.x:y
export HTTP_PROXY=http://x.x.x.x:y

login to tryton and problem with the host

I am beginner with tryton so excuse my question.
which host and profile should i use .
I need to connect to the server but i don't know which what host do i need.
I tried to log in whith localhost:8000 and local and localhost and ip address but all of these trials failed.
So is there a problem with the installation of tryton or am i entering the wrong host and profile.
INFO:tryton.rpc:common.server.version(None, None)
ERROR:tryton.rpc:[Errno -2] Name or service not known
exit
INFO:tryton.rpc:common.db.list()
INFO:tryton.rpc:common.server.version(None, None)
INFO:tryton.rpc:common.db.list()
INFO:tryton.rpc:common.server.version(None, None)
ERROR:tryton.rpc:[Errno -2] Name or service not known
gnuhealth#ghealth:~ $ exit
déconnexion
[otbs#ghealth ~]$ tryton
ERROR:tryton.rpc:[Errno 111] Connexion refusée
ERROR:tryton.rpc:[Errno 111] Connexion refusée
ERROR:tryton.rpc:Remote end closed connection without response
here's a photo below.
Thank you.

Chef-server-ctl reconfigure/ Creating Admin User on chef server

I am fairly new to Linux (and brand new to chef) and I have ran into an issue when setting up my chef server. I am trying to create an admin user with the command
sudo chef-server-ctl user-create admin Admin Ladmin admin#example.com
examplepass -f admin.pem
but after I keep getting this error:
ERROR: Connection refused connecting...
ERROR: Connection refused connecting to https://127.0.0.1/users/, retry 5/5
ERROR: Network Error: Connection refused - Connection refused
connecting to https://..., giving up
Check your knife configuration and network settings
I also noticed that when I ran chef-server-ctl I got this output:
[2016-12-21T13:24:59-05:00] ERROR: Running exception handlers Running
handlers complete
[2016-12-21T13:24:59-05:00] ERROR: Exception
handlers complete Chef Client failed. 0 resources updated in 01 seconds
[2016-12-21T13:24:59-05:00] FATAL: Stacktrace dumped to
/var/opt/opscode/local-mode-cache/chef-stacktrace.out
[2016-12-21T13:24:59-05:00] FATAL: Please provide the contents of the
stacktrace.out file if you file a bug report
[2016-12-21T13:24:59-05:00] FATAL:
Chef::Exceptions::CannotDetermineNodeName: Unable to determine node
name: configure node_name or configure the system's hostname and fqdn
I read that this error is due to a prerequisite mistake but I'm uncertain as to what it means or how to fix it. So any input would be greatly appreciated.
Your server does not have a valid FQDN (aka full host name). You'll have to fix this before installing Chef server.

Resources