Search code examples
kuberneteskubernetes-ingressdocker-desktop

Kubernetes ingress nginx "not found" (les jackson tutorial)


I'm following the tutorial from Less Jackson about Kubernetes but I'm stuck around 04:40:00. I always get an 404 returned from my Ingress Nginx Controller. I followed everything he does, but I can't get it to work.

I also read that this could have something to do with IIS, so I stopped the default website which also runs on port 80.

The apps running in the containers are .NET Core.

Commands-deply & cluster ip

apiVersion: apps/v1
kind: Deployment
metadata:
 name: commands-depl
spec:
 replicas: 1
 selector:
  matchLabels:
   app: commandservice
 template:
  metadata:
   labels:
    app: commandservice
  spec:
   containers:
    - name: commandservice
      image: maartenvissershub/commandservice:latest
---
apiVersion: v1
kind: Service
metadata:
 name: commands-clusterip-srv
spec:
 type: ClusterIP
 selector:
  app: commandservice
 ports:
  - name: commandservice
    protocol: TCP
    port: 80
    targetPort: 80

Platforms-depl & cluster ip

apiVersion: apps/v1
kind: Deployment
metadata:
 name: platforms-depl
spec:
 replicas: 1
 selector:
  matchLabels:
   app: platformservice
 template:
  metadata:
   labels:
    app: platformservice
  spec:
   containers:
    - name: platformservice
      image: maartenvissershub/platformservice:latest
---
apiVersion: v1
kind: Service
metadata:
 name: platforms-clusterip-srv
spec:
 type: ClusterIP
 selector:
  app: platformservice
 ports:
  - name: platformservice
    protocol: TCP
    port: 80
    targetPort: 80

Ingress-srv

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
 name: ingress-srv
 annotations:
  kubernetes.io/ingress.class: nginx
  nginx.ingress.kubernetes.io/use-regex: 'true'
  nginx.ingress.kubernetes.io/rewrite-target: /
spec:
 rules:
  - host: acme.com
    http:
     paths:
      - path: /api/platforms
        pathType: Prefix
        backend:
         service:
          name: platforms-clusterip-srv
          port:
           number: 80
      - path: /api/c/platforms
        pathType: Prefix
        backend:
         service:
          name: commands-clusterip-srv
          port:
           number: 80

I also added this to my hosts file: 127.0.0.1 acme.com

And I applied this from the nginx documentation:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.3.0/deploy/static/provider/cloud/deploy.yaml

kubectl get ingress kubectl get ingress

kubectl describe ing ingress-srv
kubectl describe ing ingress-srv

Dockerfile CommandService

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build-env
WORKDIR /app

COPY *.csproj ./
RUN dotnet restore

COPY . ./
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:5.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT [ "dotnet", "PlatformService.dll" ]

kubectl logs ingress-nginx-controller-6bf7bc7f94-v2jnp -n ingress-nginx LOGS INGRESS POD

Am I missing something?


Solution

  • I found my solution. There was a process running on port 80 with pid 4: 0.0.0.0:80. I could stop it using NET stop HTTP in an admin cmd.

    I noticed that running kubectl get services -n=ingress-nginx resulted a ingress-nginx-controll, which is fine, but with an external-ip . Running kubectl get ingress also didn't show an ADDRESS. Now they both show "localhost" as value for external-ip and ADDRESS.

    Reference: Port 80 is being used by SYSTEM (PID 4), what is that?