From 9c2e46408e17f4fcfd5cb326cec2713e7653e30a Mon Sep 17 00:00:00 2001 From: <> Date: Wed, 15 Nov 2023 10:22:32 +0000 Subject: [PATCH] Deployed 84d3803 with MkDocs version: 1.5.3 --- .nojekyll | 0 404.html | 934 +++ CNAME | 1 + action/index.html | 15 + advanced/faq/index.html | 1200 +++ advanced/go-packages/index.html | 1025 +++ advanced/lambda/index.html | 1007 +++ advanced/limitations/index.html | 976 +++ advanced/migrating-from-dockerfile/index.html | 1072 +++ advanced/terraform/index.html | 998 +++ agenda/index.html | 15 + assets/images/favicon.png | Bin 0 -> 1870 bytes assets/javascripts/bundle.81fa17fe.min.js | 29 + assets/javascripts/bundle.81fa17fe.min.js.map | 7 + assets/javascripts/lunr/min/lunr.ar.min.js | 1 + assets/javascripts/lunr/min/lunr.da.min.js | 18 + assets/javascripts/lunr/min/lunr.de.min.js | 18 + assets/javascripts/lunr/min/lunr.du.min.js | 18 + assets/javascripts/lunr/min/lunr.el.min.js | 1 + assets/javascripts/lunr/min/lunr.es.min.js | 18 + assets/javascripts/lunr/min/lunr.fi.min.js | 18 + assets/javascripts/lunr/min/lunr.fr.min.js | 18 + assets/javascripts/lunr/min/lunr.he.min.js | 1 + assets/javascripts/lunr/min/lunr.hi.min.js | 1 + assets/javascripts/lunr/min/lunr.hu.min.js | 18 + assets/javascripts/lunr/min/lunr.hy.min.js | 1 + assets/javascripts/lunr/min/lunr.it.min.js | 18 + assets/javascripts/lunr/min/lunr.ja.min.js | 1 + assets/javascripts/lunr/min/lunr.jp.min.js | 1 + assets/javascripts/lunr/min/lunr.kn.min.js | 1 + assets/javascripts/lunr/min/lunr.ko.min.js | 1 + assets/javascripts/lunr/min/lunr.multi.min.js | 1 + assets/javascripts/lunr/min/lunr.nl.min.js | 18 + assets/javascripts/lunr/min/lunr.no.min.js | 18 + assets/javascripts/lunr/min/lunr.pt.min.js | 18 + assets/javascripts/lunr/min/lunr.ro.min.js | 18 + assets/javascripts/lunr/min/lunr.ru.min.js | 18 + assets/javascripts/lunr/min/lunr.sa.min.js | 1 + .../lunr/min/lunr.stemmer.support.min.js | 1 + assets/javascripts/lunr/min/lunr.sv.min.js | 18 + assets/javascripts/lunr/min/lunr.ta.min.js | 1 + assets/javascripts/lunr/min/lunr.te.min.js | 1 + assets/javascripts/lunr/min/lunr.th.min.js | 1 + assets/javascripts/lunr/min/lunr.tr.min.js | 18 + assets/javascripts/lunr/min/lunr.vi.min.js | 1 + assets/javascripts/lunr/min/lunr.zh.min.js | 1 + assets/javascripts/lunr/tinyseg.js | 206 + assets/javascripts/lunr/wordcut.js | 6708 +++++++++++++++++ .../workers/search.f886a092.min.js | 42 + .../workers/search.f886a092.min.js.map | 7 + assets/stylesheets/main.4b4a2bd9.min.css | 1 + assets/stylesheets/main.4b4a2bd9.min.css.map | 1 + assets/stylesheets/palette.356b1318.min.css | 1 + .../stylesheets/palette.356b1318.min.css.map | 1 + community/index.html | 1040 +++ configuration/index.html | 1254 +++ custom/main.html | 11 + custom/partials/copyright.html | 1 + deployment/index.html | 1117 +++ features/build-cache/index.html | 974 +++ features/k8s/index.html | 1131 +++ features/multi-platform/index.html | 976 +++ features/sboms/index.html | 975 +++ features/static-assets/index.html | 999 +++ get-started/index.html | 1105 +++ godoc/index.html | 15 + images/android-icon-192x192.png | Bin 0 -> 8300 bytes images/apple-icon-180x180.png | Bin 0 -> 7725 bytes images/apple-icon.png | Bin 0 -> 6927 bytes images/cncf.svg | 1 + images/demo.png | Bin 0 -> 243310 bytes images/favicon-16x16.png | Bin 0 -> 658 bytes images/favicon-32x32.png | Bin 0 -> 1279 bytes images/favicon-96x96.png | Bin 0 -> 4114 bytes images/ko-with-name.svg | 28 + images/ko.png | Bin 0 -> 4061 bytes images/ko.svg | 714 ++ images/ms-icon-144x144.png | Bin 0 -> 6181 bytes images/og.png | Bin 0 -> 58073 bytes index.html | 995 +++ install/index.html | 1147 +++ issues/index.html | 15 + prs/index.html | 15 + reference/ko/index.html | 1076 +++ reference/ko_apply/index.html | 1164 +++ reference/ko_build/index.html | 1158 +++ reference/ko_create/index.html | 1164 +++ reference/ko_delete/index.html | 1085 +++ reference/ko_login/index.html | 1106 +++ reference/ko_resolve/index.html | 1157 +++ reference/ko_run/index.html | 1146 +++ reference/ko_version/index.html | 1083 +++ releases/index.html | 15 + repo/index.html | 15 + search/search_index.json | 1 + sitemap.xml | 133 + sitemap.xml.gz | Bin 0 -> 411 bytes slack/index.html | 15 + terraform/index.html | 15 + 99 files changed, 37379 insertions(+) create mode 100644 .nojekyll create mode 100644 404.html create mode 100644 CNAME create mode 100644 action/index.html create mode 100644 advanced/faq/index.html create mode 100644 advanced/go-packages/index.html create mode 100644 advanced/lambda/index.html create mode 100644 advanced/limitations/index.html create mode 100644 advanced/migrating-from-dockerfile/index.html create mode 100644 advanced/terraform/index.html create mode 100644 agenda/index.html create mode 100644 assets/images/favicon.png create mode 100644 assets/javascripts/bundle.81fa17fe.min.js create mode 100644 assets/javascripts/bundle.81fa17fe.min.js.map create mode 100644 assets/javascripts/lunr/min/lunr.ar.min.js create mode 100644 assets/javascripts/lunr/min/lunr.da.min.js create mode 100644 assets/javascripts/lunr/min/lunr.de.min.js create mode 100644 assets/javascripts/lunr/min/lunr.du.min.js create mode 100644 assets/javascripts/lunr/min/lunr.el.min.js create mode 100644 assets/javascripts/lunr/min/lunr.es.min.js create mode 100644 assets/javascripts/lunr/min/lunr.fi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.fr.min.js create mode 100644 assets/javascripts/lunr/min/lunr.he.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hu.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hy.min.js create mode 100644 assets/javascripts/lunr/min/lunr.it.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ja.min.js create mode 100644 assets/javascripts/lunr/min/lunr.jp.min.js create mode 100644 assets/javascripts/lunr/min/lunr.kn.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ko.min.js create mode 100644 assets/javascripts/lunr/min/lunr.multi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.nl.min.js create mode 100644 assets/javascripts/lunr/min/lunr.no.min.js create mode 100644 assets/javascripts/lunr/min/lunr.pt.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ro.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ru.min.js create mode 100644 assets/javascripts/lunr/min/lunr.sa.min.js create mode 100644 assets/javascripts/lunr/min/lunr.stemmer.support.min.js create mode 100644 assets/javascripts/lunr/min/lunr.sv.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ta.min.js create mode 100644 assets/javascripts/lunr/min/lunr.te.min.js create mode 100644 assets/javascripts/lunr/min/lunr.th.min.js create mode 100644 assets/javascripts/lunr/min/lunr.tr.min.js create mode 100644 assets/javascripts/lunr/min/lunr.vi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.zh.min.js create mode 100644 assets/javascripts/lunr/tinyseg.js create mode 100644 assets/javascripts/lunr/wordcut.js create mode 100644 assets/javascripts/workers/search.f886a092.min.js create mode 100644 assets/javascripts/workers/search.f886a092.min.js.map create mode 100644 assets/stylesheets/main.4b4a2bd9.min.css create mode 100644 assets/stylesheets/main.4b4a2bd9.min.css.map create mode 100644 assets/stylesheets/palette.356b1318.min.css create mode 100644 assets/stylesheets/palette.356b1318.min.css.map create mode 100644 community/index.html create mode 100644 configuration/index.html create mode 100644 custom/main.html create mode 100644 custom/partials/copyright.html create mode 100644 deployment/index.html create mode 100644 features/build-cache/index.html create mode 100644 features/k8s/index.html create mode 100644 features/multi-platform/index.html create mode 100644 features/sboms/index.html create mode 100644 features/static-assets/index.html create mode 100644 get-started/index.html create mode 100644 godoc/index.html create mode 100644 images/android-icon-192x192.png create mode 100644 images/apple-icon-180x180.png create mode 100644 images/apple-icon.png create mode 100644 images/cncf.svg create mode 100644 images/demo.png create mode 100644 images/favicon-16x16.png create mode 100644 images/favicon-32x32.png create mode 100644 images/favicon-96x96.png create mode 100644 images/ko-with-name.svg create mode 100644 images/ko.png create mode 100644 images/ko.svg create mode 100644 images/ms-icon-144x144.png create mode 100644 images/og.png create mode 100644 index.html create mode 100644 install/index.html create mode 100644 issues/index.html create mode 100644 prs/index.html create mode 100644 reference/ko/index.html create mode 100644 reference/ko_apply/index.html create mode 100644 reference/ko_build/index.html create mode 100644 reference/ko_create/index.html create mode 100644 reference/ko_delete/index.html create mode 100644 reference/ko_login/index.html create mode 100644 reference/ko_resolve/index.html create mode 100644 reference/ko_run/index.html create mode 100644 reference/ko_version/index.html create mode 100644 releases/index.html create mode 100644 repo/index.html create mode 100644 search/search_index.json create mode 100644 sitemap.xml create mode 100644 sitemap.xml.gz create mode 100644 slack/index.html create mode 100644 terraform/index.html diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000000..e69de29bb2 diff --git a/404.html b/404.html new file mode 100644 index 0000000000..f2f359463b --- /dev/null +++ b/404.html @@ -0,0 +1,934 @@ + + + +
+ + + + + + + + + + + + + + + + + +ldflags
?Using -ldflags is a common way to embed version info in go binaries (In fact, we do this for ko
!).
+Unfortunately, because ko
wraps go build
, it's not possible to use this flag directly; however, you can use the GOFLAGS
environment variable instead:
GOFLAGS="-ldflags=-X=main.version=1.2.3" ko build .
+
+Currently, there is a limitation that does not allow to set multiple arguments in ldflags
using GOFLAGS
.
+Using -ldflags
multiple times also does not work.
+In this use case, it works best to use the builds
section in the .ko.yaml
file.
In order to support reproducible builds, ko
doesn't embed timestamps in the images it produces by default.
However, ko
does respect the SOURCE_DATE_EPOCH
environment variable, which will set the container image's timestamp accordingly.
Similarly, the KO_DATA_DATE_EPOCH
environment variable can be used to set the modtime timestamp of the files in KO_DATA_PATH
.
For example, you can set the container image's timestamp to the current timestamp by executing:
+export SOURCE_DATE_EPOCH=$(date +%s)
+
+or set the timestamp of the files in KO_DATA_PATH
to the latest git commit's timestamp with:
export KO_DATA_DATE_EPOCH=$(git log -1 --format='%ct')
+
+Yes, but support for Windows containers is new, experimental, and tenuous. Be prepared to file bugs. 🐛
+The default base image does not provide a Windows image.
+You can try out building a Windows container image by setting the base image to a Windows base image and building with --platform=windows/amd64
or --platform=all
:
For example, to build a Windows container image, update your .ko.yaml
to set the base image:
defaultBaseImage: mcr.microsoft.com/windows/nanoserver:ltsc2022
+
+And build for windows/amd64
.
ko build ./ --platform=windows/amd64
+
+kodata
are ignored when building Windows images; only regular files and directories will be included in the Windows image.ko
support autocompletion?Yes! ko completion
generates a Bash/Zsh/Fish/PowerShell completion script.
+You can get how to load it from help document.
ko completion [bash|zsh|fish|powershell] --help
+
+Or, you can source it directly:
+source <(ko completion)
+
+ko
work with Kustomize?Yes! ko resolve -f -
will read and process input from stdin, so you can have ko
easily process the output of the kustomize
command.
kustomize build config | ko resolve -f -
+
+ko
integrate with other build and development tools?Oh, you betcha. Here's a partial list:
+ko
support in Skaffoldko
support for goreleaserko
task in the Tekton catalogko
support in Carvel's kbld
ko
extension for Tiltko
work with OpenShift Internal Registry?Yes! Follow these steps:
+$HOME/.docker/config.json
:oc registry login --to=$HOME/.docker/config.json
+
+ko-images
KO_DOCKER_REPO
to publish images to the internal registry.export KO_DOCKER_REPO=$(oc registry info --public)/ko-images
+
+
+
+
+
+
+
+ ko
's functionality can be consumed as a library in a Go application.
To build an image, use pkg/build
, and publish it with pkg/publish
.
This is a minimal example of using the packages together, to implement the core subset of ko
's functionality:
package main
+
+import (
+ "context"
+ "fmt"
+ "log"
+
+ "github.com/google/go-containerregistry/pkg/authn"
+ "github.com/google/go-containerregistry/pkg/name"
+ "github.com/google/go-containerregistry/pkg/v1/remote"
+ "github.com/google/ko/pkg/build"
+ "github.com/google/ko/pkg/publish"
+)
+
+const (
+ baseImage = "cgr.dev/chainguard/static:latest"
+ targetRepo = "example.registry/my-repo"
+ importpath = "github.com/my-org/miniko"
+ commitSHA = "deadbeef"
+)
+
+func main() {
+ ctx := context.Background()
+
+ b, err := build.NewGo(ctx, ".",
+ build.WithPlatforms("linux/amd64"), // only build for these platforms.
+ build.WithBaseImages(func(ctx context.Context, _ string) (name.Reference, build.Result, error) {
+ ref := name.MustParseReference(baseImage)
+ base, err := remote.Index(ref, remote.WithContext(ctx))
+ return ref, base, err
+ }))
+ if err != nil {
+ log.Fatalf("NewGo: %v", err)
+ }
+ r, err := b.Build(ctx, importpath)
+ if err != nil {
+ log.Fatalf("Build: %v", err)
+ }
+
+ p, err := publish.NewDefault(targetRepo, // publish to example.registry/my-repo
+ publish.WithTags([]string{commitSHA}), // tag with :deadbeef
+ publish.WithAuthFromKeychain(authn.DefaultKeychain)) // use credentials from ~/.docker/config.json
+ if err != nil {
+ log.Fatalf("NewDefault: %v", err)
+ }
+ ref, err := p.Publish(ctx, r, importpath)
+ if err != nil {
+ log.Fatalf("Publish: %v", err)
+ }
+ fmt.Println(ref.String())
+}
+
+
+
+
+
+
+
+ ko
can build images that can be deployed as AWS Lambda functions, using Lambda's container support.
For best results, use the Go runtime interface client provided by the lambda
package.
For example:
+package main
+
+import (
+ "fmt"
+ "context"
+ "github.com/aws/aws-lambda-go/lambda"
+)
+
+type Event struct {
+ Name string `json:"name"`
+ // TODO: add other request fields here.
+}
+
+func main() {
+ lambda.Start(func(ctx context.Context, event Event) (string, error) {
+ return fmt.Sprintf("Hello %s!", event.Name), nil
+ }
+}
+
+See AWS's documentation for more information on writing Lambda functions in Go.
+To deploy to Lambda, you must push to AWS Elastic Container Registry (ECR):
+KO_DOCKER_REPO=[account-id].dkr.ecr.[region].amazonaws.com/my-repo
+image=$(ko build ./cmd/app)
+
+Then, create a Lambda function using the image in ECR:
+aws lambda create-function \
+ --function-name hello-world \
+ --package-type Image \
+ --code ImageUri=${image} \
+ --role arn:aws:iam::[account-id]:role/lambda-ex
+
+See AWS's documentation for more information on deploying Lambda functions using Go container images, including how to configure push access to ECR, and how to configure the IAM role for the function.
+The base image that ko
uses by default supports both x86 and Graviton2 architectures.
You can also use the ko
Terraform provider to build and deploy Lambda functions as part of your IaC workflow, using the aws_lambda_function
resource. See the provider example to get started.
ko
works best when your application has no dependencies on the underlying image.
This means ko
is ideal when you don't require cgo, and builds are executed with CGO_ENABLED=0
by default.
To install other OS packages, make those available in your configured base image.
+ko
only supports Go applications.
+For a similar tool targeting Java applications, try Jib.
+For other languages, try apko and melange.
If your Dockerfile
looks like either of the examples in the official tutorial for writing a Dockerfile to containerize a Go application, you can easily migrate to use ko
instead.
Let's review the best practice multi-stage Dockerfile in that tutorial first:
+# syntax=docker/dockerfile:1
+
+##
+## Build
+##
+FROM golang:1.16-buster AS build
+
+WORKDIR /app
+
+COPY go.mod ./
+COPY go.sum ./
+RUN go mod download
+
+COPY *.go ./
+
+RUN go build -o /docker-gs-ping
+
+##
+## Deploy
+##
+FROM gcr.io/distroless/base-debian10
+
+WORKDIR /
+
+COPY --from=build /docker-gs-ping /docker-gs-ping
+
+EXPOSE 8080
+
+USER nonroot:nonroot
+
+ENTRYPOINT ["/docker-gs-ping"]
+
+This Dockerfile
:
golang:1.16
imageCOPY
s your local source into the container environment (COPY
ing go.mod
and go.sum
first and running go mod download
, to cache dependencies in the container environment)RUN
s go build
on your source, inside the container, to produce an executableCOPY
s the executable built in the previous step into a new image, on top of a minimal distroless base image.The result is a Go application built on a minimal base image, with an optimally cached build sequence.
+After running docker build
on this Dockerfile
, don't forget to push that image to the registry so you can deploy it.
ko
If your Go source is laid out as described in the tutorial, and you've installed and set up your environment, you can simply run ko build ./
to build and push the container image to your registry.
You're done. You can delete your Dockerfile
and uninstall docker
.
ko
takes advantage of your local Go build cache without needing to be told to, and it sets the ENTRYPOINT
and uses a nonroot distroless base image by default.
To build a multi-arch image, simply add --platform=all
.
+Compare this to the equivalent Docker instructions.
In addition to the CLI, ko
's functionality is also available as a Terraform provider.
This allows ko
to be integrated with your Infrastructure-as-Code (IaC) workflows, and makes building your code a seamless part of your deployment process.
Using the Terraform provider is as simple as adding a ko_build
resource to your Terraform configuration:
// Require the `ko-build/ko` provider.
+terraform {
+ required_providers {
+ ko = { source = "ko-build/ko" }
+ }
+}
+
+// Configure the provider to push to your repo.
+provider "ko" {
+ repo = "example.registry/my-repo" // equivalent to KO_DOCKER_REPO
+}
+
+// Build your code.
+resource "ko_build" "app" {
+ importpath = "github.com/example/repo/cmd/app"
+}
+
+// TODO: use the `ko_build.app` resource elsewhere in your Terraform configuration.
+
+// Report the build image's digest.
+output "image" {
+ value = ko_build.app.image
+}
+
+See the ko-build/ko
provider on the Terraform Registry for more information, and the GitHub repo for more examples.
{"use strict";/*!
+ * escape-html
+ * Copyright(c) 2012-2013 TJ Holowaychuk
+ * Copyright(c) 2015 Andreas Lubbe
+ * Copyright(c) 2015 Tiancheng "Timothy" Gu
+ * MIT Licensed
+ */var Ha=/["'&<>]/;Un.exports=$a;function $a(e){var t=""+e,r=Ha.exec(t);if(!r)return t;var o,n="",i=0,s=0;for(i=r.index;i