1. Deploy the fluentbit-resource helm chart on Google Kubernetes Engine (GKE)

    TypeScript

    To deploy the fluentbit Helm chart on Google Kubernetes Engine (GKE), you first need to set up a GKE cluster. After creating a cluster, you can then deploy the Helm chart to it. The following is a TypeScript program that uses Pulumi to create a GKE cluster and deploy the fluentbit Helm chart to the cluster.

    First, you need to import the necessary Pulumi packages. We'll use the @pulumi/gcp package to create GKE resources and the @pulumi/kubernetes package to deploy Helm charts.

    1. Install the required packages using npm by running:

      npm install @pulumi/gcp @pulumi/kubernetes
    2. Define your GKE cluster with a predefined node size and region.

    3. Once the cluster is created, obtain the Kubeconfig to interact with the cluster.

    4. Use the Kubeconfig to create an instance of the Kubernetes Provider.

    5. Deploy the fluentbit Helm chart using this Kubernetes Provider.

    Here's the full Pulumi program:

    import * as gcp from "@pulumi/gcp"; import * as k8s from "@pulumi/kubernetes"; // Create a GKE cluster const cluster = new gcp.container.Cluster("my-gke-cluster", { initialNodeCount: 1, nodeVersion: "latest", minMasterVersion: "latest", nodeConfig: { machineType: "n1-standard-1", // This is a cost-effective type for demo purposes. 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; // Manufacture a GKE-style kubeconfig. Note that this is slightly "different" // because of the way GKE requires gcloud to get the credentials for the cluster. // Hence it is not guaranteed to work with other Kubernetes environments. 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: cmd-args: config config-helper --format=json cmd-path: gcloud expiry-key: '{.credential.token_expiry}' token-key: '{.credential.access_token}' name: gcp `; }); // Create a Kubernetes provider instance that uses our cluster from above. const k8sProvider = new k8s.Provider("my-k8s-provider", { kubeconfig: kubeconfig, }); // Deploy the fluentbit Helm chart to the cluster under the provided Kubernetes provider const fluentbitChart = new k8s.helm.v3.Chart("fluentbit", { chart: "fluent-bit", fetchOpts: { repo: "https://fluent.github.io/helm-charts", }, // You can include additional configurations here if needed }, { provider: k8sProvider }); // Export the Helm chart name export const fluentbitChartName = fluentbitChart.name;

    This program does the following:

    • Creates a GKE cluster with one node which can be scaled as needed. It uses the n1-standard-1 machine type for the node, a good default choice for general purposes.
    • Constructs a kubeconfig that is compatible with GKE’s authentication mechanism.
    • Instantiates a Kubernetes provider to interact with the GKE cluster.
    • Deploys the fluentbit Helm chart to the GKE cluster using the created Kubernetes provider.

    Note that the program assumes you’ve already authenticated with GCP using the gcloud CLI and have set the project and zone configuration values for the GCP provider appropriately. If not, you may need to use gcloud to authenticate and provide the project and zone to Pulumi via configuration or environment variables.

    Now, save the code to a file with a .ts extension, then run pulumi up to execute it. The Pulumi CLI will perform the deployment, and the fluentbit Helm chart will be deployed to your GKE cluster, ready for you to configure and use.