Deploy the fluentd-kubernetes-daemonset helm chart on Kubernetes
TypeScriptDeploying a Helm chart to a Kubernetes cluster using Pulumi is a straightforward process. In this scenario, we will use the
Chart
resource from thekubernetes
package which is designed for Helm chart deployments. Thefluentd-kubernetes-daemonset
is a Helm chart by Fluentd that allows you to collect logs from your Kubernetes nodes and forward them to a specified backend.Here's a step-by-step guide to deploying the
fluentd-kubernetes-daemonset
Helm chart:-
Install Pulumi: Ensure that Pulumi CLI is installed on your machine. If it's not, please visit the Pulumi Installation Guide.
-
Configure Kubernetes: Ensure your
kubectl
is configured to communicate with your Kubernetes cluster. Pulumi uses the same configuration. -
Create a new Pulumi Project: If you haven't already, create a new Pulumi Project by running
pulumi new <template>
and choose a template that matches your preferred language and environment. -
Write the Deployment Code: We will use TypeScript to define the deployment. The Pulumi program below creates a new
Chart
resource for thefluentd-kubernetes-daemonset
. -
Deploy: Run
pulumi up
to deploy your chart.
Below is a TypeScript program that defines the deployment of the
fluentd-kubernetes-daemonset
:import * as k8s from "@pulumi/kubernetes"; const fluentdChart = new k8s.helm.v3.Chart("fluentd", { chart: "fluentd-kubernetes-daemonset", version: "0.12.1", // this is an example version, please use the current version fetchOpts:{ repo: "https://fluent.github.io/helm-charts", }, // Specify the values you want for your chart. values: { // Depending on the chart, you might need to fill out configuration values. // For fluentd-kubernetes-daemonset, you might configure the backend like this: // backend: { // type: "es", // es: { // host: "elasticsearch.default.svc.cluster.local" // } // } }, }); // Export the (likely empty) public service endpoint of the fluentd daemonset export const fluentdDaemonset = fluentdChart.getResource("v1/Service", "fluentd");
Explanation:
-
We import the
@pulumi/kubernetes
package which contains helpers for interacting with Kubernetes. -
We create a new Helm
Chart
resource using the class fromk8s.helm.v3
. The name "fluentd" is chosen arbitrarily and will be used as the name for resources Pulumi creates. -
chart
refers to the name of the Helm chart we want to deploy. -
version
is the version of the Helm chart you want to deploy. It’s important to pin the version for consistent deployments. -
fetchOpts.repo
is the repository URL where the Helm chart is located. -
values
will contain any configurations that are specific to this chart. These are the same values you would configure with avalues.yaml
file or with--set
flags during a manualhelm
command execution. -
Lastly, we export the
fluentdDaemonset
, which is the service resource associated with the Fluentd daemonset. ThegetResource
function is used here to fetch a service resource created by the Helm chart. If the Helm chart doesn't create a service or if you don't need to export it, you could omit this line.
After writing this code in your Pulumi project, running
pulumi up
would deploy the Fluentd daemonset to your Kubernetes cluster, which starts collecting logs according to the provided configuration.Remember to modify the
values
to match your specific configuration needs for the Fluentd daemonset. You can find out what values are configurable by looking at thefluentd-kubernetes-daemonset
chart's documentation.-