1. Deploy the laravel-worker helm chart on Rancher


    Deploying a helm chart using the Pulumi rancher2 provider requires you to first have a Rancher server and a Kubernetes cluster managed by Rancher.

    The following Pulumi program written in TypeScript assumes the existence of:

    1. A Rancher server that you can interact with via its API.
    2. A Kubernetes cluster registered and managed with Rancher.
    3. A Helm chart for the Laravel worker available in a repository that Rancher can access.

    The primary resources used in this program are:

    • rancher2.CatalogV2: Represents a catalog in Rancher, which provides a repository of Helm charts that Rancher can deploy.
    • rancher2.AppV2: Represents a deployment of a Helm chart within a specific namespace of a cluster managed by Rancher.

    Here is an explanation of what the following program does:

    1. It first configures a new Helm chart repository as a CatalogV2 so that Rancher knows where to look for the Laravel worker chart.
    2. Then it deploys an application using the AppV2 resource, specifying the Laravel worker chart from the added catalog.

    Make sure that you already have the necessary credentials to access the Rancher API and that you already created a workload within Rancher to hold the deployment.

    import * as pulumi from "@pulumi/pulumi"; import * as rancher2 from "@pulumi/rancher2"; // Replace these variables with values specific to your Rancher setup. const rancherClusterId = "my-cluster-id"; // Rancher Cluster ID const namespace = "my-namespace"; // The Kubernetes namespace where you want to deploy the helm chart. // Create a Rancher v2 Catalog to add the helm chart repository const catalog = new rancher2.CatalogV2("my-catalog", { clusterId: rancherClusterId, url: "https://example.com/laravel-worker-helm-repo", // Replace with the actual helm chart repo URL gitRepo: "", // The git repository hosting the helm chart, if applicable gitBranch: "main", // The default branch to use from the git repository }); // Deploy a Laravel Worker helm chart using Rancher v2 App const laravelWorkerApp = new rancher2.AppV2("laravel-worker-app", { clusterId: rancherClusterId, namespaceId: namespace, repoName: catalog.name, chartName: "laravel-worker", // The name of the helm chart in the catalog chartVersion: "1.0.0", // Specify the version of the chart you want to deploy // Values can be a raw string or fetched from a file or URL. // They follow the same format as values.yaml in a Helm chart. values: ` replicaCount: 2 image: repository: myrepo/laravel-worker tag: latest pullPolicy: IfNotPresent `, }); // Export the App's name and version export const appName = laravelWorkerApp.name; export const appVersion = laravelWorkerApp.chartVersion;

    In this program, values specify the configuration for your Laravel worker, such as the number of replicas, image repository, and tag. You would need to adjust these to match the configuration you want for your Laravel application.

    You would typically store the values configuration in a separate file (e.g., values.yaml) and then import it into your Pulumi program. However, for simplicity, this program includes them as a raw string inline.

    Remember that when you run this Pulumi program, it will interface with your Rancher server to deploy the chart, and thus it will need the appropriate credentials set in your Pulumi environment to interact with the Rancher API.