1. Deploy the k8s-mutating-admission-webhook helm chart on Kubernetes


    To deploy a Helm chart on Kubernetes using Pulumi, you'll be making use of the kubernetes.helm.v3.Chart resource. This resource manages the deployment of a Helm chart and its associated Kubernetes resources.

    In this example, you will see how to deploy a hypothetical Helm chart named k8s-mutating-admission-webhook. The details for the chart, such as the repository it resides in, will be made up for educational purposes. If there's an actual chart you want to deploy, you'll need to replace the details accordingly (the repository URL, version, and any custom values required by the chart).

    The Pulumi program begins with importing the necessary packages, creating a Kubernetes provider (assuming you've configured kubectl), and then deploying the chart. For brevity, I’ll skip the detailed setup of the Kubernetes cluster itself and focus on the deployment of the Helm chart.

    Below is a detailed explanation of the Pulumi TypeScript program:

    import * as pulumi from '@pulumi/pulumi'; import * as k8s from '@pulumi/kubernetes'; // This example assumes that you have a Kubernetes cluster running and that your kubectl is configured // to point to that cluster. // The `kubernetes.helm.v3.Chart` is a component resource that represents a Helm chart in a Pulumi program. // The following code deploys the 'k8s-mutating-admission-webhook' Helm chart to your Kubernetes cluster. const webhookChart = new k8s.helm.v3.Chart('webhook-admission', { // You can specify the repository where your chart is located. // Replace `REPO_URL` with the actual repository URL. repo: 'my-helm-chart-repo', chart: 'k8s-mutating-admission-webhook', // The name of the chart. // Specify the version of the Helm chart you want to deploy. // Use the exact version to ensure idempotence across deployments. version: '1.2.3', // Custom values for the Helm chart can be set here. // These values would configure your mutating admission webhook's specifics. // You would need to replace them with actual configuration values for your webhook. values: { // An example of setting a custom namespace for the webhook deployment. namespace: 'webhook-namespace', // Example of custom values. Replace these with actual values based on the webhook chart you are using. image: { repository: 'my-webhook-image', tag: 'latest' }, resources: { requests: { memory: "64Mi", cpu: "250m" }, limits: { memory: "128Mi", cpu: "500m" } } // Add more custom values as required by your scenario. }, // Namespace where you want to deploy your webhook. // It should match the namespace provided inside the values or the Helm chart's default will be applied. namespace: 'webhook-namespace' }, { provider: /* If you have a specific Kubernetes Provider setup, reference it here */ }); // The following command can be used to export the resulting Kubernetes resources’ manifests, if needed. export const webhookManifest = webhookChart.resourceNames;

    In this program:

    • We created a new Chart resource named webhook-admission.
    • repo attribute specifies the repository where the Helm chart is located.
    • chart attribute specifies the name of the Helm chart to be deployed.
    • version attribute is where the version number of the Helm chart is defined.
    • values is a map of key-value pairs that will override default settings in the Helm chart.
    • An output variable webhookManifest exports the generated resource names for easy access post-deployment.

    Remember to replace placeholder values like REPO_URL, 1.2.3, and the contents of the values field with the actual details corresponding to the k8s-mutating-admission-webhook chart you wish to deploy. The values provided should reflect the necessary configuration for the mutating admission webhook you are setting up.