Skip to main content
Version: 1.0.0

Harnessing Zeet's GraphQL API for Programmatic Scaling

Zeet's GraphQL API is an incredibly versatile and powerful feature that allows you to deploy and manage your apps programmatically. With the capability to spin up numerous apps in just seconds, you can rapidly scale your platform to accommodate tens of thousands of users. This guide will explore the technical know-how behind how companies like Circle are utilizing the Zeet API to achieve remarkable growth and scalability.

1. Setting up your GraphQL API

Before you can start creating services and scaling them programmatically, you'll need to configure and familiairze yourself with the API.

The Getting Started section of the API reference covers how you can install and configure your Python or Javascript app to use the Zeet API.

We recommend that you then go through some of our example use cases as well as the available queries and mutations.

2. Creating a blueprint for your app

Now that you have your API configured and set up, let's create a "blueprint" for your app. In the next step, we will discuss how to efficiently spin any number of apps based off of this blueprint, with different configurations.

Specifically, we will be building a container image for your app and storing it in a container registry. In the next step, we will deploy an instance of this image with the desired configuration.

2.1 Select repo to build

To build a container image using Zeet, navigate to zeet.co/new/build or select "Build Container Image" in the Create New dropdown from your dashboard.

Now, connect your GitHub account and select the GitHub repository containing your app.

2.2 Select target registry

Next, select your target container registry. Note that a Null registry is only used for testing your build and does not save your build image anywhere.

2.3 Overview and build

Once you give your new Zeet app a name and build it, you should see something like this in your dashboard.

This Zeet app represents the container image that we have built. In the next step, we will deploy an instance of this app programatically and configure some specifc Environment Variables. Note that you can populate environment variables for your container image, these variables will be available to all apps deployed using this image.

3. Programmatically deploy and scale!

Now that we have built and published a container image to a container registry, we will deploy an instance of this image using the Zeet API. To achieve this, we will be using using the createProjectDocker mutation.

In your Node JS or Python app, you can craft the mutation like so:

 const req = gql`
mutation {
createProjectDocker(input: {
userID: $user_id,
name: "my-api-app",
projectName: "api-apps",
environmentName: "production",
deployTarget: {
deployTarget: "KUBERNETES",
clusterID: $cluster_id,
},
dockerImage: $build_image,
envs: [
{
name: "MY_API_KEY",
value: "1234567890",
sealed: false,
},
],
ports: [
{
port: "80",
protocol: "tcp",
public: true,
https: true,
},
],
}) {
id
}
}
`

Some important things to note:

  1. We can specify the projectName and environmentName you want to organize this app in.
  2. We provide the container image as $build_image
  3. We can pass in environment variables to the app in the envs field

This way, you can programatically spin up multiple apps using the same blueprint with different configuration passed to the app through Environment Variables!