Deploy the NGINX Ingress Controller

To deploy the NGINX Ingress Controller in an Azure Kubernetes Service (AKS) cluster using the Helm chart with Pulumi and retrieve the LoadBalancer IP of the ingress controller, you can follow these steps. I'll also mention some optimizations that can be useful for production environments, such as ensuring resource limits and using stable versions of Helm charts.

Write Pulumi Code to Deploy NGINX Ingress Controller

The code will deploys the NGINX Ingress Controller using the official Helm chart.

import * as k8s from "@pulumi/kubernetes";
import { config } from "../config";

export const nginxIngressController = (k8sProvider) => {
//   // Deploy the NGINX Ingress Controller
  const nginxIngressController = new k8s.helm.v4.Chart("nginx-ingress-controller", {
    chart: "nginx-ingress-controller",
    namespace: config.ingressNamespace,
    version: "11.4.1", // Pin the Helm chart version for production stability
    repositoryOpts: {
        repo: "https://charts.bitnami.com/bitnami"
    },
    values: {
        controller: {
            service: {
                type: "LoadBalancer",
            }
        },
        resources: {
            limits: {
                cpu: "500m",
                memory: "512Mi", // Set resource limits for production optimization
            },
            requests: {
                cpu: "250m",
                memory: "256Mi",
            },
        }
    }
  }, { provider: k8sProvider });

  return nginxIngressController.resources;

}

Explanation of the Code:

  • We deploy the NGINX Ingress Controller using the Helm chart from Bitnami package for NGINX Ingress Controller

  • We specify the service.type as LoadBalancer so that Azure will provision a public IP address for the ingress controller.

  • Resource Limits: In production environments, it is essential to define resource limits for CPU and memory to ensure that the ingress controller doesn't consume excessive resources and cause issues in the cluster.

  • Versioning: It's a best practice to pin the Helm chart to a specific version (e.g., 1.11.2) to avoid unexpected behavior due to future updates. This ensures stability in production environments.

From the index.ts file, you will modify the code to deploy Nginx Ingress Controller to the AKS cluster:

Now, you can deploy your AKS cluster and the NGINX ingress controller with Pulumi:

Verify NGINX Ingress Controller

Once the deployment is finished, you can verify that the NGINX ingress controller has been successfully deployed and is up and running:

Last updated