1. Deploy the simple-nginx helm chart on Azure Managed Openshift Service

    TypeScript

    To deploy the simple-nginx Helm chart on an Azure Managed OpenShift Service using Pulumi, we'll go through the following key steps:

    1. Set up an Azure Managed OpenShift cluster.
    2. Install the simple-nginx Helm chart on the OpenShift cluster.

    Prerequisites

    Before starting, you should have the following prerequisites in place:

    • Pulumi CLI installed and configured with appropriate Azure credentials.
    • Node.js and npm installed to run the Pulumi TypeScript program.
    • An Azure account with the necessary permissions to create resources.

    Step 1: Setting Up an Azure Managed OpenShift Cluster

    We'll begin by creating an instance of an Azure Managed OpenShift cluster (OpenShiftManagedCluster), which is a fully managed service provided by Azure. This will create the underlying Kubernetes cluster that OpenShift runs on.

    Step 2: Installing the simple-nginx Helm Chart

    Once the OpenShift cluster is provisioned, we can deploy the simple-nginx Helm chart on it using the Chart resource from Pulumi's Kubernetes provider. This is a wrapper around Helm's capabilities, which allows us to define Helm releases declaratively in our Pulumi program.

    Below is the TypeScript program that performs these steps.

    import * as pulumi from "@pulumi/pulumi"; import * as azure_native from "@pulumi/azure-native"; import * as k8s from "@pulumi/kubernetes"; // Use an existing resource group or create a new one const resourceGroupName = "rg-openshift-example"; const resourceGroup = new azure_native.resources.ResourceGroup(resourceGroupName); // Create an Azure Managed OpenShift cluster const managedClusterName = "openshift-cluster-example"; const managedOpenShiftCluster = new azure_native.containerservice.OpenShiftManagedCluster(managedClusterName, { resourceGroupName: resourceGroup.name, location: resourceGroup.location, openShiftVersion: "4.6", // Specify your desired OpenShift version networkProfile: { vnetCidr: "10.0.0.0/8", }, masterPoolProfile: { count: 3, // Set the number of master nodes vmSize: "Standard_D4s_v3", // Choose the appropriate VM size }, agentPoolProfiles: [{ name: "agentpool", count: 3, vmSize: "Standard_D4s_v3", role: "Compute", }], // Other necessary configurations... }); // Kubernetes provider to interact with the OpenShift cluster const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig: managedOpenShiftCluster.config.apply(c => c.kubeconfig), }); // Deploy the `simple-nginx` Helm chart using the Pulumi Kubernetes provider const nginxChart = new k8s.helm.v3.Chart("simple-nginx", { chart: "nginx", version: "1.12.0", // Specify the chart version you want to deploy fetchOpts: { repo: "https://charts.bitnami.com/bitnami", // Specify the Helm chart repository }, }, { provider: k8sProvider }); // Export the public IP address of the nginx service (if service is of type LoadBalancer) export const nginxPublicIp = nginxChart.getResourceProperty("v1/Service", "simple-nginx-nginx", "status") .apply(status => status.loadBalancer.ingress[0].ip);

    In the program:

    • We create a new resource group to hold our Azure OpenShift cluster, unless we use an existing one.
    • We instantiate the OpenShiftManagedCluster resource, which will provision an OpenShift cluster in Azure using the azure_native.containerservice module. You can customize the openShiftVersion, vmSize, and number of nodes (count) as per your requirements.
    • We create a provider of type k8s.Provider that uses the kubeconfig from the newly created OpenShift cluster to interact with it.
    • We use the k8s.helm.v3.Chart resource to define the Helm release for simple-nginx. The fetchOpts tells Pulumi where to find the Helm chart.
    • Finally, we export the public IP address of the nginx service which would be useful to access our nginx server if the service type is LoadBalancer.

    Before executing the program with pulumi up, you should ensure that your Pulumi stack is selected and configured appropriately for the desired Azure region and other settings.

    The artifacts of this program (i.e., the Managed OpenShift cluster and nginx deployment) can be viewed in the Azure portal once they are provisioned.