Deploy the nginx-gateway-fabric helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptDeploying a Helm chart on a Kubernetes cluster involves several steps, including setting up a Kubernetes cluster, installing Helm (if not already present), and then using Helm to deploy the chart. With Pulumi, you can automate these steps programmatically.
Using Pulumi with TypeScript, you can define cloud resources using familiar programming constructs. I'm going to demonstrate how you can deploy the
nginx-gateway-fabric
Helm chart on an Oracle Kubernetes Engine (OKE) cluster.Firstly, ensure that you have the Oracle Cloud Infrastructure (OCI) provider configured with the necessary credentials. You can follow the Pulumi OCI setup guide to configure the Pulumi with OCI.
Here's how you could write a Pulumi program to deploy a Helm chart on OKE:
- Setup an OKE Cluster: Define an Oracle Kubernetes Engine cluster resource. You can customize your cluster as needed by setting the different properties, like the number of nodes.
- Install the Helm Chart: Once the cluster is provisioned, you can use the
kubernetes.helm.v3.Chart
resource from Pulumi's Kubernetes provider to deploy thenginx-gateway-fabric
Helm chart.
Below is the Pulumi TypeScript program achieving this. Please note that you should have Pulumi CLI installed and OCI configured on your system for this code to execute successfully.
import * as oci from "@pulumi/oci"; import * as kubernetes from "@pulumi/kubernetes"; // Create an Oracle Kubernetes Engine (OKE) cluster const cluster = new oci.containerengine.Cluster("okeCluster", { // ... specify other necessary OKE cluster properties here }); // Define the OKE Node Pool const nodePool = new oci.containerengine.NodePool("okeNodePool", { // Reference the cluster created above clusterId: cluster.id, // ... specify the node pool configuration like node shapes and quantity }); // Once the cluster is provisioned, you can use the `kubernetes` provider to interact with it. // The kubeconfig can be obtained from OCI, which Pulumi can use to know how to communicate with your cluster. const provider = new kubernetes.Provider("okeK8s", { kubeconfig: cluster.kubeConfigRaw, }); // Deploy the nginx-gateway-fabric Helm chart using Pulumi's Kubernetes provider const nginxGatewayFabricChart = new kubernetes.helm.v3.Chart("nginx-fabric", { chart: "nginx-gateway-fabric", // Use the version attribute if you want to specify a chart version // version: "<version>", // Namespace where the chart will be installed namespace: "default", // Additional values to configure the chart values: { /* Provide any additional chart values here, for example: service: { type: "LoadBalancer" }, */ }, }, { provider }); // Export the URL to access the NGINX Gateway // Please adjust the following line according to your chart's service setup, this is an example const gatewayUrl = nginxGatewayFabricChart.getResourceProperty("v1/Service", "nginx-service", "status").apply(status => status.loadBalancer.ingress[0].ip); export const gatewayIp = gatewayUrl;
In this program, we start by defining an OKE cluster and node pool which will constitute the environment where our Helm chart will be deployed.
Next, we create a Kubernetes provider instance using the kubeconfig data of the OKE cluster, which enables Pulumi to interact with the cluster.
Lastly, we use the
kubernetes.helm.v3.Chart
resource to deploy thenginx-gateway-fabric
Helm chart onto our cluster. This step assumes that the chart is available in one of the Helm repositories that are accessible from your OKE cluster. If your chart is in a custom repository or requires specific Helm repository configurations, additional setup will be necessary.Upon running
pulumi up
, Pulumi will provision the OKE cluster, set up the Kubernetes provider, and deploy thenginx-gateway-fabric
Helm chart.Keep in mind that this is a simplified example and you'll need filled-out detailed configuration options for the OKE cluster, node pool, and Helm chart values based on your specific use case and requirements.