-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] images/releng/ko-builder: Initial commit #2087
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: justaugustus The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Slack thread: https://kubernetes.slack.com/archives/CJH2GBF7Y/p1622038124127700 Here's the current state: ❯ time docker run -it -v $(pwd):/workspace gcr.io/k8s-staging-releng/ko-builder publish ./cmd/cip --local
2021/05/26 13:42:09 Using base gcr.io/distroless/static:nonroot for sigs.k8s.io/k8s-container-image-promoter/cmd/cip
2021/05/26 13:42:10 Building sigs.k8s.io/k8s-container-image-promoter/cmd/cip for linux/amd64
2021/05/26 13:42:43 Loading ko.local/cip-d9236763b0fdb29506a7a9abe4767208:b5a2ad2ce67333203fa09c3d4f35bf20ac1cc958d0b2b0935555a1c4965e136e
Error: failed to publish images: error publishing ko://sigs.k8s.io/k8s-container-image-promoter/cmd/cip: error loading image: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Usage:
ko publish IMPORTPATH... [flags]
Examples:
# Build and publish import path references to a Docker
# Registry as:
# ${KO_DOCKER_REPO}/<package name>-<hash of import path>
# When KO_DOCKER_REPO is ko.local, it is the same as if
# --local and --preserve-import-paths were passed.
ko publish github.com/foo/bar/cmd/baz github.com/foo/bar/cmd/blah
# Build and publish a relative import path as:
# ${KO_DOCKER_REPO}/<package name>-<hash of import path>
# When KO_DOCKER_REPO is ko.local, it is the same as if
# --local and --preserve-import-paths were passed.
ko publish ./cmd/blah
# Build and publish a relative import path as:
# ${KO_DOCKER_REPO}/<import path>
# When KO_DOCKER_REPO is ko.local, it is the same as if
# --local was passed.
ko publish --preserve-import-paths ./cmd/blah
# Build and publish import path references to a Docker
# daemon as:
# ko.local/<import path>
# This always preserves import paths.
ko publish --local github.com/foo/bar/cmd/baz github.com/foo/bar/cmd/blah
Flags:
--bare Whether to just use KO_DOCKER_REPO without additional context (may not work properly with --tags).
-B, --base-import-paths Whether to use the base path without MD5 hash after KO_DOCKER_REPO (may not work properly with --tags).
--disable-optimizations Disable optimizations when building Go code. Useful when you want to interactively debug the created container.
-h, --help help for publish
--image-label strings Which labels (key=value) to add to the image.
--insecure-registry Whether to skip TLS verification on the registry
-j, --jobs int The maximum number of concurrent builds (default 6)
-L, --local Load into images to local docker daemon.
--oci-layout-path string Path to save the OCI image layout of the built images
--platform string Which platform to use when pulling a multi-platform base. Format: all | <os>[/<arch>[/<variant>]][,platform]*
-P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO.
--push Push images to KO_DOCKER_REPO (default true)
-t, --tags strings Which tags to use for the produced image instead of the default 'latest' tag (may not work properly with --base-import-paths or --bare). (default [latest])
--tarball string File to save images tarballs
2021/05/26 13:42:44 error during command execution:failed to publish images: error publishing ko://sigs.k8s.io/k8s-container-image-promoter/cmd/cip: error loading image: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
docker run -it -v $(pwd):/workspace gcr.io/k8s-staging-releng/ko-builder 0.12s user 0.11s system 0% cpu 58.148 total |
/cc @wilsonehusin to get his insight on recent attempts. |
Some things to note from above:
Known issues:
|
This indicates that Do you expect to need to build and publish to a Docker daemon before (presumably) pushing the image to a registry? If not, you can remove the |
@imjasonh -- Thanks for the tip on Looking better now (outside of the expected auth failure): ❯ time docker run -it -v $(pwd):/workspace -e KO_DOCKER_REPO=gcr.io/k8s-staging-releng-test gcr.io/k8s-staging-releng/ko-builder publish ./cmd/cip
2021/05/26 14:55:55 No matching credentials were found, falling back on anonymous
2021/05/26 14:56:13 Using base gcr.io/distroless/static:nonroot for sigs.k8s.io/k8s-container-image-promoter/cmd/cip
2021/05/26 14:56:14 Building sigs.k8s.io/k8s-container-image-promoter/cmd/cip for linux/amd64
2021/05/26 14:57:13 Publishing gcr.io/k8s-staging-releng-test/cip-d9236763b0fdb29506a7a9abe4767208:latest
2021/05/26 14:57:13 No matching credentials were found for "gcr.io"
Error: failed to publish images: error publishing ko://sigs.k8s.io/k8s-container-image-promoter/cmd/cip: GET https://gcr.io/v2/token?scope=repository%3Ak8s-staging-releng-test%2Fcip-d9236763b0fdb29506a7a9abe4767208%3Apush%2Cpull&scope=repository%3Adistroless%2Fstatic%3Apull&service=gcr.io: UNAUTHORIZED: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication
Usage:
ko publish IMPORTPATH... [flags]
Examples:
# Build and publish import path references to a Docker
# Registry as:
# ${KO_DOCKER_REPO}/<package name>-<hash of import path>
# When KO_DOCKER_REPO is ko.local, it is the same as if
# --local and --preserve-import-paths were passed.
ko publish github.com/foo/bar/cmd/baz github.com/foo/bar/cmd/blah
# Build and publish a relative import path as:
# ${KO_DOCKER_REPO}/<package name>-<hash of import path>
# When KO_DOCKER_REPO is ko.local, it is the same as if
# --local and --preserve-import-paths were passed.
ko publish ./cmd/blah
# Build and publish a relative import path as:
# ${KO_DOCKER_REPO}/<import path>
# When KO_DOCKER_REPO is ko.local, it is the same as if
# --local was passed.
ko publish --preserve-import-paths ./cmd/blah
# Build and publish import path references to a Docker
# daemon as:
# ko.local/<import path>
# This always preserves import paths.
ko publish --local github.com/foo/bar/cmd/baz github.com/foo/bar/cmd/blah
Flags:
--bare Whether to just use KO_DOCKER_REPO without additional context (may not work properly with --tags).
-B, --base-import-paths Whether to use the base path without MD5 hash after KO_DOCKER_REPO (may not work properly with --tags).
--disable-optimizations Disable optimizations when building Go code. Useful when you want to interactively debug the created container.
-h, --help help for publish
--image-label strings Which labels (key=value) to add to the image.
--insecure-registry Whether to skip TLS verification on the registry
-j, --jobs int The maximum number of concurrent builds (default 6)
-L, --local Load into images to local docker daemon.
--oci-layout-path string Path to save the OCI image layout of the built images
--platform string Which platform to use when pulling a multi-platform base. Format: all | <os>[/<arch>[/<variant>]][,platform]*
-P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO.
--push Push images to KO_DOCKER_REPO (default true)
-t, --tags strings Which tags to use for the produced image instead of the default 'latest' tag (may not work properly with --base-import-paths or --bare). (default [latest])
--tarball string File to save images tarballs
2021/05/26 14:57:14 error during command execution:failed to publish images: error publishing ko://sigs.k8s.io/k8s-container-image-promoter/cmd/cip: GET https://gcr.io/v2/token?scope=repository%3Ak8s-staging-releng-test%2Fcip-d9236763b0fdb29506a7a9abe4767208%3Apush%2Cpull&scope=repository%3Adistroless%2Fstatic%3Apull&service=gcr.io: UNAUTHORIZED: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication
docker run -it -v $(pwd):/workspace -e gcr.io/k8s-staging-releng/ko-builder 0.15s user 0.20s system 0% cpu 1:37.35 total |
Signed-off-by: Stephen Augustus <[email protected]>
(No changes yet; just a rebase.) |
@justaugustus: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
Closing this out due to bandwidth. |
@justaugustus: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
FYI over in It's not ready for prime-time yet -- it's built from HEAD, and it doesn't include any support for cred helpers -- but if you're curious you can try it out:
Since this doesn't support cred helpers yet, that ☝️ assumes you have basic username/password auth in your Or, in a
(In GCB, a short-lived access token is automatically made available and kept refreshed in |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This is inspired by the Tekton ko build image (h/t @priyawadhwa): https://github.com/tektoncd/plumbing/blob/fe57aef52b996fa58ca2ff5529819c8706f2ac4b/tekton/images/ko-gcloud/Dockerfile
Here we attempt to provide a simpler means of building container images for the Golang applications we maintain via ko.
Signed-off-by: Stephen Augustus [email protected]
Which issue(s) this PR fixes:
Special notes for your reviewer:
This is likely missing a few things, but just getting it off of my local and in public early.
Does this PR introduce a user-facing change?