Deploy the shortlink-api-graphql helm chart on Opensshift
TypeScriptTo deploy the
shortlink-api-graphql
Helm chart on an OpenShift cluster using Pulumi, you will primarily use thekubernetes.helm.v3.Chart
resource from the Pulumi Kubernetes provider. This resource allows you to specify a Helm chart to deploy along with configurations such as the namespace, values, repository, and chart version.Before using the code below, you need to ensure that you have Pulumi installed and set up for TypeScript, and that you have access configured to your OpenShift cluster, typically through the
kubectl
configuration.The general steps we will perform in the program include:
- Importing necessary packages.
- Specifying the Helm chart details like name, repository, and any values that need to be overridden.
- Invoking the
Chart
resource to deploy the Helm chart.
Here is the TypeScript program to perform this deployment:
import * as k8s from "@pulumi/kubernetes"; // Create a new Helm Chart for `shortlink-api-graphql`. const shortlinkApiGraphqlChart = new k8s.helm.v3.Chart("shortlink-api-graphql", { // Specify the repository for the Helm chart. repo: "your_helm_chart_repo", // Replace with your chart's repository // Specify the Helm chart name. chart: "shortlink-api-graphql", // You can specify a particular version of the chart here if needed // version: "x.y.z", // Define the values that need to be overridden. // This is an equivalent to the helm CLI's --set or -f for a values YAML file. values: { // Replace these with actual configurations needed for 'shortlink-api-graphql' service: { type: "ClusterIP", }, replication: { count: 3, }, // Add any other values that you need to customize }, // Assuming OpenShift is correctly configured, the following namespace will be used. // If the namespace is not created, either create it beforehand or set the `createNamespace` property to `true`. namespace: "shortlink-namespace", }); // Optional: Export the chart metadata export const chartName = shortlinkApiGraphqlChart.metadata.name; export const chartVersion = shortlinkApiGraphqlChart.metadata.version; // Run `pulumi up` to deploy the chart and `pulumi stack export` to get these details.
Explanation:
-
Importing Packages: We import the Kubernetes package from Pulumi, which provides us the necessary resources to interact with Kubernetes clusters.
-
Creating a Helm Chart Resource: We create a new
Chart
resource by providing it a unique name within our Pulumi program, and a configuration object. -
Chart Repository and Name: We specify the repository where our Helm chart exists and the name of the chart which we want to deploy.
-
Chart Values: We provide any custom values that are required for the chart deployment. These values will override the defaults specified in the chart's
values.yaml
. -
Namespace: The namespace helps in organizing and securing the resources inside a Kubernetes cluster. If the namespace doesn't exist, you can create it beforehand or set the
createNamespace
property within the chart's options. -
Exporting Metadata: Optionally, we can export metadata such as the chart name and version for reference outside of the Pulumi program.
Be sure to replace the placeholder values such as the repository URL (
your_helm_chart_repo
) andvalues
configuration with the actual values for yourshortlink-api-graphql
Helm chart.Once you have created this Pulumi program, run
pulumi up
in your terminal. Pulumi will prompt you to review the changes before it applies them to your OpenShift cluster, allowing theshortlink-api-graphql
application to be deployed.