1. Using kubernetes bitnami.com with pulsar.streamnative.io

    TypeScript

    To deploy an application on Kubernetes that uses Bitnami charts and StreamNative's Pulsar, you would typically follow these steps:

    1. Set up a Kubernetes cluster: You'd need a running Kubernetes cluster. You can create one using cloud providers like AWS, GCP, Azure, or others.

    2. Install Pulsar: Pulsar can be installed on Kubernetes using Helm charts provided by StreamNative.

    3. Deploy your application: The application pods would interact with Pulsar for messaging requirements.

    We will create a Pulumi program that sets up a Kubernetes cluster (assuming we are using GCP) and installs Pulsar using Bitnami Helm charts. Let’s break down the program into parts:

    • Import necessary libraries: We'll use the Pulumi GCP and Kubernetes libraries to create a cluster and deploy applications on it.

    • Create a GKE (Google Kubernetes Engine) cluster: Use GCP resources to set up a GKE cluster.

    • Install Pulsar using Helm Charts: After the cluster is created, we'll configure kubectl to interact with the cluster and then use a Helm chart to deploy Pulsar.

    Below is a Pulumi program written in TypeScript that demonstrates how to accomplish this. Remember, you'll need to have Pulumi installed and configured with the appropriate cloud provider credentials.

    import * as pulumi from "@pulumi/pulumi"; import * as gcp from "@pulumi/gcp"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Create a GKE cluster on GCP const cluster = new gcp.container.Cluster("pulumi-cluster", { initialNodeCount: 2, minMasterVersion: "latest", nodeVersion: "latest", location: "us-central1-a", nodeConfig: { machineType: "n1-standard-1", oauthScopes: [ "https://www.googleapis.com/auth/compute", "https://www.googleapis.com/auth/devstorage.read_only", "https://www.googleapis.com/auth/logging.write", "https://www.googleapis.com/auth/monitoring", ], }, }); // Export the Cluster name export const clusterName = cluster.name; // Obtain Kubeconfig after cluster creation const kubeconfig = pulumi. all([cluster.name, cluster.endpoint, cluster.masterAuth]). apply(([name, endpoint, masterAuth]) => { const context = `${gcp.config.project}_${gcp.config.zone}_${name}`; return `apiVersion: v1 clusters: - cluster: certificate-authority-data: ${masterAuth.clusterCaCertificate} server: https://${endpoint} name: ${context} contexts: - context: cluster: ${context} user: ${context} name: ${context} current-context: ${context} kind: Config preferences: {} users: - name: ${context} user: auth-provider: config: access-token: ${masterAuth.clientCertificate} cmd-args: config config-helper --format=json cmd-path: gcloud expiry-key: '{.credential.token_expiry}' token-key: '{.credential.access_token}' name: gcp `; }); // Step 2: Install Pulsar using a Helm Chart // This can be done after we have the kubeconfig from the newly created cluster. const pulsarChart = new k8s.helm.v3.Chart("pulsar", { chart: "pulsar", version: "2.8.1", // specify the desired version of Pulsar fetchOpts:{ repo: "https://charts.bitnami.com/bitnami", }, }, { provider: new k8s.Provider("k8s-provider", { kubeconfig }) }); // Export the Pulsar chart name export const pulsarChartName = pulsarChart.name;

    This program creates a new GKE cluster and a Kubeconfig that will be used for deploying Pulsar.

    The pulsar chart refers to the Apache Pulsar Helm chart maintained by Bitnami, which can be found at the specified repository URL (https://charts.bitnami.com/bitnami). The name "pulsar" is a reference to the Helm chart, not a Pulumi resource. It's important to set the provider property to the newly instantiated K8s provider with the Kubeconfig we obtained from our newly created cluster.

    We use pulumi.all to wait for all the necessary data to be available to construct the kubeconfig, which will be used by the Kubernetes provider.

    Lastly, we export the cluster name and the Pulsar chart name so that they can be accessed from the command line after deployment.

    Make sure you replace the version with the preferred version of Pulsar you want installed. You can find more about the Pulsar Helm chart in the Bitnami repository and customize the chart settings according to your needs.

    Remember, before running pulumi up, you'll need to have your GCP CLI configured with the necessary credentials and permissions for creating GKE clusters.