Deploy the mariadb-persistent helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptTo deploy the
mariadb-persistent
Helm chart on Oracle Kubernetes Engine (OKE) using Pulumi, you perform the following steps:- Set up Oracle Kubernetes Engine (OKE): You create a Kubernetes cluster managed by OKE. For this, you can use the
oci.ContainerEngine.Cluster
resource. - Install the Helm Chart: After setting up the cluster, you need to install the
mariadb-persistent
Helm chart onto the cluster. You can use thekubernetes.helm.sh/v3.Chart
resource from thekubernetes
provider to do this.
Here's how you could structure your Pulumi program in TypeScript to achieve this:
-
First, make sure you have installed the Pulumi CLI and have set up the correct OCI (Oracle Cloud Infrastructure) configuration to interact with your Oracle Cloud account from your local machine.
-
Next, you can execute the following Pulumi program, which we will go through step by step:
import * as oci from "@pulumi/oci"; import * as k8s from "@pulumi/kubernetes"; // This line assumes you have already configured Pulumi to use your OCI account. // See https://www.pulumi.com/docs/intro/cloud-providers/oci/setup/ for setup details. // Step 1: Create an OKE cluster const cluster = new oci.ContainerEngine.Cluster("okeCluster", { // Provide necessary configuration for OKE cluster here // Example configuration: compartmentId: "your-oci-compartment-id", vcnId: "your-oci-vcn-id", kubernetesVersion: "v1.20.8", options: { // Options such as enabled add-ons can be specified here }, // Other parameters... }); // Step 2: Obtain the kubeconfig from the OKE cluster const kubeconfig = cluster.kubeConfigs.apply(configs => configs[0].content); // Prepare a Kubernetes Provider using the kubeconfig from the OKE cluster const k8sProvider = new k8s.Provider("okeK8sProvider", { kubeconfig: kubeconfig, }); // Step 3: Deploy the mariadb-persistent helm chart using the Pulumi Kubernetes provider const mariadbChart = new k8s.helm.v3.Chart("mariadbPersistent", { chart: "mariadb", version: "your-desired-chart-version", // specify the chart version fetchOpts: { // If the chart is not from the stable repository, specify `repo` here. repo: "https://charts.bitnami.com/bitnami", }, // Specify any custom values for the chart values: { // Example value overrides for MariaDB auth: { rootPassword: "your-root-password", // Other authentication parameters... }, // Persistence configuration if needed primary: { persistence: { enabled: true, size: "8Gi", // Other persistence parameters... }, }, // Other custom values... }, }, { provider: k8sProvider }); // Optional step: Export the endpoint of MariaDB after it has been deployed export const mariadbEndpoint = mariadbChart.getResourceProperty("v1/Service", "mariadb", "status").apply(s => s.loadBalancer.ingress[0].ip);
In this Pulumi program, you create an Oracle Kubernetes Engine cluster with the
oci.ContainerEngine.Cluster
(documentation) resource. It's important to supply the compartment ID and the VCN ID as per your OCI account and setups.Additionally, you need the Kubernetes version that you want your OKE cluster to run. You have the option to enable various add-ons or configure your cluster's options within the
options
property.You then proceed to define a
kubeconfig
that allows Pulumi to interact with your OKE cluster. This is necessary to create aProvider
for Pulumi that is tied to your new OKE cluster.With a Kubernetes provider configured using the kubeconfig for the created OKE cluster, you deploy the
mariadb-persistent
Helm chart. Thek8s.helm.v3.Chart
(documentation) resource allows you to specify the chart name, version, and any custom values that you would like to override.In the example, we have commented on where you would place your root password for MariaDB and configurations required for persistence such as volume size. Make sure to replace placeholder values like
your-root-password
,your-desired-chart-version
,your-oci-compartment-id
, andyour-oci-vcn-id
with actual values that you intend to use.Finally, as an optional step, the program exports the MariaDB service endpoint, which you'll be able to use to connect to your MariaDB database once deployed.
Please remember that you need to add the Pulumi packages to your
package.json
file and you should runnpm install
oryarn install
to ensure all dependencies are installed before runningpulumi up
.This is a simplified demonstration and in a real-world scenario, you would likely need to include additional configurations such as setting up networking components (like subnets and security groups) within OKE, securing database access, and planning for high availability and backup strategies for the database.
- Set up Oracle Kubernetes Engine (OKE): You create a Kubernetes cluster managed by OKE. For this, you can use the