1. Deploy the workload-api helm chart on Opensshift


    To deploy a Helm chart on an OpenShift cluster using Pulumi, you need to do several things: set up the OpenShift cluster, install and configure helm, and then use Pulumi to deploy the chart. In the example below, I'm assuming that you already have an OpenShift cluster running and that you have the necessary permissions to deploy applications on it.

    Pulumi can deploy Helm charts on a Kubernetes cluster including OpenShift, which is essentially a specialized Kubernetes distribution. The following program will outline how to deploy a Helm chart named workload-api on an OpenShift cluster using Pulumi with TypeScript.

    Before running the Pulumi program, you need to have the following prerequisites met:

    1. pulumi CLI installed on your machine.
    2. kubectl and oc (OpenShift's CLI tool) configured to communicate with your OpenShift cluster.
    3. Credentials for your cluster (obtained from your cloud provider or OpenShift installation).
    4. Node.js and npm installed to run TypeScript Pulumi code.

    Here’s a step-by-step Pulumi TypeScript program that achieves deployment of the workload-api Helm chart:

    import * as k8s from "@pulumi/kubernetes"; // Replace with the appropriate values for your OpenShift cluster. const config = { // The namespace where the chart will be deployed. namespace: "default", // The version of the Helm chart to deploy. Specify a version to ensure your deployment does not receive unintended upgrades. chartVersion: "1.2.3", // Helm chart values to customize your deployment. values: { // This is an example of setting a value for the Helm chart. Update these fields based on the values // that are applicable to the 'workload-api' Helm chart that you wish to deploy. service: { type: "ClusterIP" } } }; // Assuming you have added the Helm repository that contains the 'workload-api' Helm chart. // e.g., `helm repo add my-repo <repo-url>` and then `helm repo update`. const workloadApiChart = new k8s.helm.v3.Chart("workload-api", { chart: "workload-api", // The name of the chart in the Helm repo. version: config.chartVersion, // Specify the version of the chart to deploy. namespace: config.namespace, // Namespace where the chart will be deployed. values: config.values, // Values to configure your deployment. // When dealing with OpenShift, you might need to include additional settings or workarounds depending on // your chart's needs and OpenShift's security contexts or permissions. }); // Export the base URL where the service can be accessed, once it is deployed. // The exact way of obtaining this information depends on the specifics of the 'workload-api' Chart. export const serviceUrl = workloadApiChart.getResourceProperty( "v1/Service", "workload-api", "status" ).apply(status => status.loadBalancer.ingress[0].hostname);

    The @pulumi/kubernetes package gives us access to the Pulumi Kubernetes provider, which allows us to interact with Kubernetes resources including Helm charts.

    In the code snippet above, k8s.helm.v3.Chart is a Pulumi class that supports deploying Helm charts. We're creating an instance of this to deploy the workload-api chart. Adjustment of chart, version, namespace, and values might be needed according to your Helm chart's specifications and your OpenShift setup.

    Replace namespace, chartVersion, and the contents of values with the appropriate values for the Helm chart you wish to deploy and your specific configuration requirements.

    Lastly, the serviceUrl export assumes that your Helm chart creates a Kubernetes Service of type LoadBalancer which gets an ingress hostname that can be used to access the service. If your service uses a different type or method for external access, you'll need to adjust this export accordingly to retrieve the correct endpoint.

    To execute this Pulumi program:

    1. Save this code in a file named index.ts.
    2. Run npm install to install necessary packages.
    3. Execute pulumi up to preview and deploy the changes.

    Remember, the code above is designed based on the assumption that the workload-api chart expects certain values and that you have the required permissions in your cluster to create resources. The Helm chart might require more or different values depending on what services and resources it provisions. Always consult the documentation of the Helm chart you are using for its specific requirements.