1. Deploy the elastic-apm-server helm chart on Opensshift

    TypeScript

    Deploying an Elastic APM Server via Helm on OpenShift can be accomplished with Pulumi using the kubernetes.helm.v3.Chart resource. The Chart resource allows you to deploy a Helm chart from a repository, with the ability to customize it using values provided inline or from a file.

    Here's a step-by-step explanation and a Pulumi TypeScript program to deploy the elastic-apm-server Helm chart on OpenShift.

    1. Setting Up the Pulumi Program: We begin by importing the necessary Pulumi and Kubernetes packages.
    2. Kubernetes Configs: Configure the Kubernetes provider to connect to your OpenShift cluster. This requires you to have access to your OpenShift kubeconfig file, and that your context is set correctly to target your OpenShift cluster.
    3. Helm Chart Deployment: We use the Chart resource from the @pulumi/kubernetes/helm/v3 package to deploy our chart.

    The provided program assumes that you have your OpenShift cluster running and the kubeconfig file set up correctly to allow Pulumi to interact with your cluster.

    import * as k8s from "@pulumi/kubernetes"; // Step 1: Create a provider resource that specifies the details of your OpenShift cluster. const openshiftProvider = new k8s.Provider("openshift-k8s", { // You may omit the kubeconfig property if you have it setup in environment // or it defaults to "~/.kube/config". This should point to your OpenShift cluster's // kubeconfig file. kubeconfig: process.env.KUBECONFIG, }); // Step 2: Deploy the Helm chart for elastic-apm-server. const elasticApmServerChart = new k8s.helm.v3.Chart("elastic-apm-server", { // Specify the chart, version, and repository. chart: "elastic-apm-server", version: "7.10.0", // Replace with the desired chart version fetchOpts: { repo: "https://helm.elastic.co", }, // Any additional customization of the Helm deployment can be specified in `values`. values: { // For example, if you need to set custom values, you can specify them like this: // serviceAccount: { // create: true, // name: "elastic-apm-server-service-account", // }, }, }, { provider: openshiftProvider }); // Exporting the service endpoint for the APM server export const apmServerEndpoint = elasticApmServerChart.getResourceProperty( "v1/Service", "elastic-apm-server", "status" ).apply(status => status.loadBalancer.ingress[0].ip || status.loadBalancer.ingress[0].hostname);

    Let's go over some details:

    • The elasticApmServerChart is an instance of Chart, where we define the Helm chart we want to deploy. Make sure to provide the correct chart name and version.
    • The repo is the Helm chart repository URL where the elastic-apm-server Helm chart is hosted.
    • In the values property, you may override default chart values or set additional values as required by the chart.
    • You can choose to customize the default values of the Helm chart by providing your desired configuration in the values property. This configuration follows the chart's structure, which can usually be found in the chart's values.yaml file or in its documentation.
    • We specify openshiftProvider as the provider to ensure this deployment targets the Openshift cluster.

    The last part is an optional export. It captures the resulting service endpoint after the Helm chart is deployed. This will output the IP or hostname where the APM server is accessible. Note that the actual service might not have a loadBalancer by default. Adjust the resource property getter accordingly based on your configuration.

    Remember to replace the placeholder values like the chart version with the actual values suitable for your deployment. Make sure you are referencing the correct Helm chart for the elastic-apm-server.

    Run the program with Pulumi CLI commands:

    1. Create a new Pulumi project with pulumi new.
    2. Add this code to the index.ts file in your Pulumi project.
    3. Ensure your environment is set up for OpenShift access (the KUBECONFIG environment variable or default kubeconfig should point to your Openshift cluster's configuration).
    4. Run pulumi up to deploy your changes.