Deploy the cubefs helm chart on Kubernetes
TypeScriptTo deploy the CubeFS Helm chart on Kubernetes using Pulumi, you can use the
kubernetes.helm.v3.Chart
resource. This resource allows you to deploy Helm charts into your Kubernetes cluster. Helm is a package manager for Kubernetes, which uses a packaging format called charts. A chart is a collection of files that describe a set of Kubernetes resources.Here is how you can define the deployment in Pulumi with TypeScript:
- First, ensure that you have Pulumi installed and set up together with kubectl configured to access your Kubernetes cluster.
- Create a new directory for your Pulumi project and execute
pulumi new typescript
in your terminal to create a new TypeScript project.
In your Pulumi TypeScript program:
- Import the necessary libraries.
- Define the CubeFS Helm chart using the
kubernetes.helm.v3.Chart
resource, specifying the chart name, any custom values in thevalues
object, and the namespace to deploy in if notdefault
.
Below is the TypeScript program that demonstrates how to deploy the CubeFS Helm chart:
import * as kubernetes from "@pulumi/kubernetes"; // Create a new instance of the CubeFS Helm chart. // Note: Replace `CHART_VERSION` with the version number of the CubeFS Helm chart that you wish to deploy. // The Helm chart `repo` should be the URL of the Helm repository that contains the CubeFS chart. // Also replace `NAMESPACE` with the Kubernetes namespace where you want to deploy the chart, if it's different from `default`. const cubefsChart = new kubernetes.helm.v3.Chart("cubefs", { chart: "cubefs", version: "CHART_VERSION", namespace: "NAMESPACE", // If not provided, the chart will be installed in the 'default' namespace. fetchOpts: { repo: "https://charts.cubefs.io", }, // If there are custom values required, specify them as an object below. For example: // values: { // key: "value", // } }); // Export the base URL that the application will be accessible on. // Ensure your service is of the type LoadBalancer or NodePort to be able to access it externally. // This may vary based on your CubeFS Helm chart's service configuration. export const cubeFsUrl = cubefsChart.getResourceProperty("v1/Service", "cubefs-service", "status").apply(status => { const ingress = status.loadBalancer?.ingress[0]; if (ingress) { if (ingress.ip) return `http://${ingress.ip}`; if (ingress.hostname) return `http://${ingress.hostname}`; } return "LoadBalancer ingress is not yet available"; });
Before running the
pulumi up
command to deploy the stack, make sure the Helm chart's version (CHART_VERSION
) and the namespace (NAMESPACE
) are correctly set as per your Kubernetes cluster and Helm chart details.This program is written assuming you're familiar with Pulumi, TypeScript, and Kubernetes. It creates the Helm chart for CubeFS within Kubernetes and exports the URL that CubeFS will be available at once it is deployed.
The
cubefsChart.getResourceProperty
method fetches properties from the deployed Kubernetes resources, in this case from a Service. If the CubeFS chart creates a service of type LoadBalancer, the external IP or hostname assigned by the load balancer is exported ascubeFsUrl
.Before executing this Pulumi program, you will need to make sure that your Kubernetes cluster is properly configured in your environment. Pulumi uses the configuration from kubectl, so running
kubectl config current-context
should show the context of the Kubernetes cluster you intend to deploy to.