Deploy the Wordress helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptTo deploy the WordPress Helm chart on Oracle Kubernetes Engine (OKE), you will need to follow these steps:
-
Set up Oracle Kubernetes Engine (OKE): Before deploying any charts, ensure that you have a functioning Kubernetes cluster on OKE. This generally involves creating an OKE cluster in your Oracle Cloud Infrastructure (OCI) account and configuring
kubectl
to connect to the cluster. -
Install Pulumi: Pulumi is a modern infrastructure as code (IaC) tool that allows you to define and manage cloud services using familiar programming languages. Before executing the code, you need to have Pulumi installed and set up on your local machine. For more information on how to install Pulumi, visit the Pulumi Installation Guide.
-
Configure Pulumi to Access OCI: Ensure that Pulumi can authenticate with OCI. This usually involves setting up the
OCI_AUTH
environment variables or the OCI CLI configuration file with the appropriate credentials. -
Install the Pulumi Kubernetes Provider: This provider allows Pulumi to interact with Kubernetes, including OKE. You can use Pulumi to install the Kubernetes provider plugin.
-
Use
kubernetes.helm.v3.Chart
Resource to Deploy WordPress: Pulumi'skubernetes.helm.v3.Chart
resource can be used to deploy a Helm chart, which in this case, is the WordPress chart.
Below is a basic Pulumi program written in TypeScript that you can use as a starting point to deploy the WordPress Helm chart to an OKE cluster.
Before using this Pulumi code, you should have Pulumi and Kubernetes CLI installed, your OCI credentials configured, and your Kubeconfig file ready and pointing to your OKE cluster context.
import * as kubernetes from "@pulumi/kubernetes"; // Create a Kubernetes provider instance that uses our existing OKE cluster context from the Kubeconfig file. const k8sProvider = new kubernetes.Provider("okeK8s", { kubeconfig: process.env.KUBECONFIG, }); // Deploy WordPress using the stable Helm chart. const wordpressChart = new kubernetes.helm.v3.Chart("wordpress", { chart: "wordpress", version: "9.0.3", // You can specify the chart version you want to deploy; check the current versions in the Helm Hub. fetchOpts:{ repo: "https://charts.bitnami.com/bitnami", // The repository where the WordPress Helm chart is hosted. }, }, { provider: k8sProvider }); // Export the public Service endpoint for the WordPress service. export const frontendIp = wordpressChart.getResourceProperty("v1/Service", "wordpress-wordpress", "status") .apply(status => status.loadBalancer.ingress[0].ip);
This Pulumi code performs the following actions:
-
It imports the Pulumi Kubernetes SDK.
-
It creates a
Provider
resource. This initializes the Kubernetes provider with the configuration from yourKUBECONFIG
environment variable, which is supposed to be set to your OKE cluster. -
The
helm.v3.Chart
resource namedwordpressChart
is declared for the WordPress Helm chart hosted in the Bitnami repository. It specifies the chart name ("wordpress"
) and version ("9.0.3"
), and the Helm repository URL where Pulumi can fetch the chart from. -
The last part of the code extracts the load balancer IP address from the deployed chart and exports it. This IP address can be used to access your WordPress site in a web browser.
Please note that you'll need to have
kubectl
properly configured to communicate with your OKE cluster. TheKUBECONFIG
environment variable should point to a configured.kube/config
file.After ensuring that the prerequisites are met, you can run the Pulumi code by creating a new Pulumi project and replacing the contents of
index.ts
with the code provided. Then runpulumi up
to execute the code and deploy WordPress on your OKE cluster.Keep in mind that this is a simple deployment and you might want to customize the WordPress deployment further by providing custom configuration values, persistent storage, or ingress controllers. The Pulumi Kubernetes library supports these additional configurations as well.
-