telnet: Unable to connect to remote host: Connection refused - running from a kubernetes pod

devcodes

My local kubernetes cluster is running by Rancher Desktop -

% kubectl cluster-info

Kubernetes control plane is running at https://127.0.0.1:6443
CoreDNS is running at https://127.0.0.1:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://127.0.0.1:6443/api/v1/namespaces/kube-system/services/https:metrics-server:https/proxy

I have created a very basic job - to do a telnet at localhost and port 6443 and see if the connection is reachable by the job pod running in the cluster ->

apiVersion: batch/v1
kind: Job
metadata:
  name: telnet-test
spec:
  template:
    spec:
      containers:
      - name: test-container
        image: getting-started:latest
        imagePullPolicy: IfNotPresent
        command: ["/usr/bin/telnet"]
        args: ["127.0.0.1","6443"]
      restartPolicy: Never
  backoffLimit: 4

Docker image is also basic , installing telnet ->

#Download base image ubuntu 16.04
FROM ubuntu:16.04

# Update Software repository
RUN apt update && apt upgrade

# Install nginx, php-fpm and supervisord from ubuntu repository
RUN apt install -y telnet

CMD ["which","telnet"]

EXPOSE 6443

When I run this job , I get connection refused ->

telnet: Unable to connect to remote host: Connection refused
Trying 127.0.0.1...

Any idea what I could be missing here ?

Audun Nes

"kubectl cluster-info" shows you on which NODE and port your Kubernetes api-server is Running. So these are processes running on either a virtual machine or on a physical machine.

IP address 127.0.0.1 is also known as the localhost address, and belong to the local network adapter. Hence it is NOT a real IP that you can call from any other machine.

When you test 127.0.0.1:6443 inside your container image running as a Pod or with "docker run", you are not trying to call the NODE on port 6443. Instead you are trying to call the localhost address on port 6443 INSIDE the container.

When you install Kubernetes, it would be better if you configure the cluster address as the :6443 or :6443 instead of using a localhost address.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Connection refused when trying to access a kubernetes pod via kubernetes DNS

Telnet [Unable to connect to remote host: Connection refused]

connect to host localhost port 22: Connection refused

Connection refused / couldn't connect to host

Unable to connect to tomcat running in Docker (Connection refused)

"Connect: Connection Refused" when Connecting Prometheus to Kubernetes

Kubernetes pod desc shows "connection refused" error

Connection refused when trying to connect to services in Kubernetes

Kubernetes: connection refused on the endpoint of a working pod

Getting connection refused from kubernetes pod open port

Could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?

Unable to connect to Cockroach pod in Kubernetes

Jmeter remote connection throwing "Connection refused to host"

Hadoop: connect to host localhost port 22: Connection refused when running start-dfs.sh

ssh: connect to host port 22: Connection refused

PHP Socket Connection - Telnet refused to connect

Unable to connect to the remote server: No connection could be made because the target machine actively refused it

ssh connect to host port 22: Connection refused

socket connection refused: telnet: Unable to connect to remote host: Connection refused

MiNiFi - NiFi Connection Failure: Unknown Host Exception : Able to telnet host from the machine where MiNiFi is running

django postgres could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1)

Impossible to connect to minecraft remote server : connection refused

Running rails + postgres in kubernetes: Connection refused

could not connect to server: Connection refused Is the server running on host ... and accepting TCP/IP connections on port 5432?

"Unable to connect to remote host: Connection refused" error when trying to get two Azure VMs to communicate on different ports

Getting Connection refused while trying to access service from kubernetes pod

MQTT connection refused when trying to connect from remote machine

Access a web service in kubernetes pod from local browser using NodePort yields Connection refused

unable to connect to server: connection failed: connection refused is the server running on that host accepting tcp/ip connections?