{"id":13820409,"url":"https://github.com/vmware-archive/buildkit-cli-for-kubectl","last_synced_at":"2025-05-16T10:30:51.476Z","repository":{"id":39566708,"uuid":"306426878","full_name":"vmware-archive/buildkit-cli-for-kubectl","owner":"vmware-archive","description":"BuildKit CLI for kubectl is a tool for building container images with your Kubernetes cluster","archived":true,"fork":false,"pushed_at":"2023-09-28T03:00:47.000Z","size":13414,"stargazers_count":500,"open_issues_count":42,"forks_count":41,"subscribers_count":20,"default_branch":"main","last_synced_at":"2024-05-19T08:07:42.642Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vmware-archive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-10-22T18:32:09.000Z","updated_at":"2024-04-25T15:42:07.000Z","dependencies_parsed_at":"2022-07-04T10:52:25.046Z","dependency_job_id":"c7d57007-32c5-4d42-a983-baa1ee70e910","html_url":"https://github.com/vmware-archive/buildkit-cli-for-kubectl","commit_stats":null,"previous_names":["vmware-tanzu/buildkit-cli-for-kubectl"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware-archive%2Fbuildkit-cli-for-kubectl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware-archive%2Fbuildkit-cli-for-kubectl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware-archive%2Fbuildkit-cli-for-kubectl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware-archive%2Fbuildkit-cli-for-kubectl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vmware-archive","download_url":"https://codeload.github.com/vmware-archive/buildkit-cli-for-kubectl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225349550,"owners_count":17460403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T08:01:02.892Z","updated_at":"2024-11-19T20:30:28.057Z","avatar_url":"https://github.com/vmware-archive.png","language":"Go","funding_links":[],"categories":["others","Go"],"sub_categories":[],"readme":"# BuildKit CLI for kubectl\n\n[![Build Status](https://github.com/vmware-tanzu/buildkit-cli-for-kubectl/actions/workflows/pull_request.yaml/badge.svg?branch=main)](https://github.com/vmware-tanzu/buildkit-cli-for-kubectl/actions/workflows/pull_request.yaml?query=workflow%3Apre-and-post-merge+branch%3Amain)\n[![codecov](https://codecov.io/gh/vmware-tanzu/buildkit-cli-for-kubectl/branch/main/graph/badge.svg)](https://codecov.io/gh/vmware-tanzu/buildkit-cli-for-kubectl)\n[![Go Report Card](https://goreportcard.com/badge/github.com/vmware-tanzu/buildkit-cli-for-kubectl)](https://goreportcard.com/report/github.com/vmware-tanzu/buildkit-cli-for-kubectl)\n\n\nBuildKit CLI for kubectl is a tool for building OCI and Docker images with your kubernetes cluster.\nIt replaces the `docker build` command to let you quickly and easily build your single and\nmulti-architecture container images.\n\n![Pants Cast](./docs/pants-cast.svg)\n\n## Features\n\n### Drop in replacement for `docker build`\n\nThe BuildKit CLI for kubectl replaces the `docker build` command with `kubectl build` to build\nimages in your kubernetes cluster, instead of on a single node. Your Dockerfile will be parsed\nthe same way as with the existing `docker build` command, and build flags should feel almost\nthe same.\n\n### Uses containerd or docker runtime environments\n\nRegardless of whether your Kubernetes cluster is using pure [containerd](https://containerd.io) or\n[docker](https://docker.com), the builder will be able to build OCI compatible images. These\nimages can be used inside of your cluster, or pushed to an image registry for distribution.\n\n### Works in numerous kubernetes environments\n\nThe BuildKit builder should work in most Kubernetes environments. We tested it with:\n\n  * [vSphere Tanzu](./docs/installing.md#vmware-vsphere-tanzu)\n  * Amazon EKS\n  * Minikube\n  * [VMware Fusion](./docs/installing.md#vmware-fusion)\n  * Docker Desktop\n  * k0s\n  * [k3d (limited support)](./docs/installing.md#k3d)\n\nYou should use Kubernetes version 1.14 or greater.\n\n\n### Supports building multi-architecture images\n\nIf you need to support building multi-architecture images, the builder can create those by\ncross-compiling your binaries. Multi-architecture images allow you to create images _with the same tag_\nso that when they are pulled, the correct image for the architecture will be used. This includes\narchitectures such as:\n\n * linux/amd64 (Intel based 64 bit images)\n * linux/386 (Intel based 32 bit images)\n * linux/arm/v7 (ARM based 32 bit images - Raspberry Pi)\n * linux/arm64 (ARM based 64 bit images)\n * windows/amd64 (Intel based 64 bit Windows images)\n\nFuture versions will include native builds in mixed clusters, as well as being able to\nemulate architectures when it's difficult to cross-compile. Check out the [multi-architecture](./docs/multiarch.md)\ndocumentation for more information.\n\n## Getting started\n\n### Installing on MacOS and Linux with Homebrew\n\nWe include a [Brew](https://docs.brew.sh/) Tap in this repo.  First add the Tap with\n```sh\nbrew tap vmware-tanzu/buildkit-cli-for-kubectl https://github.com/vmware-tanzu/buildkit-cli-for-kubectl\n```\n\nThen you can install with\n```sh\nbrew install kubectl-buildkit\n```\n\nKeep up-to-date with  `brew upgrade kubectl-buildkit` (or `brew upgrade` to upgrade everything)\n\n### Installing on Windows\n\nWe produce [Choco](https://docs.chocolatey.org/) compatible packages in our https://github.com/vmware-tanzu/buildkit-cli-for-kubectl/releases\nJust download the latest `nupkg` artifact and in a PowerShell Admin terminal, run\n```\nchoco install .\\kubectl-buildkit*.nupkg\n```\n\nNote: if you haven't already done so, you will need to run `choco install kubernetes-cli` once to get `kubectl` installed.\n### Installing on Linux\n\nWe also produce `.deb` and `.rpm` packages which should work for most distros in our https://github.com/vmware-tanzu/buildkit-cli-for-kubectl/releases\nJust download the latest artifact and use `yum install ./kubectl-buildkit*.rpm` or `apt install ./kubectl-buildkit*.deb`\n\n### Installing the tarball\n\nHead over to https://github.com/vmware-tanzu/buildkit-cli-for-kubectl/releases and download the `tgz` asset for your platform.\n\nOnce downloaded, extract it into your path.  For example, on MacOS\n```sh\ncat darwin-*.tgz | tar -C /usr/local/bin -xvf -\n```\n\nTest your install with\n```sh\nkubectl build --help\n```\n\n### Building from source\n\nCheck out our [contributing](./CONTRIBUTING.md) guide for instructions on setting up your environment and build instructions\n\n### Changing contexts\n\nIf you're using more than one kubernetes environment, switch to the context you wish to use with\nthe buildkit builder.\n\n```\nkubectl config get-contexts\nkubectl config use-context \u003ccontext name\u003e\n```\n\n### Creating a Kubernetes Registry Secret and Pushing\n\nIf you're going to push a newly created image to a container registry, you will need to store your\ncontainer registry credentials. This can be done either by passing a secret through a multi-stage\nDockerfile, or with a *registry secret* inside of Kubernetes.  Although either method can store your\nplaintext password, you should consider creating an API key in your registry to be more secure.\n\nTo create a registry secret inside of Kubernetes, use the command:\n\n```\nread -s REG_SECRET\nkubectl create secret docker-registry mysecret --docker-server='\u003cregistry hostname\u003e' --docker-username=\u003cuser name\u003e --docker-password=$REG_SECRET\nkubectl build --push --registry-secret mysecret -t \u003cregistry hostname\u003e/\u003cnamespace\u003e/\u003crepo\u003e:\u003ctag\u003e -f Dockerfile ./\n```\n\nHint: if you're trying to authenticate to Docker Hub, use `https://index.docker.io/v1/` as the `--docker-server`\n\n### Registry-based Caching\n\nBuildKit is smart about caching prior build results for efficient incremental\nbuilds.  This works great for a single-node scenario, but if you want to build\non a multi-node cluster, you can take advantage of BuildKit's ability to use a\nregistry for cache persistence.  This can have a significant improvement on\nincremental build times regardless of which node in the cluster your build lands\non.  For best performance, this registry should be \"local\" to the cluster.  The\nfollowing examples demonstrate this pattern:\n\n* [./examples/local-registry.yaml](./examples/local-registry.yaml) A kubernetes Deployment+Service to run a local registry (unauthenticated)\n* [./examples/local-registry-buildkitd.toml](./examples/local-registry-buildkitd.toml) A BuildKit TOML configuration example for the above Registry that configures it for **\"insecure\" access**\n\nTo setup from the root of this tree:\n```\nkubectl apply -f ./examples/local-registry.yaml\nkubectl buildkit create --config ./examples/local-registry-buildkitd.toml\n```\n\nYou can then build using the registry cache with the command:\n```\nkubectl build -t myimage --cache-to=type=registry,ref=registry:5000/cache --cache-from=type=registry,ref=registry:5000/cache .\n```\n\n## Custom Certs for Registries\n\nIf you happen to run a container image registry with non-standard certs (self signed, or signed by a private CA)\nyou can configure buildkitd to trust those certificates.\n\nFirst load your certs into a ConfigMap:\n```sh\nkubectl create configmap custom-root-certs --from-file=root_ca1.pem --from-file=root_ca2.pem\n```\n\nThen create a `buildkitd.toml` file for your registries where the certs above will be mounted into `/etc/config`\n```\ndebug = false\n[worker.containerd]\n  namespace = \"k8s.io\"\n[registry.\"myregistry1.acme.local\"]\n    ca=[\"/etc/config/root_ca1.pem\"]\n[registry.\"myregistry2.acme.local:5001\"]\n    ca=[\"/etc/config/root_ca2.pem\"]\n```\n\nYou can then create a customized builder with\n```\nkubectl buildkit create --custom-config=custom-root-certs --config ./buildkitd.toml\n```\n\n## Get in Touch\n\nIf you encounter issues or have questions/comments, you can find us on the CNCF Slack at\n[#buildkit-cli-for-kubectl](https://cloud-native.slack.com/messages/buildkit-cli-for-kubectl)\n\n## Contributing\n\nCheck out our [contributing](./CONTRIBUTING.md) for guidance on how to help contribute to the project.\n\nThis project wouldn't have been possble without the awesome upstream work from [BuildKit](https://github.com/moby/buildkit) which serves as the back-end builder, and [buildx](https://github.com/docker/buildx) which this CLI was derived from.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmware-archive%2Fbuildkit-cli-for-kubectl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvmware-archive%2Fbuildkit-cli-for-kubectl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmware-archive%2Fbuildkit-cli-for-kubectl/lists"}