Deploy the cadvisor helm chart on Kubernetes
TypeScriptTo deploy the
cadvisor
Helm chart on a Kubernetes cluster using Pulumi, we will use thekubernetes.helm.v3.Chart
class from the Pulumi Kubernetes Provider. This class allows us to deploy Helm charts in a Kubernetes cluster directly from Pulumi programs without using the Helm CLI externally.Before we begin, make sure you have:
- A Kubernetes cluster up and running.
kubectl
configured to interact with your cluster.- Helm binary installed if you need to fetch Helm charts from repositories that require authentication or if the charts are not packaged.
- Pulumi CLI installed and set up to manage your infrastructure.
Let's break down what the Pulumi program does:
- It declares a new Helm chart resource using the
kubernetes.helm.v3.Chart
class. - It specifies the repository and chart name for
cadvisor
. Therepo
parameter refers to the URL of the Helm chart repository, while thechart
parameter is the name of the chart in the repository. - The
version
parameter indicates the specific chart version you want to deploy. If not set, it will default to the latest version. - We set the
namespace
where we want to deploy thecadvisor
chart. If the namespace doesn't exist, it's created by Pulumi. Make sure to adjust this value according to your cluster setup.
Below is a Pulumi TypeScript program that accomplishes the deployment of the
cadvisor
Helm chart:import * as k8s from "@pulumi/kubernetes"; // Create a Kubernetes Namespace const namespace = new k8s.core.v1.Namespace("cadvisor-ns", { metadata: { // Specifying the name of the namespace name: "cadvisor", }, }); // Deploy the cadvisor Helm chart in the created Namespace const cadvisorChart = new k8s.helm.v3.Chart("cadvisor", { // Chart details chart: "cadvisor", version: "3.5.0", // replace with desired chart version namespace: namespace.metadata.name, fetchOpts:{ repo: "https://kubernetes-charts.storage.googleapis.com/", // This URL is just an example; replace it with the actual chart repo URL }, // Set values for the Helm chart as needed values: { // insert chart values here }, }, { dependsOn: [namespace] }); // Ensure the namespace is created before the Helm chart // Expose managed resources export const cadvisorNamespace = namespace.metadata.name; export const cadvisorChartName = cadvisorChart.metadata.name;
This program will create a
Namespace
calledcadvisor
and then deploy thecadvisor
Helm chart into that namespace. ThedependsOn
option ensures that the namespace is created before attempting to deploy the chart into it.After setting up this program, you would run
pulumi up
to apply the changes to your cluster. This command initiates Pulumi's deployment process, which shows you a preview of the resources that will be created and asks for confirmation before proceeding with the actual deployment. After confirming, Pulumi will reach out to your Kubernetes cluster and deploy thecadvisor
Helm chart into the specified namespace.For more information about deploying Helm charts with Pulumi and to understand the options you can specify in the
values
block for the Helm chart, you can consult the Pulumi documentation for Helm Charts.Please replace the
version
andrepo
values with the correct ones forcadvisor
. As of my knowledge cutoff in early 2023,https://kubernetes-charts.storage.googleapis.com/
was a common base URL for the official Helm stable repository. However, repository URLs can change, and you might need to point to a different repository where thecadvisor
chart is hosted.