Deploy the cadvisor helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptTo deploy the cAdvisor Helm chart on Oracle Kubernetes Engine (OKE), you will follow these steps using Pulumi with TypeScript:
-
Set up an OKE cluster, if you haven't done so already. The
oci.ContainerEngine.Cluster
resource is used for this purpose. You will need to provide the necessary properties such as the compartment ID, VCN ID, and Kubernetes version. -
Once you have your Kubernetes cluster running, you’ll use Pulumi’s Kubernetes provider to interact with it.
-
Deploy the cAdvisor Helm chart to the OKE cluster using Pulumi's Helm support via the
kubernetes.helm.v3.Chart
resource. You'll specify the chart name, release name, and any values you wish to override.
Below is a TypeScript program that demonstrates how to perform these tasks. Make sure you have all the necessary OCI credentials configured for Pulumi to interact with your Oracle Cloud account.
Here's how you can perform the deployment step-by-step:
import * as oci from "@pulumi/oci"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Configure Oracle Cloud Infrastructure and create an OKE cluster // You must provide your own compartmentId and vcnId according to the structure of your Oracle Cloud setup const okeCluster = new oci.ContainerEngine.Cluster("okeCluster", { // Replace these with appropriate values for your environment compartmentId: "ocid1.compartment.oc1..xxxxxx...dummy-compartment", vcnId: "ocid1.vcn.oc1..xxxxxx...dummy-vcn", kubernetesVersion: "v1.21.5", // or another supported version options: { serviceLbSubnetIds: ["ocid1.subnet.oc1..xxxxxx...dummy-subnet1", "ocid1.subnet.oc1..xxxxxx...dummy-subnet2"], // Add additional options as needed }, // Other required configurations here }); // Step 2: Configure k8s provider to interact with the OKE cluster // Here we use the kubeconfig from OKE to setup the Pulumi Kubernetes provider const k8sProvider = new k8s.Provider("k8sProvider", { // You will need to retrieve this from your existing cluster setup or from the OCI console kubeconfig: okeCluster.kubeConfig.rawConfig, // Other optional provider configurations }); // Step 3: Deploy the cAdvisor Helm chart to the OKE cluster const cAdvisorChart = new k8s.helm.v3.Chart("cAdvisorChart", { chart: "cadvisor", // The Helm chart can be found in a Helm repository, specify that repository URL if necessary fetchOpts: { repo: "https://kubernetes-charts.storage.googleapis.com/", }, // Replace with appropriate namespace if needed, it defaults to 'default' namespace: "monitoring", values: { // Your customized values here if you need to override chart defaults }, }, { provider: k8sProvider }); // Export the cluster's kubeconfig and cAdvisor endpoint if required export const kubeConfig = okeCluster.kubeConfig.rawConfig; export const cAdvisorEndpoint = cAdvisorChart.getResourceProperty("v1/Service", "cadvisor", "status").apply(s => s.loadBalancer.ingress[0].ip);
In this program:
- We configure OCI resources by importing the
@pulumi/oci
package. - We import the Pulumi Kubernetes provider (
@pulumi/kubernetes
) to interact with our Kubernetes cluster. - We create an instance of the
oci.ContainerEngine.Cluster
to represent our OKE cluster detailing properties like compartment ID and VCN ID specific to our Oracle Cloud setup. - We set up a Kubernetes provider by providing the kubeconfig from the OKE cluster.
- We specify the
kubernetes.helm.v3.Chart
with the chart name "cAdvisor", indicating the Helm repository if it's not part of the default Helm repos. - The
namespace
argument defines the Kubernetes namespace where cAdvisor will be deployed; adjust this to your specific environment needs. - If necessary, in the
values
object, you can override the Helm chart values as needed for your Helm release. - We export the kubeconfig of the cluster and the cAdvisor service's endpoint (if it's exposed via a LoadBalancer) which you can use to access the cAdvisor service from outside the cluster.
Make sure to fill in the placeholder values with real values from your environment. These placeholders include things like OCI compartment and VCN IDs, Kubernetes version, and subnet IDs. You should ensure that Pulumi has the necessary access rights to create and modify resources in your OCI account.
Remember, this code is expected to run "out of the box", but the specific values for OCI configurations related to the compartment, VCN, and subnets will differ based on your environment, and you'll need to replace the placeholders with actual values accordingly.
-