Frequently Asked Questions
How can I set 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:
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.
Why are my images all created in 1970?
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:
or set the timestamp of the files in KO_DATA_PATH
to the latest git commit's timestamp with:
Can I build Windows containers?
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:
And build for windows/amd64
.
Known issues 🐛
- Symlinks in
kodata
are ignored when building Windows images; only regular files and directories will be included in the Windows image.
Does ko
support autocompletion?
Yes! ko completion
generates a Bash/Zsh/Fish/PowerShell completion script.
You can get how to load it from help document.
Or, you can source it directly:
Does 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.
Does 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'skbld
ko
extension for Tilt
Does ko
work with OpenShift Internal Registry?
Yes! Follow these steps:
- Connect to your OpenShift installation
- Expose the OpenShift Internal Registry so you can push to it:
- Export your token to
$HOME/.docker/config.json
:
- Create a namespace where you will push your images, i.e:
ko-images
- Execute this command to set
KO_DOCKER_REPO
to publish images to the internal registry.