Deploy the mogenius-metrics-server helm chart on Kubernetes
TypeScriptTo deploy the
mogenius-metrics-server
Helm chart on a Kubernetes cluster using Pulumi, we can use thekubernetes.helm.v3.Chart
resource from the Pulumi Kubernetes provider. This resource allows you to deploy Helm charts to a Kubernetes cluster.Here is a breakdown of the steps included in the program:
-
Import the necessary libraries: We'll import Pulumi Kubernetes SDK to interact with Kubernetes resources.
-
Create a new Helm Chart resource: Using
new kubernetes.helm.v3.Chart
we will deploy themogenius-metrics-server
chart. -
Chart Arguments: When creating the Helm Chart resource, we'll need to specify the
chart
name,version
,repo
,namespace
(optional), and any other configurations if required for the metrics server viavalues
. If you don't specifyrepo
, make sure that you have added it to your local Helm repositories withhelm repo add
, or else you must provide arepo
option. -
Launching the Program: Running the Pulumi program will deploy the Helm chart to your Kubernetes cluster. The program assumes that you've already configured Pulumi to use your Kubernetes cluster, either via a kubeconfig file or other means.
Here's the TypeScript program that accomplishes this:
import * as kubernetes from "@pulumi/kubernetes"; // Deploy mogenius-metrics-server chart using the kubernetes.helm.v3.Chart class. const metricsServerChart = new kubernetes.helm.v3.Chart("mogenius-metrics-server", { // If the Helm chart is hosted on a specific Helm repository, specify the `repo` option. // Change REPO_URL to the URL of the repository where the chart is located. // Otherwise, ensure that the repository is added to Helm with `helm repo add` if // using a chart from a known public repository already added to helm. repo: "REPO_URL", // Replace REPO_URL with the actual repository URL. chart: "metrics-server", // Name of the chart (adjust if the name differs). // Optional: Specify the version of the chart. version: "CHART_VERSION", // Replace CHART_VERSION with the version you want to deploy. // Optional: Specify namespace where the chart will be installed. namespace: "kube-system", // Change or remove if you want a different namespace or the default. // Specify any custom values for the chart. This is how you can override chart values. values: { // For example, if you need to set specific values, uncomment and configure the parameters below. // replicaCount: 1, // image: { // repository: "mogenius/metrics-server", // tag: "LATEST_TAG", // Replace LATEST_TAG with the desired image tag. // }, // Other custom values that the chart requires. }, }); // Export the Chart name of the deployed Metrics Server export const metricsServerName = metricsServerChart.getResourceProperty("v1/Service", "mogenius-metrics-server-metrics-server", "metadata").apply(m => m.name);
When running this Pulumi program, it will use your configured Kubernetes context to deploy the
mogenius-metrics-server
Helm chart onto your cluster. Remember to replace"REPO_URL"
and"CHART_VERSION"
with the repository URL and chart version specific tomogenius-metrics-server
, and uncomment or add thevalues
configuration as per the chart's requirements.To apply this configuration, save the code to a file named
index.ts
and runpulumi up
in the same directory. The command will create a preview of the deployment and, upon confirmation, apply the changes to your Kubernetes cluster.Please replace
REPO_URL
andCHART_VERSION
with the appropriate values for themogenius-metrics-server
chart before executing the program. If you don't have the exact details, you'll need to refer to the Helm chart's repository for the required version and values.-