Deploy the eolo-planner helm chart on Kubernetes
TypeScriptDeploying a Helm chart on Kubernetes using Pulumi involves several steps. First, we need to set up Pulumi with the Kubernetes provider. This allows Pulumi to interact with our Kubernetes cluster to manage resources. When using Helm with Kubernetes, you typically have to include the
Chart
resource from the@pulumi/kubernetes
package. This package allows us to work with Kubernetes resources in a declarative way using Pulumi.Here is a step-by-step guide to deploying the
eolo-planner
Helm chart:- Initialize a new Pulumi project in TypeScript, if you haven't already.
- Install the necessary Pulumi Kubernetes package using npm or yarn.
- Create a new TypeScript file for defining the resources you're going to deploy.
In this example, we will:
- Use the
Chart
resource to deploy theeolo-planner
Helm chart. - Assume that you have already configured your Pulumi to work with the desired Kubernetes cluster through the
kubeconfig
file. - Specify any necessary chart values upon instantiation or rely on the chart's default values.
Let's walk through the TypeScript Pulumi code to accomplish this:
import * as k8s from "@pulumi/kubernetes"; // The following code assumes that your Pulumi configuration is set up // to point to the appropriate Kubernetes cluster. const eoloPlannerChart = new k8s.helm.v3.Chart("eolo-planner", { // Specify the Helm chart repository and chart name. chart: "eolo-planner", // If the Helm chart is from a custom repository, specify it here. // For instance: // repo: "http://my-helm-chart-repo.com/", // Omit `version` to use the latest chart version or // specify a version string to pin to a specific chart version. // version: "1.2.3", // You can provide custom values for the Helm chart here // Below is an example of custom values. The actual values would depend // on the 'eolo-planner' chart in question. // values: { // service: { // type: "LoadBalancer", // }, // replicaCount: 2, // }, // Namespace where the Helm chart should be deployed. // Omit to use the default namespace or specify if needed. // namespace: "eolo-planner-ns", }, { provider: /* Provide a specific K8s Provider if necessary */ }); // To interact with a resource created by the Helm chart, you can query it like so: // This could be a Kubernetes Service, Deployment, StatefulSet, etc., depending on what the Helm chart provides. const service = eoloPlannerChart.getResource("v1/Service", "eolo-planner-svc");
Understanding the Components of the Code:
- We import the Kubernetes package from Pulumi which allows us to write Kubernetes resources using TypeScript.
- We instantiate a new Helm chart resource with the
Chart
class, specifying various options:chart
is the name of the Helm chart we want to deploy.repo
is the repository URL where the Helm chart is located (commented out here since it's for a custom repository).version
is the specific chart version to deploy (also commented out).values
is an optional set of overrides to the default chart values.namespace
is the namespace to which the chart should be deployed (commented out to use the default namespace).
- Optionally, we pass a provider instance to support scenarios where you might be managing resources in more than one cluster.
getResource
is used to retrieve a resource created by the Helm chart, if you need to reference it or interact with it outside of the chart.
Pulumi will use the information from the provided Kubernetes config (typically located at
~/.kube/config
or specified via theKUBECONFIG
environment variable) to communicate with your Kubernetes cluster and deploy the Helm chart when you runpulumi up
.Next steps would involve running this TypeScript code with Pulumi:
pulumi up
This command will start the deployment. Pulumi will query your Kubernetes cluster, compare the desired state defined in your code (the Helm chart) with the actual state of your cluster, and execute the necessary steps to make your cluster match the desired state.
After the deployment,
eolo-planner
services and other resources can be interacted with usingkubectl
or Pulumi's query interfaces, letting you list, describe, or manage those resources as needed.