Deploy the sys-info-web-env-view-server helm chart on Kubernetes
TypeScriptTo deploy a Helm chart on a Kubernetes cluster using Pulumi, you can use the
Chart
resource from the Kubernetes provider. This resource represents a Helm chart in its desired state on the cluster.The
Chart
resource requires a few properties to be set:chart
: The name of the Helm chart. In your case, it would besys-info-web-env-view-server
.version
: The version of the chart to be deployed if you have a specific version in mind.namespace
: The Kubernetes namespace in which the chart should be deployed. If not specified, it defaults to thedefault
namespace.repo
: The repository where the chart is hosted if it's not a locally available chart.values
: An object representing any custom values you want to pass to the Helm chart, overriding its defaults.
Below is the Pulumi TypeScript program that declares and deploys the chart on the Kubernetes cluster:
import * as k8s from "@pulumi/kubernetes"; // Create a Kubernetes namespace (optional). const namespace = new k8s.core.v1.Namespace("app-ns", { metadata: { name: "sys-info-ns" }, }); // Deploy the helm chart into the cluster. const chart = new k8s.helm.v3.Chart("sys-info-chart", { chart: "sys-info-web-env-view-server", // Name of the Helm chart version: "1.0.0", // Version of the Helm chart, specify your desired version namespace: namespace.metadata.name, // Kubernetes namespace // Add any custom values for your Helm chart here. values: { // Example: These values would be specific to your Helm chart configuration. // service: { // type: "LoadBalancer", // port: 80, // }, }, // (Optional) Set the repository if the chart is not from the default Helm repo // repo: "http://my-helm-chart-repo/", }); // Export the Namespace name and the Service endpoint of the `sys-info-web-env-view-server` chart export const namespaceName = namespace.metadata.name; export const serviceEndpoint = chart.getResourceProperty( "v1/Service", "sys-info-service", "status" ).then(status => status.loadBalancer.ingress[0].ip);
This program does the following:
- It imports the necessary Pulumi Kubernetes package.
- It (optionally) creates a new Kubernetes namespace where the Helm chart will be deployed.
- It declares a new
Chart
resource which Pulumi will use to ensure the Helm chart is deployed to the Kubernetes cluster matching the specifiedchart
,version
, andvalues
. - Finally, the program exports the namespace's name and anticipates the service endpoint by looking up the
Service
resource that would typically be created by the Helm chart (you would modifysys-info-service
to match the actual service name within the Helm chart).
To run the above Pulumi program, you need to have the Pulumi CLI installed and configured for access to your Kubernetes cluster. Place the above code in a file named
index.ts
within your Pulumi project directory.Keep in mind that you need to replace the chart name, version, repository (if applicable), and custom values with the ones that are appropriate for your specific Helm chart. If you are not sure about any of these values, you could refer to the Helm chart's documentation or its repository for guidance.