1. Deploy the kube-metrics-adapter helm chart on Oracle Kubernetes Engine (OKE)


    To deploy the kube-metrics-adapter Helm chart on Oracle Kubernetes Engine (OKE), we will use the Pulumi Kubernetes provider to interact with our Kubernetes cluster. The kube-metrics-adapter is an implementation of the Kubernetes Metrics-API. It collects and provides custom metrics to the Horizontal Pod Autoscaler for autoscaling applications.

    Before we begin, make sure you have the following prerequisites:

    1. Pulumi CLI installed and configured.
    2. Access to an Oracle Cloud Infrastructure (OCI) account.
    3. Oracle Kubernetes Engine (OKE) cluster up and running.
    4. kubectl configured to communicate with the OKE cluster.
    5. Helm CLI installed (for Helm chart repositories).

    Here's a Pulumi program in TypeScript that demonstrates how to accomplish this:

    import * as pulumi from "@pulumi/pulumi"; import * as kubernetes from "@pulumi/kubernetes"; // This is the name of the kube-metrics-adapter Helm chart we want to deploy. const CHART_NAME = "kube-metrics-adapter"; // Specify the chart version you want to deploy. Change this to the version you need. const CHART_VERSION = "x.y.z"; // Replace with actual chart version // Namespace where the kube-metrics-adapter will be installed. const NAMESPACE = "kube-system"; // Create a Chart resource to deploy kube-metrics-adapter using the Helm chart. const kubeMetricsAdapter = new kubernetes.helm.v3.Chart("kube-metrics-adapter", { // Specify the chart repository URL. repo: "REPO_URL", // Replace with the URL of the Helm repository that hosts kube-metrics-adapter chart: CHART_NAME, version: CHART_VERSION, namespace: NAMESPACE, // Values to configure the kube-metrics-adapter Helm chart. // Check the chart's documentation for the default values and other configuration options. values: { // Example of setting values, you can configure options according to your needs. // Use `values` to pass custom configuration to the Helm chart. image: { tag: "latest", // Replace with the tag of the image you want to use. }, // Add more configuration options here as needed. }, }); // Export the status URL of the deployed kube-metrics-adapter. export const kubeMetricsAdapterStatusUrl = pulumi.interpolate`https://${kubeMetricsAdapter.getResourceProperty("v1/Service", "kube-metrics-adapter", "status").apply(status => status.loadBalancer.ingress[0].ip)}`;

    Here's a breakdown of the Pulumi program above:

    • We start by importing the necessary Pulumi libraries.
    • We set some constants that define:
      • The Helm chart name of the kube-metrics-adapter.
      • The version of the Helm chart.
      • The namespace where we want to deploy our Helm chart.
    • We create a new Chart resource that represents the Helm chart we want to deploy. We specify the chart repository URL, chart name, version, and the namespace.
    • Inside the values object, we can override default chart values, such as the image tag.
    • Finally, we export a status URL for the kube-metrics-adapter. This assumes your service is exposed with an external load balancer and that the first ingress entry IP address is the one you want to use.

    Don't forget to replace placeholders like REPO_URL, CHART_VERSION, and image.tag with actual values depending on the version and configuration you need.

    To run this Pulumi program:

    1. Save the code to a file with a .ts extension, for example, deployKubeMetricsAdapter.ts.
    2. Run pulumi up from the command line in the same directory as your file to start the deployment process.
    3. If this is your first time running a Pulumi program, you'll be prompted to create a new stack. A stack is an isolated environment for your project.
    4. After reviewing the proposed changes, you can confirm and apply the deployment by selecting 'yes' in the CLI.

    Keep in mind that you need to be authenticated with Oracle Cloud and have your Kubernetes cluster already configured in your environment for this code to work successfully.