Deploy the simple-redis helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptTo deploy the
simple-redis
Helm chart on Oracle Kubernetes Engine (OKE), you should first ensure that you have an OKE cluster up and running. Pulumi provides resources for managing OKE clusters, and Helm charts can be deployed on a Kubernetes cluster using the Pulumi Kubernetes provider.Here's what needs to happen step by step:
- Set up an OKE cluster using the
oci.ContainerEngine.Cluster
resource, if you don't already have one. - Once the cluster is ready, configure
kubectl
to communicate with the cluster. - Use the
kubernetes.helm.v3.Chart
resource to deploy thesimple-redis
chart to the OKE cluster.
Below is a Pulumi program in TypeScript that demonstrates how to deploy the
simple-redis
helm chart on OKE:import * as pulumi from "@pulumi/pulumi"; import * as oci from "@pulumi/oci"; import * as kubernetes from "@pulumi/kubernetes"; // Step 1: Set up a new OKE cluster. // Ensure you have configured your OCI provider credentials. const cluster = new oci.containerengine.Cluster("simple-redis-cluster", { // Replace the following properties with the appropriate values for your environment. compartmentId: "ocid1.compartment.oc1..xxxxxx", // Compartment OCID name: "simple-redis-oke-cluster", kubernetesVersion: "v1.20.8", // Specify your desired Kubernetes version options: { // Optionally, you can specify additional configuration for add-ons, network setup, etc. ... }, // Assign the VCN and other required network resources such as subnets. ... }); // Step 2: Set up the Kubernetes provider to communicate with the OKE cluster. // The kubeconfig can be obtained from the OCI console or via the OCI CLI. const kubeconfig = ... // Your kubeconfig content here const k8sProvider = new kubernetes.Provider("k8s-provider", { kubeconfig: kubeconfig, }); // Step 3: Deploy the `simple-redis` Helm chart to your OKE cluster using the kubernetes.helm.v3.Chart resource. // Make sure you have access to the Helm chart repository that contains `simple-redis`. const chart = new kubernetes.helm.v3.Chart("simple-redis", { chart: "simple-redis", // The name of the helm chart version: "1.0.0", // Specify the chart version you want to deploy namespace: "default", // Specify the namespace where the chart should be deployed // If your Helm chart requires additional values, specify them here. values: { usePassword: false, // Assuming you have a `usePassword` option in your chart // You can add more custom values as required by your Helm chart ... }, }, { provider: k8sProvider }); // Export the Cluster and App Service details. export const clusterName = cluster.name; export const redisEndpoint = pulumi.interpolate`${chart.getResourceProperty("v1/Service", "redis-service", "status").apply(status => status.loadBalancer.ingress[0].ip)}`;
Here are the explanations for the code:
-
OCI Kubernetes Cluster: The
oci.ContainerEngine.Cluster
resource creates a new OKE cluster. You need to specify details such as the compartment OCID, cluster name, and Kubernetes version. You may also need to specify network-related configurations depending on your OCI setup. -
Kubernetes Provider: The
kubernetes.Provider
resource sets up the Kubernetes provider with thekubeconfig
necessary to communicate with the OKE cluster. -
Helm Chart: The
kubernetes.helm.v3.Chart
resource deploys the Redis Helm chart to the Kubernetes cluster specified by the Kubernetes provider. You specify the name, version, and namespace for the Helm chart here. If the chart requires additional configuration, you can also provide that in thevalues
property. -
Exports: At the end, the
clusterName
and theredisEndpoint
(an IP address of the Redis service if configured with a LoadBalancer) are exported. The endpoint export assumes your chart creates aService
of typeLoadBalancer
with the nameredis-service
to access Redis.
Please adapt the placeholders and configurations to suit your exact requirements, such as the compartment ID and desired Kubernetes version. Additionally, ensure you have the Pulumi CLI installed and configured for use with OCI.
- Set up an OKE cluster using the