I am trying to expose my application inside the AKS cluster using ingress:
It creates a service and an ingress but somehow does not assign an address to the ingress. What could be a possible reason for this?
apiVersion: apps/v1
kind: Deployment
metadata:
name: dockerdemo
spec:
replicas: 1
selector:
matchLabels:
app: dockerdemo
template:
metadata:
labels:
app: dockerdemo
spec:
nodeSelector:
"kubernetes.io/os": linux
containers:
– name: dockerdemo
image: devsecopsacademy/dockerapp:v3
env:
– name: ALLOW_EMPTY_PASSWORD
value: "yes"
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 250m
memory: 256Mi
ports:
– containerPort: 80
name: redis
apiVersion: v1
kind: Service
metadata:
name: dockerdemo-service
spec:
type: ClusterIP
ports:
- port: 80
selector:
app: dockerdemo
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress15
annotations:
kubernetes.io/ingress.class: addon-http-application-rounting
spec:
rules:
- host: curefirsttestapp.cluster15-dns-c42b65ee.hcp.westeurope.azmk8s.io
http:
paths:- path: /
pathType: Prefix
backend:
service:
name: dockerdemo-service
port:
number: 80
- path: /
2
Answers
Well, first make sure your application is up and functionning inside your K8s Cluster using a port-forword to your localhost
if app is reachable and your call are getting back 200 Status, you can now move to the ingress part:
Add a DNS record in your DNS zone which maps your
domain.com
to ingress controller$EXTERNAL_IP
Take a look at the ingress you created for your
$SERVICE
domain.com
, otherwise we’ll need further debugging.Make sure you have an ingress controller deployed. This is a load balancer service which can have either a public or private ip depending on your situation.
Make sure you have an ingress definition which has a rule to point to your service. This is the metadata which will tell your ingress controller how to route requests to its ip address. These routing rules can contain how to handle paths like
strip
,exact
, etc….