0

I have created a cluster using minikube. Added deployment and a cluster IP service to it. Now I want to access this resource from outside the cluster, using curl or browser and nginx routing using the nginx ingress controller. I have enabled ingress and applied the following ingrwess-srv.yaml:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
    - host: my-domain.dev
      http:
        paths:
          - path: /auth
            pathType: Prefix
            backend:
              service:
                name: auth-srv
                port:
                  number: 3003

This is my auth-depl.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: auth-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: auth
  template:
    metadata:
      labels:
        app: auth
    spec:
      containers:
        - name: auth
          image: my-image-from-docker-hub
          env:
            - name: MONGO_URI
              value: 'mongodb://auth-mongo-srv:27017/auth'
---
apiVersion: v1
kind: Service
metadata:
  name: auth-srv
spec:
  selector:
    app: auth
  ports:
    - name: auth
      protocol: TCP
      port: 3003
      targetPort: 3003

Then I run: kubectl get ingress and thats the result:

NAME              CLASS   HOSTS          ADDRESS        PORTS   AGE
example-ingress   nginx   my-domain.dev  182.138.19.21   80      48m

and then I add in the /etc/hosts using sudo:

182.138.19.21 my-domain.dev

And then run: curl my-domain.dev and no response is comming.

How can I make access the dev cluster in my local env so I can develop on it?

Also tried use skaffold, which actually reflects changes in the src dirs, but I don't find a way to access them via browser.

Jonas
  • 121,568
  • 97
  • 310
  • 388
Raz Buchnik
  • 7,753
  • 14
  • 53
  • 96
  • If the you have configured the Minikube server on your local machine, then you can try `minikube service auth-srv` . – Shubham Vaishnav Sep 25 '21 at 13:35
  • If you're trying to actually do development, I wouldn't bring Kubernetes into the setup. You're running a single-node instance of a distributed clustered environment inside a virtual machine, and there are multiple things keeping your local source tree separate from the pod environment. Build and test your application locally, mocking out as much as you need to so you can run unit tests without external dependencies, and deploy the application like this only when you need to do final manual or integration testing. – David Maze Sep 25 '21 at 15:11
  • @DavidMaze so why skaffold dev in first of all (a tool assist developing in k8s cluster locally)? And why minikube as well? Also, its much easier applying all of those yaml files instead of actually installing all of those db's as docker containers and handle their versions, isn't it? – Raz Buchnik Sep 25 '21 at 20:59
  • Do you get the same result with `curl my-domain.dev/auth` ? Do you get any specific error ? – mario Sep 27 '21 at 18:40
  • @mario yes, just no response - the terminal is processing... – Raz Buchnik Sep 29 '21 at 06:53

0 Answers0