Skip to main content

Step-by-Step Guide to Deploying a Node.js Application on Kuberns

This tutorial walks you through deploying a Node.js application on Kuberns.

Kuberns simplifies the deployment process by automating configuration, build, and runtime tasks, while offering flexibility through the Dashboard for advanced customization.

1. Creating a Project

All services in Kuberns are organized under a project. To deploy your Node.js application, start by creating a project to manage your services.

  • On the Kuberns Dashboard, new users are prompted to create a project by default. If you’ve skipped this, click the Add New button in the top-right corner of the navbar.
  • Give your project a memorable and relevant name.
  • Select Backend Service as the service type to start with.

For more details on projects, refer to the Projects guide.

2. Creating a Service

Connect with GitHub

To deploy your Node.js application, you’ll need to connect your GitHub repository to Kuberns.

  • After selecting the service type, you’ll be redirected to the "Creating a Service" page.
  • If this is your first time using Kuberns, you’ll need to authorize Kuberns to access your GitHub repositories. Click Connect to GitHub and follow the prompts to authenticate.
  • Once authorized, select the organization, repository, and branch containing your Node.js application.

This links your GitHub account to Kuberns, allowing you to choose from your repositories directly in the Dashboard.

For more details on services, refer to the Services guide.

3. Configuring Environment Variables

Environment variables are essential for configuring your Node.js application (e.g., database credentials, API keys).

Kuberns allows you to set these variables directly in the Dashboard.

How to configure environment variables

  • Navigate to the Environment section of your service in the Kuberns Dashboard.
  • Kuberns provides default environment variables necessary for your application (e.g., PORT for Node.js apps, dynamically assigned by Kuberns).
  • To add custom variables:
    1. Click Add New Environment Variable.
    2. Input the key-value pairs or upload .env file
  • Save the changes before deploying.

For more details on environment variables, refer to the Environments guide.

4. Auto-detected Node.js configuration

Kuberns AI automatically detects and configures your Node.js application, simplifying the deployment process.

How it works?

  • Kuberns scans your repository required file to identify for your Node.js application.
  • It automatically detects the necessary commands to run your application.
  • Kuberns dynamically assigns a port for your web service, so you don’t need to specify it in your code.

This automation ensures your Node.js application is deployed with minimal setup, using best practices for stability and performance.

5. Deploying your application

Deploy your application

  • On your service page in the Kuberns Dashboard, click the Deploy button.
  • Monitor the deployment process using the real-time logs provided in the Dashboard.

Post-Deployment Monitoring

  • After deployment, navigate to the Activities section to view logs and monitor your application’s status.
  • Use the Build History section to track build statuses and access detailed logs for debugging.
  • The Activities section also logs actions by team members, ensuring transparency and collaboration.
  • In the Resources Management section, track the start/stop status of your resources to manage utilization and avoid downtime.

6. Customizing runtime configuration

After your initial deployment, you can customize the Node.js runtime version if the default (selected by Kuberns AI) doesn’t meet your needs.

How to customize the runtime

  1. Navigate to the Deploy Config section in the Kuberns Dashboard.
  2. Locate the Runtime Configuration option.
  3. Select your desired Node.js version.
  4. Save the changes and redeploy your application to apply the new runtime.

If no custom runtime is specified, Kuberns will continue using the AI-selected default.

7. Adding Pre-Build and Post-Build Commands

After deployment, you can add custom pre-build and post-build commands to tailor the build process to your specific needs.

Kuberns automates these tasks by default, but custom commands provide additional flexibility.

Configuring Pre-Build Commands

  1. Navigate to the Deploy Config section in the Kuberns Dashboard.
  2. Locate the Pre-Build Scripts section.
  3. Add commands to execute before the build.
  4. Save and redeploy to apply.

Configuring Post-Build Commands

  1. Navigate to the Deploy Config section in the Kuberns Dashboard.
  2. Locate the Post-Build Scripts section.
  3. Add commands to execute after the build.
  4. Save and redeploy to apply.

If no custom commands are specified, Kuberns AI will handle these tasks automatically.

8. Managing Environments

Creating Additional Environments

To create environments for staging or testing:

  • From your service dashboard, select Add New Environment.
  • Choose the repository, branch, and hosting region for the new environment.

Cloning Environment Variables

  • Kuberns allows you to clone environment variables from one environment to another for consistency.
  • In the Environment section, select the option to clone variables from an existing environment.

For more details on managing environments, refer to the Environments guide.