Git Product home page Git Product logo

kubectl-container's Introduction

Kubectl with auto-completion in a docker container

The purpose of this tool is to have a fully portable kubectl command line tool with a few convinience utilities. Quick testing of a cluster with well-known/customized kubectl setup.

What is included

to see all the packages installed in both tags, you can use docker sbom command

KUBECTL_COMP_VERSION=v1.0.0
docker sbom piotrzan/kubectl-comp:"$KUBECTL_COMP_VERSION"-bash
docker sbom piotrzan/kubectl-comp:"$KUBECTL_COMP_VERSION"-zsh

There are two images, one simple image with bash shell containing:

  • kubectl - latest

    It is easy to override kubectl version by using --build-arg flag in docker build command docker build --build-arg KUBECTL_VERSION=v1.19.4 --rm -f "Dockerfile" -t piotrzan/kubectl-comp:v1.0.0-bash "."

  • useful aliases

Use this image if you want to quickly check and explore Kubernetes cluster without investing too much time. This image is optimized for size performance and is based on Apline base image and is 16 MB compressed size.

And one is a fancy image for zsh with more tools preinstalled:

  • kubectl - latest
  • zsh-autosuggestions - very useful zsh shell plugin showing previous commands and enabling easy autofill of text
  • helm - Kubernetes package manager
  • okteto - development platform for Kubernetes applications
  • k9s - cluster monitoring tool
  • kubectx - easily switch between Kubernetes contexts
  • kubens - easily switch between Kubernetes namespaces
  • tmux based on highly customized, great repo from samoshkin
  • popular tools: curl, wget, git
  • useful aliases

Use this image if you want to monitor and develop for Kubernetes. This is my default image with all favourite tools and settings. This image is optimized for usability and is based on Ubuntu base image and is 168 MB compressed size.

How to use

After running docker container, all the clusters running on the localhost should be available for kubectl command.

Aliases

Make use of aliases defined for both shells bash and zsh

Instead of typing kubectl all the time, abbreviate it to just “k”

alias k=kubectl

Check what is running on the cluster

alias kdump='kubectl get all --all-namespaces'

Display helpful info for creating k8s resources imperatively

alias krun='k run -h | grep “# “ -A2'

Quickly spin up busybox pod for diagnostic purposes

alias kdiag='kubectl run -it --rm debug --image=busybox --restart=Never -- sh'

Supported tags

  • zsh docker pull piotrzan/kubectl-comp:v1.0.0-zsh Dockerfile

  • bash docker pull piotrzan/kubectl-comp:v1.0.0-bash Dockerfile

How the images are build

Build image with bash shell

docker build --rm -f "Dockerfile" -t piotrzan/kubectl-comp:v1.0.0-bash "."

Build image with zsh shell

docker build --rm -f "Dockerfile" -t piotrzan/kubectl-comp:v1.0.0-zsh "."

Convinient scripts to run the contianer

Use run.ps1 or run.sh for windows or linux respectivels. Alternatively use docker-compose.yaml, this works by mounting a volume on the $HOME/.kube folder on the host.

Another option is running make (defaults to content of run script). Make can be run from root directory and will run images depending on the tasks. Linux has make installed by default, for Windows please install first Make for Windows.

ZSH container will be ran by default.

Linux Example

By default make command will run zsh container with direct mount on the ($home)/.kube directory.

Run contianer with passthrough to local network

docker run -d --network=host --name=kubectl-host --rm -it piotrzan/kubectl-comp:v1.0.0-bash

Generate raw config from kubeclt on localhost and copy the config to the container

kubectl config view --raw > config
docker cp ./config kubectl-host:./root/.kube

Attach back to the contianer with kubeconfig file containing info about clusters running on localhost

docker attach kubectl-host

Extending the image

If you would like to add your own customization, you can easily do it and use docker commit to create your own version of the image.

docker commit $(docker ps -aqf "name=kubectl-host") piotrzan/kubectl-comp:v1.0.0-zsh - this captures contianer kubectl-host as a new tag docker push piotrzan/kubectl-comp:v1.0.0-zsh

kubectl-container's People

Contributors

piotr1215 avatar renovate[bot] avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

kubectl-container's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

docker-compose
bash/docker-compose.yaml
zsh/docker-compose.yaml
dockerfile
bash/Dockerfile
  • alpine 3
  • alpine 3
zsh/Dockerfile
  • ubuntu 23.10
github-actions
.github/workflows/build_push_bash.yml
  • docker/setup-qemu-action v2
  • docker/setup-buildx-action v2
  • docker/login-action v2
  • docker/build-push-action v3.2.0
.github/workflows/build_push_zsh.yml
  • docker/setup-qemu-action v2
  • docker/setup-buildx-action v2
  • docker/login-action v2
  • docker/build-push-action v3.2.0
regex
zsh/Dockerfile
  • kubernetes/kubernetes v1.26.1
  • derailed/k9s v0.26.7
  • kubernetes-sigs/krew v0.4.3
  • kubernetes-sigs/krew 0.18.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.