2 years ago

#68092

test-img

jcarchive

Minikube exposed service url returns connection refused but kubectl port-forward working fine

I did this setup to test kubernetes with minikube 'Set up Ingress on Minikube' and everything worked fine.

Then I tried to do the same with my own app and am having a problem after configuring all the steps.

The steps that I did to setup my app and kubernetes are:

  • Create an app that works on port 5000
  • Containarized the app in a docker image and upload to the minikube image registry
  • Created a deployment for kubernetes with my container
  • Run kubectl port-forward pod/app 5000 and everyting works fine
  • Created a service with type Nodeport to expose the deployment
  • Run kubectl port-forward service/app-service 5000 and everyting works fine
  • Created an ingress to expose the service
  • Run curl app.info and it returns 502 bad gateway
  • Tryied again kubectl port-forward service/app-service 5000 and it still works fine
  • Check minikube service app-service --url and tried the result URL and it returns Connection refused, the equivalent url in the demo setup that I did previously works fine so it looks like something is wrong in this step even when doing the port-forwarding works correctly.
kind: Deployment
metadata:
  namespace: echo-app
  name: app
  labels:
    app: echo
    tier: services
spec:
  replicas: 1
  selector:
    matchLabels:
      tier: services
  template:
    metadata:
      labels:
        tier: services
    spec:
      containers:
      - name: echo-api
        image: echo/api:v1.0.0b39c8f9a
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 5000
apiVersion: v1
kind: Service
metadata:
  name: app-service
  namespace: echo-app
spec:
  type: NodePort
  selector:
    tier: services
  ports:
    - protocol: TCP
      port: 5000
      targetPort: 5000
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: api-ingress
  namespace: echo-app
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
    - host: echo.info
      http:
        - paths:
          path: /
          pathType: Prefix
          backend:
            service:
               name: api-service
               port:
               number: 5000

docker

kubernetes

minikube

0 Answers

Your Answer

Accepted video resources