im a bit new with deployments to kuberentes but to summarize, im trying to deploy my laravel API to kuberentes via digital ocean.
I’ve setup all the nitty gritty to get my laravel api dockerized, in an image and deployed to a pod. Everything gets deployed nicely, (My api and sql)
When i access my backend api via the host (/), i see my index page which is good. But when i try to access my /api page.
I get the (Not found page)
I’m a bit confused on why this happens since my index page / works fine and i see everything but my api endpoints are not accessible.
A quick side note is that the (/) page that shows is from the routes/web.php route.
And now i want to access my api endpoints which are in the /routes/api.php
Would appreciate if anyone has some advise on why i might be getting this.
This is my deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend
spec:
replicas: 1
selector:
matchLabels:
app: backend
template:
metadata:
labels:
app: backend
spec:
containers:
- name: backend
image: my_image
ports:
- containerPort: 80
env:
- name: APP_ENV
value: "production"
- name: APP_KEY
value: "some_key"
This is my ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: backend-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- host: "my host ip"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: backend
port:
number: 80
And my service.yaml
apiVersion: v1
kind: Service
metadata:
name: backend
spec:
selector:
app: backend
ports:
- protocol: TCP
port: 80
targetPort: 80
type: ClusterIP
Did you try adding a 2nd path to your Ingress e.g.
- path: /api
pathType: Prefix
backend:
service:
name: backend
port:
number: 80
2