Deploy the wazuh helm chart on Kubernetes
TypeScriptDeploying a Helm chart with Pulumi on a Kubernetes cluster involves several steps. Below is an outline of what we are going to do:
- Import necessary Pulumi and Kubernetes packages.
- Initialize a new Pulumi Kubernetes provider.
- Create a namespace for the Wazuh deployment (optional step to keep things organized).
- Use the
Chart
class to deploy the Wazuh Helm chart into the specified namespace.
First, you will need to install the required Pulumi packages. This can be done using the following commands:
$ npm install @pulumi/pulumi $ npm install @pulumi/kubernetes
Here's the Pulumi program in TypeScript that deploys the Wazuh Helm chart to an existing Kubernetes cluster:
import * as pulumi from "@pulumi/pulumi"; import * as k8s from "@pulumi/kubernetes"; // Create a Kubernetes provider instance using the current context from kubeconfig. const provider = new k8s.Provider("k8s-provider", { kubeconfig: pulumi.Config.require("kubeconfig"), }); // Define the namespace where Wazuh will be installed. const namespace = new k8s.core.v1.Namespace("wazuh-namespace", { metadata: { name: "wazuh" }, }, { provider: provider }); // Deploy Wazuh Helm chart. const wazuhChart = new k8s.helm.v3.Chart("wazuh", { repo: "wazuh", // The repository name for the Helm chart. chart: "wazuh", // The name of the chart. namespace: namespace.metadata.name, // The namespace into which the chart will be deployed. version: "3.13.3", // The version of the chart. // Values to pass to the Helm chart - these would be the same as what you // would put into a 'values.yaml' or pass with '--set' when installing with Helm // directly. The specific values would depend on Wazuh's chart documentation. values: { // Add your custom values here, for example: // elasticsearch: { // heapSize: "1g" // }, // kibana: { // elasticsearchURL: "http://elasticsearch:9200" // }, }, }, { provider: provider }); // Export the name of the namespace export const namespaceName = namespace.metadata.name;
Remember to replace the
values
object with custom configurations as per the Wazuh Helm chart documentation. These values override the default settings on the Helm chart, just like how you would do with avalues.yaml
file or the--set
command when using Helm directly.This script does the following:
- It makes use of
@pulumi/kubernetes
package to interact with Kubernetes resources. - It creates a Kubernetes namespace named
wazuh
. - It deploys the Wazuh application using the Wazuh Helm chart found in the
wazuh
repository, with a specified version. Adjust therepo
andchart
fields if the Wazuh Helm repository or chart names are different.
When deploying this in your environment, make sure your Pulumi configuration (
Pulumi.<stack-name>.yaml
) includes thekubeconfig
key with the contents of your kubeconfig file or ensure your Kubernetes configuration context is set up correctly.To run this program, save it in a file named
index.ts
, ensure you have Pulumi installed and configured, then execute the following commands in your terminal:$ pulumi stack init dev # Replace 'dev' with a stack name of your choice $ pulumi up # Deploy the Wazuh Helm chart into your Kubernetes cluster
This will start the deployment process, and you will be prompted to review the changes before they are applied to your cluster. Once you confirm, Pulumi will proceed with deploying the specified resources.