Search code examples
kuberneteskubectlminikube

kubernetes nodeport service not responding


Here is my deploy yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: some-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: some-api
  template:
    metadata:
      labels:
        app: some-api
    spec:
      containers:
      - name: some-api-local
        image: "ealen/echo-server:0.9.2"
        ports:
        - containerPort: 80
      imagePullSecrets:
      - name: registrycred

---
apiVersion: v1
kind: Service
metadata:
  name: some-service
spec:
  type: NodePort
  ports:
  - name: http
    port: 5001
    targetPort: 80
    nodePort: 30002
  selector:
    app: some-api

The actual service is running on port 80 with logs spitting just below: enter image description here

Just experimenting with kubernetes cluster deployments. I am trying to access a simple echo server via this service above like this:

10.109.89.108:30002

Output of: k get nodes --output wide

enter image description here

The ip above is my cluster IP that I got from kubectl get service. What I am doing wrong?

Tried to access as below:

  1. 192.168.49.2:30002 (using node ip)
  2. 10.109.89.108:30002 (cluster ip)

Solution

  • The ip above is my cluster IP that I got from kubectl get service.

    Try [node IP]:30002 to access the port. You can find the node IP with kubectl get nodes --output wide.

    For minikube, run minikube service some-service --url before browsing to http://localhost:30002. More details here.