How to configure an endpoint on AKS ingress controller (ngnix)?

Be The Code 86 Reputation points
2021-09-14T02:52:51.09+00:00

Attempting to configure a 'dummy' endpoint (in the future will be a valid endpoint but the dummy is just a placeholder for now), on the AKS ingress controller. What would be the ideal way to accomplish that? Thanks in advance.

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
1,855 questions
0 comments No comments
{count} votes

Accepted answer
  1. SRIJIT-BOSE-MSFT 4,326 Reputation points Microsoft Employee
    2021-09-15T12:23:19.073+00:00

    @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,

    1. Create a Dockerfile with the following content:
      FROM nginx  
      
      EXPOSE 80
      RUN echo "This is a dummy website" > /usr/share/nginx/html/index.html
    2. Build the container image using docker build -t <your-repository>/<image-name>:<tag> /path/to/folder/with/Dockerfile
    3. Push the container image to your repository using docker push <your-repository>/<image-name>:<tag>
    4. Create a Deployment using the image with kubectl create deploy $DeploymentName --image <your-repository>/<image-name>:<tag> -n <namespace>
    5. Expose the Deployment using kubectl expose deploy $DeploymentName --name $ServiceName --port 80
    6. Add the following under spec.rules of your Ingress resource.
          - http:  
           paths:  
           - path: <your-ingress-path>  
             pathType: Prefix  
             backend:  
               service:  
                 name: $ServiceName  
                 port:  
                   number: 80  
      
      When you have your final Service later, you can simply change $ServiceName with the desired Service name and the port.number with the appropriate value, using kubectl 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.

    0 comments No comments

0 additional answers

Sort by: Most helpful