1. Deploy the vsg-hw helm chart on Rancher


    To deploy a Helm chart on Rancher using Pulumi, you would need to interact with the Rancher API. The Helm chart deployment can be managed through the CatalogV2 resource in the rancher2 provider, which allows you to configure a Helm chart repository.

    Here is a walkthrough of how to use Pulumi and TypeScript to deploy the vsg-hw Helm chart on a Rancher managed Kubernetes cluster:

    1. Set up the Rancher Cluster: Before using Pulumi to deploy the Helm chart, ensure that you have a Rancher managed Kubernetes cluster set up and that you have access to it. You will need the cluster ID to specify the target of the Helm chart deployment.

    2. Install Pulumi Rancher2 Provider: Include the rancher2 provider in your Pulumi project. This provider is a plugin for Pulumi that allows for full management of Rancher resources.

    3. Create a CatalogV2 Resource: Define a CatalogV2 resource to represent the Helm chart repository. This resource requires you to specify the details of the Helm repository URL and the target cluster ID.

    4. Specify the vsg-hw Helm Chart: Within the CatalogV2 definition, specify the Helm chart you wish to deploy. If the Helm chart vsg-hw is part of a public Helm repository, you would need the correct URL to this repository. Otherwise, if it's private, ensure you have the right authentication details configured.

    5. Deploy the Chart: Once defined, run pulumi up to execute the deployment. The Pulumi engine will then plan and perform the necessary steps to deploy the Helm chart to your Rancher managed cluster.

    Let's create the program to deploy the vsg-hw Helm chart:

    import * as pulumi from '@pulumi/pulumi'; import * as rancher2 from '@pulumi/rancher2'; // Initialize a new Rancher2 Catalog V2 resource. const catalog = new rancher2.CatalogV2('my-catalog', { // Assuming you have the correct URL and branch for your Helm chart repository url: 'https://helm.example.com/', branch: 'main', clusterId: '<YOUR_RANCHER_CLUSTER_ID>', }); // Deploy the vsg-hw Helm chart onto the Rancher managed Kubernetes cluster const helmChart = new rancher2.AppV2('vsg-hw-app', { // Reference to the catalog that contains the vsg-hw Helm chart catalogName: catalog.name, // Assuming 'vsg-hw' is the name of the Helm chart within your repository chartName: 'vsg-hw', // Specify the Kubernetes namespace in which to install the Helm chart namespace: 'default', // Your specific version of the Helm chart if required, e.g., '1.2.3' // chartVersion: '<CHART_VERSION>', // Values: Pass values to the Helm chart as needed like below // values: { // key: 'value', // anotherKey: { // nestedKey: 'nestedValue' // } // }, // Leave empty or specify a map corresponding to the 'values.yaml' of the Helm chart values: {}, // The Cluster ID where the Helm chart should be deployed clusterId: '<YOUR_RANCHER_CLUSTER_ID>', }); // Export the app's name export const helmChartName = helmChart.metadata.apply(metadata => metadata.name);

    Replace <YOUR_RANCHER_CLUSTER_ID> with your Rancher Cluster ID, and if necessary, specify the Helm chart version and other configurations according to your requirements.

    The above program sets up a new Catalog V2 resource, which points to the Helm chart repository. After setting up this catalog, it defines an AppV2 resource which actually deploys the vsg-hw Helm chart onto the specified cluster and namespace. You can add custom values for Helm chart deployment by specifying them under the values property of the AppV2 resource, which corresponds to a custom values.yaml. Once the Pulumi program is set up, use the Pulumi CLI to run pulumi up to preview and apply the deployment.

    Do not forget to install the Pulumi CLI and set up the Rancher2 provider by running pulumi plugin install resource rancher2 <VERSION> where <VERSION> is replaced with the version number of the provider. You also need to be authenticated with Rancher, so ensure your Pulumi stack is correctly configured with any necessary Rancher API tokens or credentials.

    After deploying with Pulumi, the Helm chart name is exported as a stack output, so you can easily reference your Helm chart deployments. You can see the outputs by running pulumi stack output.