Deploy the tyk-stack helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptTo deploy the
tyk-stack
Helm chart on Oracle Kubernetes Engine (OKE), we will use Pulumi resources likeoci.ContainerEngine.Cluster
for setting up an OKE cluster andkubernetes.helm.sh/v3.Chart
to deploy the Helm chart onto the created Kubernetes cluster.Here's the process that we will follow:
- Set up the Oracle Kubernetes Engine cluster using the
oci.ContainerEngine.Cluster
resource. This will create a Kubernetes cluster in your OCI (Oracle Cloud Infrastructure) account. - Install the Helm chart on the Kubernetes cluster using a
kubernetes.helm.sh/v3.Chart
resource. Ensure that the Helm chart repository contains thetyk-stack
chart or has a direct URL to the chart.
Let's go through a step-by-step Pulumi TypeScript program to achieve this:
import * as pulumi from "@pulumi/pulumi"; import * as oci from "@pulumi/oci"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Create an Oracle Kubernetes Engine (OKE) cluster const okeCluster = new oci.ContainerEngine.Cluster("my-oke-cluster", { // Provide the OCI compartment ID where the cluster should be provisioned. compartmentId: "compartment-id", // Specify the VCN (Virtual Cloud Network) ID where the cluster network resources should be provisioned. vcnId: "vcn-id", // Specify the Kubernetes version for the OKE cluster. kubernetesVersion: "v1.20.8", // Add any other necessary configurations as required. options: { serviceLbSubnetIds: ["subnet-id1", "subnet-id2"], // Replace these with actual subnet IDs in your OCI VCN }, }); // Step 2: Deploy the tyk-stack Helm chart on the OKE cluster // Initialize a provider to deploy resources to the created cluster const k8sProvider = new k8s.Provider("my-k8s-provider", { kubeconfig: okeCluster.kubeconfig.toSecret(), // Automatically fetch the kubeconfig from the OKE cluster }); // Deploy the tyk-stack Helm chart const tykStackChart = new k8s.helm.v3.Chart("tyk-stack", { // Chart repository or path depends on where the tyk-stack Helm chart is hosted. // Change these properties to point to the correct repository and chart name chart: "tyk-headless", version: "v0.9.0", // Specify the chart version you wish to deploy fetchOpts: { repo: "https://helm.tyk.io/public/helm/charts/", // Repository where tyk-stack is located }, }, { provider: k8sProvider }); // Optional: Export the cluster's kubeconfig and Tyk Stack service's IP export const kubeconfig = okeCluster.kubeconfig.apply(JSON.stringify); export const tykStackServiceIP = tykStackChart.getResourceProperty("v1/Service", "tyk-gateway", "status").apply(status => status.loadBalancer.ingress[0].ip);
In this TypeScript program, we start by importing the required packages from Pulumi. We define two constants:
okeCluster
andtykStackChart
.For
okeCluster
, you would need to provide thecompartmentId
andvcnId
specific to your Oracle Cloud Infrastructure. You also define the Kubernetes version and subnet IDs to use for the LoadBalancer, which allows external access to your services.The
k8sProvider
establishes the connection to the newly created OKE cluster using thekubeconfig
which is fetched from the OKE cluster details.For
tykStackChart
, we deploy thetyk-stack
as a Helm chart to the Kubernetes cluster defined earlier. We use thefetchOpts
property to specify the Helm chart's repository and chart name, which instructs Pulumi where to fetch the chart from.Finally, you can optionally export the cluster's kubeconfig and the IP address of the Tyk Gateway service for external access.
Please replace placeholder values such as
"compartment-id"
,"vcn-id"
, and the subnet IDs with actual values from your Oracle Cloud Infrastructure. You might also need to adjust the chart version and repository URL based on the latest details from the tyk-stack Helm chart documentation.To apply this Pulumi program, you would save it to a file, such as
index.ts
, and then use the Pulumi CLI to create a new stack and deploy it:pulumi stack init dev pulumi up
This will prompt you to review the changes before actually provisioning the resources. After your review, select 'yes' to proceed with the deployment.
- Set up the Oracle Kubernetes Engine cluster using the