1. Deploy the angular-chart helm chart on Rancher


    To deploy an Angular chart using Helm on Rancher, you can use the Pulumi Rancher2 provider. This provider allows you to manage Rancher resources in your infrastructure as code using Pulumi.

    In this guide, I'll help you create a Pulumi program to deploy an Angular chart on a Rancher-managed Kubernetes cluster. Please ensure that you have a Kubernetes cluster managed by Rancher and the necessary access to deploy to it.

    The code will be structured in the following manner:

    • Import necessary Pulumi libraries and Rancher2 provider.
    • Define a Rancher2 CatalogV2 resource to add a Helm chart repository.
    • Define a Rancher2 AppV2 resource to deploy the Angular chart from the Helm repository you added.

    Before you start, make sure you have installed Pulumi CLI and have access to a Rancher Kubernetes cluster. If you need help setting up the Pulumi CLI or configuring Kubernetes access, refer to the official Pulumi installation guide and Kubernetes configuration guide.

    Now, let's write the program:

    import * as pulumi from '@pulumi/pulumi'; import * as rancher2 from '@pulumi/rancher2'; // Initialize a Pulumi program async function main() { // You must be logged into the Rancher2 instance with enough privileges // First, you need to create a `CatalogV2`, pointing to your Helm chart's repository const helmRepo = new rancher2.CatalogV2('angular-chart-repo', { // The URL of the Helm chart repository containing the Angular chart url: 'https://your-helm-chart-repository.com/', // The name of the Helm catalog as seen in Rancher name: 'angular-chart-repo', // Optionally, attach a cluster ID if this Catalog is specific to one cluster clusterId: 'cluster-id', // Replace with your actual cluster ID }); // Now, deploy the Helm chart to your cluster as an `AppV2` const angularChartApp = new rancher2.AppV2('angular-chart-app', { // The namespace where the Helm chart will be installed namespace: 'default', // Replace with the desired namespace // The repo name must match the `CatalogV2` resource name created above repoName: helmRepo.name, // The name of the chart you want to install chartName: 'angular-chart', // The version of the chart you want to install chartVersion: '1.0.0', // Replace with the version of the chart // The target cluster ID to deploy this app clusterId: 'cluster-id', // Replace with your actual cluster ID // Values to set in the Helm chart, equivalent to `--set` in Helm CLI values: ` replicaCount: 2 service: type: LoadBalancer `, // Waiting for the cluster to become ready before attaching the Helm chart waitForCluster: true, }); // At the end of the deployment, you might want to export some of the output, for instance the app's name return { appName: angularChartApp.name, }; } // Start the Pulumi program main().then(exports => pulumi.output(exports).apply(outputs => { // You can perform additional actions with the outputs here console.log(`App Name: ${outputs.appName}`); }));

    This program performs the following actions:

    • Creates a new Helm Chart repository (CatalogV2) in Rancher to host your Angular chart.
    • Deploys a Helm chart (AppV2) onto the Rancher-managed Kubernetes cluster.

    Replace the placeholder comments with actual values like the URL of your Helm chart repository, the version of the chart, and your cluster ID.

    After writing this Pulumi program, run pulumi up from the CLI in the directory where your Pulumi project is located to initiate the deployment. Pulumi will perform a preview of the changes and prompt you to confirm before proceeding with the actual deployment.