I have two dotnet services that I’m trying to deploy to my local kubernetes (I’m using Docker Desktop on Windows) – commands service and platforms service. My deployment files are
platforms-service-depl.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: platforms-service-depl
spec:
replicas: 1
selector:
matchLabels:
app: platformservice
template:
metadata:
labels:
app: platformservice
spec:
containers:
- name: platformservice
image: mj97/platformservice:latest
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: platform-clusterip-service
spec:
type: ClusterIP
selector:
app: platformservice
ports:
- name: platformservice
protocol: TCP
port: 80
targetPort: 8080
commands-service-depl.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: commands-service-depl
spec:
replicas: 1
selector:
matchLabels:
app: commandservice
template:
metadata:
labels:
app: commandservice
spec:
containers:
- name: commandservice
image: mj97/commandservice:latest
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: command-clusterip-service
spec:
type: ClusterIP
selector:
app: commandservice
ports:
- name: commandservice
protocol: TCP
port: 80
targetPort: 8080
and my ingress-service.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-service
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: 'true'
spec:
rules:
- host: course.com
http:
paths:
- path: /api/platforms
pathType: Prefix
backend:
service:
name: platform-clusterip-service
port:
number: 80
- path: /api/commands/platforms
pathType: Prefix
backend:
service:
name: command-clusterip-service
port:
number: 80
Now when I’m trying to make http request to my api endpoint all I get is
* Trying 127.0.0.1:80...
* connect to 127.0.0.1 port 80 failed: Connection refused
* Failed to connect to course.com port 80 after 2043 ms: Connection refused
I have also modified my hosts file by adding 127.0.0.1 course.com
.
Running netstat -ntlp
in the platforms service pod I get
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp6 0 0 :::8080 :::* LISTEN 1/dotnet
I have tried doing curl requests directly to pod ip and cluster ip service ip but I get time outs. I also tried recreating deploys and cluster ip services in hopes that I’ve missed something and just didn’t recreate them but no luck. I thought that my ports configurations are ok.
I got it working. What was missing was an ingress controller https://kubernetes.github.io/ingress-nginx/deploy/. After running kubectl apply command from that link my ingress is working and I can hit api endpoints.