Deploy Guide · Go

Deploy a Go Application

Ship your Go binary to a live HTTPS URL — zero server config.

Overview

Go produces small, fast, self-contained binaries that are ideal for container deployment. A Go HTTP server in a scratch or distroless container starts in milliseconds, which pairs perfectly with Kubeletto's scale-to-zero model — cold starts are virtually imperceptible.

Prerequisites

  • A Go module with a main package that starts an HTTP server
  • Go 1.21+ recommended
  • A Kubeletto account

Step-by-Step Guide

Deploying Go / net/http / Gin / Echo to Kubeletto is done by configuring a Dockerfile, connecting your GitHub repository, and setting environment variables. Follow this step-by-step checklist to deploy your code:

  1. 1

    Create a multi-stage Dockerfile

    Use a multi-stage build to produce a tiny final image with just your binary.

    dockerfile
    FROM golang:1.22-alpine AS builder
    WORKDIR /app
    COPY go.mod go.sum ./
    RUN go mod download
    COPY . .
    RUN CGO_ENABLED=0 GOOS=linux go build -o server ./cmd/server
    
    FROM gcr.io/distroless/static-debian12
    COPY --from=builder /app/server /server
    EXPOSE 8080
    ENTRYPOINT ["/server"]
  2. 2

    Bind to 0.0.0.0 and read PORT from env

    Kubeletto injects a PORT environment variable. Read it to avoid hardcoded port conflicts.

    go
    port := os.Getenv("PORT")
    if port == "" {
        port = "8080"
    }
    log.Fatal(http.ListenAndServe(":"+port, router))
  3. 3

    Deploy

    Connect your GitHub repo or deploy from CLI.

    bash
    kubeletto deploy --source github --repo your-org/go-api --branch main

Sample Environment Variables

To configure your Go / net/http / Gin / Echo application, set these key-value pairs in the environment variables tab of the Kubeletto console or CLI. Ensure production secrets are flagged as write-only:

.env
PORT=8080
DATABASE_URL=postgres://user:pass@host:5432/dbname
JWT_SECRET=your-secret
ENVIRONMENT=production

Related Kubeletto Features

Kubeletto offers automatic SSL certificate provisioning, zero-downtime rollbacks, and scale-to-zero autoscaling for Go / net/http / Gin / Echo container workloads:

PaaS Platform Comparisons

See how Kubeletto compares directly against other cloud platforms and PaaS providers when deploying Go workloads:

Frequently Asked Questions

Find direct answers to common questions about hosting, building, scaling, and managing Go / net/http / Gin / Echo containerized apps on Kubeletto:

How small will my Go container image be?

Using distroless/static or scratch base images, Go binaries typically produce 5–20MB final images. They pull and start extremely fast on Kubeletto.

Can I use CGO in my Go build?

CGO_ENABLED=0 is recommended for distroless builds. If you need CGO (e.g., SQLite), use a glibc-based base image like debian:bookworm-slim instead of distroless/static.

Does Kubeletto support WebSockets with Go?

Yes. Standard Go WebSocket servers (gorilla/websocket, nhooyr.io/websocket) work as-is. Knative Kourier supports WebSocket upgrades.

Deploy your Go / net/http / Gin / Echo app today

Free during our active beta. No credit card required.

Start Deploying Free