Deploy the nodered-chart helm chart on Digital Ocean Kubernetes Service
TypeScriptDeploying a Helm chart on a Digital Ocean Kubernetes Service with Pulumi involves a combination of resources. The main steps include provisioning the Kubernetes cluster on Digital Ocean and then deploying the
nodered-chart
Helm chart onto this cluster. The resources involved in this include thedigitalocean.KubernetesCluster
to create the cluster, and thekubernetes.helm.v3.Chart
for the Helm chart deployment part.First, we'll set up the Digital Ocean Kubernetes cluster, which is a combination of nodes grouped together to form a cluster that can run containerized applications. We use the
digitalocean.KubernetesCluster
Pulumi resource which will configure the managed Kubernetes service provided by Digital Ocean.Once the cluster is up and running, we'll proceed with deploying the
nodered-chart
Helm chart. Helm charts help you define, install, and upgrade even the most complex Kubernetes applications. Thekubernetes.helm.v3.Chart
resource from Pulumi's Kubernetes provider will track the specified Helm chart and manage its deployment in the Kubernetes cluster.Here is the Pulumi program in TypeScript to accomplish this deployment:
import * as digitalocean from '@pulumi/digitalocean'; import * as kubernetes from '@pulumi/kubernetes'; import * as pulumi from '@pulumi/pulumi'; // Create a DigitalOcean Kubernetes cluster const cluster = new digitalocean.KubernetesCluster('do-cluster', { region: 'nyc3', version: 'latest', nodePool: { size: 's-1vcpu-2gb', name: 'default', nodeCount: 2, }, }); // Export the DigitalOcean K8s cluster config export const kubeConfig = cluster.kubeConfigs[0].rawConfig; // Create a Kubernetes provider instance using the DigitalOcean cluster's kubeconfig const k8sProvider = new kubernetes.Provider('do-k8s-provider', { kubeconfig: kubeConfig, }); // Deploy the nodered-chart Helm chart const nodeRedChart = new kubernetes.helm.v3.Chart('node-red', { fetchOpts: { repo: 'https://nodered.org/helm/', }, chart: 'nodered', // Specify the chart version you want to deploy version: '0.1.0', values: { // Provide any custom values for 'nodered-chart' here service: { type: 'ClusterIP', }, }, namespace: 'default', }, { provider: k8sProvider }); // Export the URL for the deployed Node-RED instance export const nodeRedUrl = pulumi.stackReference('kubeConfig').getResourceProperty( 'v1/Service', 'default', 'node-red-node-red', 'status') .apply(status => `http://${status.loadBalancer.ingress[0].ip}:1880`);
Explanation:
-
Digital Ocean Kubernetes Cluster: We start by declaring a new Digital Ocean Kubernetes cluster resource. The
region
specifies the location for the cluster,version
sets the version of Kubernetes to use (latest
specifies we want the latest stable version available), andnodePool
defines the configuration for the nodes within our cluster. Here, we create a node pool with two nodes of a particular size, and we name it 'default'. -
Kubernetes Provider: We instantiate a new Kubernetes provider using the configuration exported from the Digital Ocean cluster. This provider will help us interact with the Kubernetes API to deploy Helm charts.
-
Node-Red Helm Chart Deployment: We then use the
kubernetes.helm.v3.Chart
resource to specify the Helm chart we wish to deploy. By settingfetchOpts
, we specify the repository to fetch ournodered-chart
from. We also set thechart
andversion
values, and if necessary, we can customize the deployment with values provided to thevalues
argument. -
Export Node-RED URL: Finally, we export the URL through which the Node-RED service can be accessed, which depends on the service type and the cluster's load balancer configuration.
Make sure you have Pulumi installed and configured for use with DigitalOcean. After you save the above code to a file, say
index.ts
, you would runpulumi up
, which will execute the code and deploy the resources. Keep in mind that changes to cloud resources can incur costs, so be sure to check the specific details for resource usage in DigitalOcean.-