Deploy the postgresql-persistent helm chart on Opensshift
TypeScriptTo deploy the
postgresql-persistent
Helm chart on OpenShift using Pulumi, we'll leverage thekubernetes.helm.v3.Chart
resource from the Pulumi Kubernetes provider. This resource allows you to deploy Helm charts into a Kubernetes cluster.The steps to use this resource are as follows:
- Import the required Pulumi and Kubernetes packages.
- Initialize a new Kubernetes provider instance if needed (for example, if you're deploying to a cluster that's not your current context).
- Create a new Helm chart resource, using the
Chart
resource class. - Pass the appropriate chart details such as chart name, version, and any custom values that are needed for the
postgresql-persistent
chart.
Below is the TypeScript program that performs these steps:
import * as k8s from '@pulumi/kubernetes'; // This assumes you have a configured OpenShift cluster and your kubeconfig is properly set up. // Otherwise, you would need to create a kubernetes provider and pass the kubeconfig details. const openshiftProvider = new k8s.Provider('openshift-provider', { // Provide additional configuration if not relying on the default kubeconfig. }); // Deploy the 'postgresql-persistent' Helm chart into the OpenShift cluster. const postgresChart = new k8s.helm.v3.Chart('postgresql-persistent', { repo: 'https://charts.bitnami.com/bitnami', // Replace with the correct Helm repo if different. chart: 'postgresql', version: '10.3.11', // Specify the version you want to deploy. // Override default configuration values by specifying the `values` property. // This is where you would ensure persistence is enabled and configure other chart settings. values: { persistence: { enabled: true, size: '8Gi', // Specify the persistent volume size. }, // Add any additional custom values your chart might require. } }, { provider: openshiftProvider }); // Optional: Export the status of the Helm release to access it later, e.g., to check if it's ready. export const postgresChartStatus = postgresChart.status;
In this program:
- We import the
@pulumi/kubernetes
package, which includes the classes for interacting with Kubernetes resources through Pulumi. - The
openshiftProvider
is an instance of the Kubernetes Provider class. (The configuration here is commented out, as it would only be needed if you are not using the default kubeconfig location). - We then declare a Helm chart using
new k8s.helm.v3.Chart
. We name the chartpostgresql-persistent
and configure it with our chosen repository, chart name, and version. - In the
values
property, we provide the necessary customization to ensure the PostgreSQL chart has persistent storage enabled. - Finally, we export the status of the Helm release so that we can query Pulumi for the release's status later on. This could be useful for automation or simply to verify deployment success.
When you run this Pulumi program, it communicates with the OpenShift Kubernetes API to deploy the specified Helm chart with the given configuration. Once deployed, you can manage the PostgreSQL instance through Kubernetes tooling, aligned with standard Helm chart practices.