Skip to content

Cube quickstart

Deploy an image as a Cube, change it, look at its log and roll it back, with the glac command line, the Python SDK or the console.

Cập nhật ngày

Trang này chưa được dịch sang Tiếng Việt: đây là bản tiếng Anh.

You need a project’s API key in GLAC_API_KEY, and glac or the Python SDK installed: get started says how. Cubes are deployed with the command line or the API; the console shows how each one stands.

The example runs the web server that Python carries, on port 8000, from a public image.

With the command line

Deploy the image as an app called hello. glac deploy waits until the version is ready and has the traffic, then prints the app’s address:

glac deploy public.ecr.aws/docker/library/python:3.12-alpine --name hello --port 8000 \
  --start-command '["python3", "-m", "http.server", "8000"]'

Open the address it printed in a browser, or with curl. The first request wakes an instance in a few milliseconds.

Look at the app and its log:

glac cube get hello                    # its address, the version that has the traffic, its scale
glac cube logs hello --since 10m       # what it printed, a line per request, what the platform did

Change it. A change of what a version is made of (here an environment variable) deploys a new version, and waits for it:

glac cube update hello -e GREETING=hi
glac cube versions hello               # version 2 has the traffic now

Send the traffic back to version 1, then delete the app:

glac cube rollback hello 1
glac cube rm hello

Every command takes --json and then prints what the API returned. glac help cube deploy lists every option; the command line page has the rest.

With the Python SDK

from glac import Glac

glac = Glac()  # GLAC_API_KEY and GLAC_API_URL
app = glac.cube.deploy(
    "public.ecr.aws/docker/library/python:3.12-alpine",
    name="hello",
    port=8000,
    start_command=["python3", "-m", "http.server", "8000"],
)
print(app.url)                        # its address

app.deploy(env={"GREETING": "hi"})    # version 2, waited for until it has the traffic
app.rollback(1)                       # the traffic goes back to version 1
for line in app.logs():               # every line of the days the plan keeps, then it stops
    print(line)
app.delete()

A version that does not come up raises DeployError, with the image’s own last words, and the traffic stays where it was. See the Python SDK page.

In the console

Open the [console](https://console.glac.ai/console/), pick the project, and choose Cube under Compute. Each app shows its address, the version that has the traffic, the one being deployed, its versions, and the last lines of its log. The page only shows: deploy, scale and roll back with the command line or the API.

Next

Điều hướng

Nhập để tìm…

↑↓ di chuyển↵ chọnEsc đóng