Hi I am trying to do communication between a mongo database and nodejs application using kubernetes. everything is running fine . but I ma unable to access my api from outside environment. I am also not able to telnet the port.
apiVersion: v1
kind: Service
metadata:
name: node
labels:
app: node
tier: backend
spec:
type: NodePort
ports:
- port: 3000
nodePort: 30005
externalIPs:
- 34.73.154.127
# # Replace with the IP of your minikube node / master node
# selector:
# app: node
# tier: backend
this is my service yaml file
when i am checking the status of port using commandsudo lsof -i:30005
I am able to see the results as below
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
kube-prox 2925 root 8u IPv6 32281 0t0 TCP *:30005 (LISTEN)
Now i should be able to telnet the port with ip liketelnet 34.73.154.127 30005
but I am getting result as below.
Trying 34.73.154.127...
telnet: Unable to connect to remote host: Connection refused
If any of my friend is going to suggest that port is not open then please note that i have open all the port range from anywhere.
One more thing I want to let you know that I deployed a sample node application natively using npm on port 30006 and i am able to telnet on this port. So conclusion is that all the port range is open and working.
This is the describe command result of servicekubectl describe service/node
result:
Name: node
Namespace: default
Labels: app=node
tier=backend
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"node","tier":"backend"},"name":"node","namespace":"defau...
Selector: <none>
Type: NodePort
IP: 10.102.42.145
External IPs: 34.73.154.127
Port: <unset> 3000/TCP
TargetPort: 3000/TCP
NodePort: <unset> 30005/TCP
Endpoints: <none>
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
Please let me know what is wrong with me ..
ENVIRONMENT:
cloud :google cloud platform
container :using docker and kubernetes
ubuntu 16.04 LTS
kubernetes 1.13.0
In order to access your service from the outside you need to expose this service as a LoadBalancer type such as:
apiVersion: v1
kind: Service
metadata:
name: node
labels:
app: node
tier: backend
spec:
type: LoadBalancer
ports:
- port: 3000
nodePort: 30005
Google Cloud Platform will provision you an IP Address that is publicly routable and will open the firewall for you.
Hi I was doing a silly mistake .
Just uncommented this in my service yaml file and it started working
# # Replace with the IP of your minikube node / master node
# selector:
# app: node
# tier: backend