Platform
Use cases
Resources
← Back to Changelog
23rd November 2020

Northflank CLI & Extended API

In addition to the UI and API, you can now interact with Northflank using a Command Line Interface. Local deveploment becomes even easier with the ability to proxy your remote databases and services to your machine. The Northflank CLI comes with RBAC so you can securely share services with developers in your team.

Install the Northflank CLI with npm i @northflank/cli -g or yarn global add @northflank/cli. To log in, you will need to create an API token in your user or team account.

Available commands

forward           Port-forwarding for Northflank services and addons
login [options]   Connect the CLI to your Northflank account
context|contexts  Retrieve and update local context settings
list              List Northflank resources
create            Create Northflank resources
get               Get information about Northflank resources
delete            Delete Northflank resources
scale             Scale Northflank resources
update            Update Northflank resource properties
restart           Restart Northflank resources
pause             Pause Northflank resources
resume            Resume Northflank resources
help [command]    display help for command

Creating a service

To create a deployment service, use the create deploymentService command. You can also create other service types or projects:

project|projects [options]   Creates a new project.
combinedService [options]    Creates a new combined service.
deploymentService [options]  Creates a new deployment service.
buildService [options]       Creates a new build service.

Forwarding resources for local development

You can choose which services and addons to forward or select all project resources using the forward all command. This allows you to connect directly to your applications and databases without having to publically expose them.

Extended API

We have expanded the Northflank API so you can interact with your Northflank resources directly in your code. Documenation is available here.

const payload = {
  name: 'My awesome service',
  description: 'Example deployment service',
  billing: {
      deploymentPlan: 'micro'
  },
  deployment: {
    instances: 1,
    external: {
      registryProvider: 'dockerhub',
      imagePath: 'nginx:latest',
      privateImage: false,
    },
  },
  ports: [{ name: 'default-port', internalPort: 80, public: true, protocol: 'HTTP' }],
};
const response = await fetch(NORTHFLANK_API_ENDPOINT, {
  method: 'POST',
  headers: {
  	'Accept': 'application/json',
  	'Content-Type': 'application/json',
  	'Authorization': `Bearer ${NORTHFLANK_API_TOKEN}`,
},
  body: JSON.stringify(payload),
});
const { serviceType, serviceId } = await response.json()
console.log(`Deployed a service of type ${serviceType} with the ID ${serviceId}!`)
// => Deployed a service of type deployment with the ID my-awesome-service

Share this article with your network
X