kvaps/kubectl-build

Build dockerfiles directly in your Kubernetes cluster.

Shell

149

50 commits

updated Nov 18, 2021

See the code

README

Kubectl build

Kubectl build mimics the kaniko executor, but performs building on your Kubernetes cluster side.
This allows you to simply build your local dockerfiles remotely without leaving your cozy environment.

demo

Installation

using krew:

kubectl krew index add kvaps https://github.com/kvaps/krew-index
kubectl krew install kvaps/build

or using curl:

curl -LO https://github.com/kvaps/kubectl-build/raw/master/kubectl-build
chmod +x ./kubectl-build
sudo mv ./kubectl-build /usr/local/bin/kubectl-build

Usage

kubectl build [args]

Examples

# Show all kaniko commands
kubectl build --help

# Build from current directory
kubectl build --context . --no-push

# Specify namespace and kubeconfig
kubectl build --context . --no-push --namespace default --kubeconfig ~/.kube/someconfig

# Login to remote registry
docker login docker.io

# Short form
kubectl build -c . -d docker.io/some/image:latest

# Run debug shell
kubectl build -c . --no-push --debug

# Use cache building
kubectl build --context . --destination docker.io/some/image:latest --cache --cache-repo docker.io/some/cache

# Save image name and digest to file
kubectl build --context . --destination docker.io/some/image:latest --digest-file /tmp/digest --image-name-with-digest-file /tmp/image

# Build from stdin
tar -cvf- . | kubectl build --destination docker.io/some/image:latest --context tar://stdin

Extra configuration

While standard behavior of kubectl-build plugin intend to repeat kaniko executor options. The additional configuration can be specified by setting environment variables.

This may be useful for both having permanent configuration and setting CI-systems.

Enivroment VariableDescriptionDefault value
KUBECTL_BUILD_CONTEXTKubernetes context for creating pod (may be overriden by --kubecontext)current context
KUBECTL_BUILD_DOCKER_CONFIGPath to dockerconfig file to forward~/.docker/config.json
KUBECTL_BUILD_IMAGEKaniko-executor imagegcr.io/kaniko-project/executor
KUBECTL_BUILD_KEEP_PODIf set to true do not delete pod after finising processfalse
KUBECTL_BUILD_KUBECONFIGPath to kubeconfig file for creating pods (may be overriden by --kubeconfig)kubectl defaults
KUBECTL_BUILD_METADATA_OVERRIDESJson patch to override metadata for creating pods{}
KUBECTL_BUILD_NAME_OVERRIDEName for creating podkaniko-rand6n
KUBECTL_BUILD_NAMESPACEKubernetes namespace for creating pod (may be overriden by --namespace)current namespace
docker
kaniko
kubectl
kubectl-plugin
kubectl-plugins
kubernetes

Contributors

kvaps

49 commits

jpambrun

1 commits

kvaps/kubectl-build

Build dockerfiles directly in your Kubernetes cluster.

Shell

149

50 commits

updated Nov 18, 2021

See the code

README

Kubectl build

Kubectl build mimics the kaniko executor, but performs building on your Kubernetes cluster side.
This allows you to simply build your local dockerfiles remotely without leaving your cozy environment.

demo

Installation

using krew:

kubectl krew index add kvaps https://github.com/kvaps/krew-index
kubectl krew install kvaps/build

or using curl:

curl -LO https://github.com/kvaps/kubectl-build/raw/master/kubectl-build
chmod +x ./kubectl-build
sudo mv ./kubectl-build /usr/local/bin/kubectl-build

Usage

kubectl build [args]

Examples

# Show all kaniko commands
kubectl build --help

# Build from current directory
kubectl build --context . --no-push

# Specify namespace and kubeconfig
kubectl build --context . --no-push --namespace default --kubeconfig ~/.kube/someconfig

# Login to remote registry
docker login docker.io

# Short form
kubectl build -c . -d docker.io/some/image:latest

# Run debug shell
kubectl build -c . --no-push --debug

# Use cache building
kubectl build --context . --destination docker.io/some/image:latest --cache --cache-repo docker.io/some/cache

# Save image name and digest to file
kubectl build --context . --destination docker.io/some/image:latest --digest-file /tmp/digest --image-name-with-digest-file /tmp/image

# Build from stdin
tar -cvf- . | kubectl build --destination docker.io/some/image:latest --context tar://stdin

Extra configuration

While standard behavior of kubectl-build plugin intend to repeat kaniko executor options. The additional configuration can be specified by setting environment variables.

This may be useful for both having permanent configuration and setting CI-systems.

Enivroment VariableDescriptionDefault value
KUBECTL_BUILD_CONTEXTKubernetes context for creating pod (may be overriden by --kubecontext)current context
KUBECTL_BUILD_DOCKER_CONFIGPath to dockerconfig file to forward~/.docker/config.json
KUBECTL_BUILD_IMAGEKaniko-executor imagegcr.io/kaniko-project/executor
KUBECTL_BUILD_KEEP_PODIf set to true do not delete pod after finising processfalse
KUBECTL_BUILD_KUBECONFIGPath to kubeconfig file for creating pods (may be overriden by --kubeconfig)kubectl defaults
KUBECTL_BUILD_METADATA_OVERRIDESJson patch to override metadata for creating pods{}
KUBECTL_BUILD_NAME_OVERRIDEName for creating podkaniko-rand6n
KUBECTL_BUILD_NAMESPACEKubernetes namespace for creating pod (may be overriden by --namespace)current namespace
docker
kaniko
kubectl
kubectl-plugin
kubectl-plugins
kubernetes

Contributors

kvaps

49 commits

jpambrun

1 commits

Languages

Shell

100.0%