@Be The Code , Thank you for your question. You can make use of the NGINX Ingress default backend. The default backend is a service which handles all URL paths and hosts the nginx controller doesn't understand (i.e., all the requests that are not mapped with an Ingress).
Basically a default backend exposes two URLs:
/healthz that returns 200
/ that returns 404
This blog post details how you can customize your NGINX Ingress default backend.
However, if you want a specific dummy backend application to be available on a specific path using NGINX Ingress, you can simply create a Deployment with the dummy application's container image, expose it using a Service and mention the Service in spec.rules[].http.paths[].backend.service.name
of your Ingress resource.
For example,
- Create a
Dockerfile
with the following content:
EXPOSE 80FROM nginx
RUN echo "This is a dummy website" > /usr/share/nginx/html/index.html - Build the container image using
docker build -t <your-repository>/<image-name>:<tag> /path/to/folder/with/Dockerfile
- Push the container image to your repository using
docker push <your-repository>/<image-name>:<tag>
- Create a Deployment using the image with
kubectl create deploy $DeploymentName --image <your-repository>/<image-name>:<tag> -n <namespace>
- Expose the Deployment using
kubectl expose deploy $DeploymentName --name $ServiceName --port 80
- Add the following under
spec.rules
of your Ingress resource.
When you have your final Service later, you can simply change- http: paths: - path: <your-ingress-path> pathType: Prefix backend: service: name: $ServiceName port: number: 80
$ServiceName
with the desired Service name and theport.number
with the appropriate value, usingkubectl edit ingress
.
For more information Kubernetes Ingress please check here.
Disclaimer: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as convenient to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
Hope this helps.
Please "Accept as Answer" if it helped, so that it can help others in the community looking for help on similar topics.