k8s-dockerbuilder

command module
v0.0.0-...-49c8991 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

README

Build & Push Docker images inside your Kubernetes cluster

Prerequisites for kubebuild CLI tool

  1. Given the CLI needs access to your Kubernetes cluster to build an image it would require an authenticated context. The CLI tool assumes a working Kubernetes config file at $HOME/.kube/config.

  2. To push the built docker image to your private container registry the CLI tool assumes a valid docker config json at $HOME/.docker/config

Quick run kubebuild CLI

# build the cli for your environment if needed
go build -o kubebuild .

# copy over the executable to your system's bin folder
sudo cp ./kubebuild /usr/local/bin/kubebuild

# See all commands
kubebuild help

# navigate to any local git repo and give the destination docker image tag as an argument (ie, hello/image:v0.0.1)
# NOTE: The builder assumes a Dockerfile is present in the git's origin repository directory
kubebuild build hello/image:v0.0.1

# If successful you should see a 'dockerbuild' job in your cluster
kubectl get jobs 

Required Environment Variables for Docker Container

  • GIT_PULL_REPO_URL - The URL of the Git Repository to pull (ie, https://username:token@github.com/yourorg/repo.git)
  • DOCKER_IMAGE_DESTINATION - The Docker Image Destination (ie, yourorg/repo:v0.0.1) to push after building
  • DOCKER_CONFIG_JSON - The Docker config JSON file (ie, cat ~/.docker/config.json) to use for authentication

Optional Environment Variables for Docker Container

  • GIT_BRANCH - The Git Branch to checkout and build from. By default it assumes the default branch on your external git repository

Quick start with a simple docker build locally

# build docker image
./buildDockerImage.sh

# run docker container
./runDockerDev.sh

# inside the docker container
./binutils/sampleKanikoUbuntuDockerBuild.sh

Documentation

Overview

Copyright 2022 Anton Mamonov <hi@antonmamonov.com> GNU GENERAL PUBLIC LICENSE

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL