Deploy the tyk-oss helm chart on Digital Ocean Kubernetes Service
TypeScriptTo accomplish the deployment of the Tyk Open Source (OSS) Helm chart on a DigitalOcean Kubernetes Service (DOKS), you'll need to perform several steps. These include creating a Kubernetes cluster on DigitalOcean, installing and configuring Helm in your Pulumi program, and lastly deploying the Tyk OSS Helm chart onto your cluster.
Pulumi makes it easier to define, deploy, and manage cloud infrastructure, including Kubernetes resources, using programming languages such as TypeScript. The resources we'll use are as follows:
- DigitalOcean Kubernetes Cluster: The
digitalocean.KubernetesCluster
resource is used to create and manage a Kubernetes cluster on DigitalOcean. - Helm Chart: The
kubernetes.helm.v3.Chart
resource is a Pulumi resource that allows you to deploy Helm charts in a Kubernetes cluster.
Below is a Pulumi program written in TypeScript that demonstrates these steps. Please ensure you have Pulumi installed and configured with the necessary cloud provider credentials. This program assumes you have already set up and configured the Pulumi CLI with the DigitalOcean provider.
Detailed Pulumi TypeScript Program
import * as pulumi from '@pulumi/pulumi'; import * as digitalocean from '@pulumi/digitalocean'; import * as k8s from '@pulumi/kubernetes'; // Define a DigitalOcean Kubernetes cluster const cluster = new digitalocean.KubernetesCluster('tyk-k8s-cluster', { region: digitalocean.Regions.NYC1, version: 'latest', nodePool: { size: digitalocean.DropletSlugs.DropletS2VCPU2GB, name: 'default', nodeCount: 2, }, }); // Once the cluster is provisioned, configure the Kubernetes provider to use the cluster credentials const k8sProvider = new k8s.Provider('k8s-provider', { kubeconfig: cluster.kubeConfigs[0].rawConfig, }); // Deploy the tyk-oss chart using a Helm Chart resource const tykOssChart = new k8s.helm.v3.Chart('tyk-oss', { chart: 'tyk-oss', version: '1.9.1', // Use the desired chart version fetchOpts: { repo: 'https://helm.tyk.io/public/helm/charts/', // Tyk OSS Helm repository URL }, }, {provider: k8sProvider}); // Export the cluster's kubeconfig export const kubeconfig = cluster.kubeConfigs[0].rawConfig;
Explanation of the Program
- Import the necessary Pulumi packages for interacting with DigitalOcean and Kubernetes resources.
- Create a managed Kubernetes cluster on DigitalOcean by defining a
KubernetesCluster
resource.- Set the region where you want your cluster to be provisioned.
- Define the version of Kubernetes to use. Set to 'latest' to use the most up-to-date stable version.
- Define a node pool for your cluster. It specifies the size of the nodes, the number of nodes, and the node pool name.
- Once the cluster is created, instantiate the Kubernetes provider with the kubeconfig of the newly created DigitalOcean Kubernetes cluster. This provider will be used to interact with this Kubernetes cluster specifically.
- Deploy the Tyk OSS Helm chart to your Kubernetes cluster using the
Chart
class from the@pulumi/kubernetes
package.- Specify the name of the chart and the exact version you want to deploy. The version should be the desired stable version of the Helm chart.
- Provide the repository URL where the Tyk OSS Helm chart is hosted.
- Associate this Helm chart with the Kubernetes provider configured for our DigitalOcean cluster.
After the program is executed with
pulumi up
command, Pulumi will perform the following actions:- Provision a new Kubernetes cluster on DigitalOcean using the configuration specified.
- Use the cluster's kubeconfig to connect to the cluster.
- Deploy the specified version of the Tyk OSS Helm chart to the cluster.
Lastly, we export the kubeconfig which will allow us to interact with our Kubernetes cluster using tools like
kubectl
.Remember to run
pulumi up
to preview and deploy the changes. You'll need to have Pulumi and the required cloud provider CLI installed and configured on your local machine.- DigitalOcean Kubernetes Cluster: The