I created a microservices project. auth-service, user-service, chat-service, frontend-service, and so on.
I wanted to make this on the ubuntu20 vmware.
So I created pods and services in the microk8s for every services.
And I created an ingress so all APIs of the services can be called via the ingress.
This is the content of the yaml file for ingress.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: fishapp-ingress
labels:
app: fishapp
annotations:
ingress.kubernetes.io/rewrite-target: /
spec:
defaultBackend:
service:
name: auth-service
port:
number: 80
rules:
- http:
paths:
- path: /api/auth
pathType: Prefix
backend:
service:
name: auth-service
port:
number: 80
- path: /api/chat
pathType: Prefix
backend:
service:
name: chat-service
port:
number: 80
- path: /admin
pathType: Prefix
backend:
service:
name: frontend-service
port:
number: 80
- path: /api/media
pathType: Prefix
backend:
service:
name: media-service
port:
number: 80
- path: /api/store
pathType: Prefix
backend:
service:
name: store-service
port:
number: 80
- path: /api/user
pathType: Prefix
backend:
service:
name: user-service
port:
number: 80
- path: /api/checkout
pathType: Prefix
backend:
service:
name: checkout-service
port:
number: 80
$ kubectl apply -f ingress.yaml
$ kubectl describe ing fishapp-ingress
Name: fishapp-ingress
Namespace: default
Address: 127.0.0.1
Default backend: auth-service:80 (10.1.243.223:9080)
Rules:
Host Path Backends
---- ---- --------
*
/api/auth auth-service:80 (10.1.243.223:9080)
/api/chat chat-service:80 (10.1.243.224:9080)
/admin frontend-service:80 (10.1.243.241:9080)
/api/media media-service:80 (10.1.243.207:9080)
/api/store store-service:80 (10.1.243.210:9080)
/api/user user-service:80 (10.1.243.213:9080)
/api/checkout checkout-service:80 (10.1.243.237:9080)
Annotations: ingress.kubernetes.io/rewrite-targert: /
Events: <none>
I can confirm that auth service’s api is working through cluster ip address.
$ curl 10.1.243.223:9080/health/ready
{"checks":[{"data":{},"name":"Auth Service Readiness Check","status":"UP"}],"status":"UP"}
But auth service’s api is not working through localhost
$ curl localhost/api/auth/health/ready
$
I want to expose APIs of multi-services through the localhost of vmware.
Please help me.
Thanks in advance.