ko Go images, no Dockerfile
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
export KO_DOCKER_REPO=<registry/repo>
ko build ./cmd/<app>
ko run ./cmd/<app>
ko resolve -f config/
ko apply -f config/
ko build --local ./cmd/<app>
ko build --platform=all ./cmd/<app>
ko login <registry> -u <user>
Concepts
- Go package package main
- ko layer on base image
- KO_DOCKER_REPO digest reference
- Kubernetes YAML resolve / apply
| Flag | Resulting name |
|---|---|
(default) |
<repo>/<pkg>-<md5 of import path> |
-B |
<repo>/<last path element> |
-P |
<repo>/<full import path> |
--bare |
<repo> itself |
Build & publish
ko build <importpath>
ko build -B <importpath>
ko build -t <tag>
ko build --push=false <importpath>
ko build --local <importpath>
ko build --bare <importpath>
ko build -P <importpath>
ko build --image-refs <file> <importpath>
ko build --tag-only <importpath>
ko build --tarball <file> <importpath>
ko build --oci-layout-path <dir>
<importpath>
ko build --ldflags <flags> <importpath>
ko build --insecure-registry <importpath>
Platforms & images
ko build --platform=all <importpath>
ko build --platform=linux/amd64,linux/arm64
<importpath>
ko build --image-label <k>=<v>
<importpath>
ko build --image-annotation <k>=<v>
<importpath>
ko build --image-user <user> <importpath>
ko build --sbom=none <importpath>
ko build --sbom-dir <dir> <importpath>
ko build --debug <importpath>
ko build --disable-optimizations <importpath>
| Value | Meaning |
|---|---|
all |
All platforms of the base image |
linux/arm64 |
os/arch |
linux/arm/v7 |
os/arch/variant |
a,b |
Comma-separated list |
Kubernetes
ko resolve -f <path>
ko resolve -f <path> | kubectl apply -f -
ko apply -f <path>
ko apply -f <path> -- <kubectl flags>
ko apply -R -f <dir>
ko resolve -l <key>=<value> -f
<path>
ko create -f <path>
ko delete -f <path>
ko run <importpath>
ko run <importpath> -- <app args>
containers:- name: app image: ko://github.com/<user>/<repo>/cmd/app
Config & environment
KO_DOCKER_REPOKO_DEFAULTBASEIMAGE
KO_DEFAULTPLATFORMS
KO_CONFIG_PATHKOCACHEKIND_CLUSTER_NAME
KO_DATA_PATH| Key | Sets |
|---|---|
defaultBaseImage |
Base image for all builds |
baseImageOverrides |
Base image per import path |
defaultPlatforms |
Target platforms |
defaultEnv / defaultFlags / defaultLdflags
|
Build defaults |
builds |
Per-build id, dir, main, env, flags, ldflags |
Auth
ko login <registry> -u <user> -p
<pass>
ko login <registry> -u <user>
--password-stdin
ko versionRecipes
export KO_DOCKER_REPO=ghcr.io/<user>/<repo>ko apply -f config/# manifests use image: ko://github.com/<user>/<repo>/cmd/app
export KO_DOCKER_REPO=ghcr.io/<user>/<repo>ko build -B -t v1.2.3 --platform=linux/amd64,linux/arm64 ./cmd/app
ko build --local -B ./cmd/appdocker run --rm ko.local/app:latest
ko resolve -f config/ > release.yamlkubectl apply -f release.yaml



