Deploy the neo4j-loadbalancer helm chart on Digital Ocean Kubernetes Service
TypeScriptTo deploy the Neo4j Helm chart on a DigitalOcean Kubernetes cluster, we'll perform the following steps:
- Create a new DigitalOcean Kubernetes cluster.
- Deploy the Helm chart for Neo4j with a load balancer service.
The two primary resources we will be using for this deployment are:
digitalocean.KubernetesCluster
: this Pulumi resource represents a Kubernetes cluster in DigitalOcean and encapsulates its creation and configuration.kubernetes.helm.v3.Chart
: this Pulumi resource represents a Helm chart, which is a package for Kubernetes that allows us to define, install, and upgrade complex Kubernetes applications like Neo4j.
Here's a Pulumi TypeScript program that performs the above steps:
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', { // Define the region where the cluster is deployed. region: digitalocean.Regions.NYC1, // Specify the version of Kubernetes to use. version: '1.21.5-do.0', // Define the node pool with its configuration such as the size and the number of nodes. nodePool: { name: 'default-pool', size: digitalocean.DropletSlugs.DropletS2VCPU2GB, nodeCount: 2, // Optional: You can define tags for the nodes in the pool. tags: ['kubernetes', 'neo4j-cluster'], }, }); // Define the Helm chart for Neo4j. const neo4jChart = new kubernetes.helm.v3.Chart('neo4j-loadbalancer', { // Specify the chart details. chart: 'neo4j', // Specify the repository where the chart is hosted. fetchOpts: { repo: 'https://neo4j-contrib.github.io/neo4j-helm/', }, // This version is hypothetical; make sure to specify the correct version you need. version: '4.0.0', // Values to override the default chart values. values: { // Here you would specify the values that are needed to configure Neo4j. // For example, if you need to set a password or resource limits, you would do it here. // As an example: acceptLicenseAgreement: 'yes', neo4jPassword: 'your-strong-neo4j-password', }, // Associate the Helm chart with the created DigitalOcean Kubernetes cluster. transformations: [ (obj: any) => { if (obj.kind === 'Service' && obj.metadata.name === 'neo4j') { obj.spec.type = 'LoadBalancer'; } }, ], }, { provider: new kubernetes.Provider('k8s-provider', { kubeconfig: cluster.kubeConfigs[0].rawConfig }) }); // Export the cluster's name and endpoint. export const clusterName = cluster.name; export const kubeconfig = cluster.kubeConfigs[0].rawConfig;
The program creates a new Kubernetes cluster on DigitalOcean with a specified node pool configuration. After the cluster is provisioned, the program proceeds to deploy the Neo4j Helm chart, pulling it from the official Neo4j Helm chart repository.
When deploying software with Helm charts, it's a common practice to adjust the default settings according to specific needs by providing custom
values
. This is done through thevalues
property in thekubernetes.helm.v3.Chart
resource. In the example, we've set a custom password for Neo4j and agreed to the license agreement, but these values should be customized as per your specific requirements.Finally, we are exporting the cluster name and kubeconfig as outputs. These outputs can be used to interact with your Kubernetes cluster with
kubectl
or other Kubernetes tooling.To run the Pulumi program:
- Ensure that you have Pulumi CLI and Node.js installed.
- Create a new Pulumi project and copy-paste the code above into
index.ts
. - Run
pulumi up
to deploy the DigitalOcean Kubernetes cluster and the Neo4j Helm chart.
The Pulumi CLI will provide you with detailed output of the operations that will be performed, and you'll need to confirm the deployment by typing
yes
when prompted. After the deployment is completed, you'll be given output values (e.g., cluster name, kubeconfig) that you can use to interact with your new Neo4j database on DigitalOcean Kubernetes.