├── .dockerignore ├── Dockerfile ├── LICENSE ├── README.md ├── k8s-cli-ps1.sh ├── k8s-cli-toolset.png └── kubie.yaml /.dockerignore: -------------------------------------------------------------------------------- 1 | *.md 2 | LICENSE -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:19.10 2 | 3 | ARG IMAGE_CREATE_DATE 4 | ARG IMAGE_VERSION 5 | ARG IMAGE_SOURCE_REVISION 6 | ARG KUBECTL_VERSION=1.18.1 7 | ARG KUBIE_VERSION=0.8.3 8 | ARG ISTIO_VERSION=1.5.1 9 | ARG LINKERD_VERSION=2.7.1 10 | ARG HELM_VERSION=3.1.2 11 | ARG KUBE_PS1_VERSION=0.7.0 12 | 13 | ENV LANG C.UTF-8 14 | 15 | # Metadata as defined in OCI image spec annotations - https://github.com/opencontainers/image-spec/blob/master/annotations.md 16 | LABEL org.opencontainers.image.title="Kubernetes cli toolset" \ 17 | org.opencontainers.image.description="Provides the following Kubernetes cli toolset - kubectl $KUBECTL_VERSION, kubie $KUBIE_VERSION, istioctl $ISTIO_VERSION, linkerd $LINKERD_VERSION, and helm $HELM_VERSION. Leverages kube-ps1 $KUBE_PS1_VERSION to provide the current Kubernetes context and namespace on the bash prompt." \ 18 | org.opencontainers.image.created=$IMAGE_CREATE_DATE \ 19 | org.opencontainers.image.version=$IMAGE_VERSION \ 20 | org.opencontainers.image.authors="Paul Bouwer" \ 21 | org.opencontainers.image.url="https://hub.docker.com/r/paulbouwer/k8s-cli-toolset/" \ 22 | org.opencontainers.image.documentation="https://github.com/paulbouwer/k8s-cli-toolset" \ 23 | org.opencontainers.image.vendor="Paul Bouwer" \ 24 | org.opencontainers.image.licenses="MIT" \ 25 | org.opencontainers.image.source="https://github.com/paulbouwer/k8s-cli-toolset.git" \ 26 | org.opencontainers.image.revision=$IMAGE_SOURCE_REVISION 27 | 28 | # Install dependencies and create dirs 29 | RUN apt-get update && apt-get install -y --no-install-recommends \ 30 | bash-completion \ 31 | ca-certificates \ 32 | curl \ 33 | fzf \ 34 | git \ 35 | jq \ 36 | less \ 37 | vim \ 38 | && echo ". /etc/bash_completion" >> ~/.bashrc \ 39 | && rm -rf /var/lib/apt/lists/* \ 40 | && mkdir -p ~/completions \ 41 | && mkdir -p ~/k8s-prompt 42 | 43 | WORKDIR /tmp/install-utils 44 | 45 | # Install kubectl 46 | # License: Apache-2.0 47 | RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl \ 48 | && chmod +x ./kubectl \ 49 | && mv ./kubectl /usr/local/bin/kubectl \ 50 | && kubectl completion bash > ~/completions/kubectl.bash \ 51 | && echo "source ~/completions/kubectl.bash" >> ~/.bashrc 52 | 53 | # Install kubie 54 | # License: Zlib 55 | RUN curl -LO https://github.com/sbstp/kubie/releases/download/v$KUBIE_VERSION/kubie-linux-amd64 \ 56 | && chmod +x ./kubie-linux-amd64 \ 57 | && mv ./kubie-linux-amd64 /usr/local/bin/kubie \ 58 | && curl -LO https://raw.githubusercontent.com/sbstp/kubie/master/completion/kubie.bash \ 59 | && mv kubie.bash ~/completions/ \ 60 | && echo "source ~/completions/kubie.bash" >> ~/.bashrc 61 | 62 | # Install linkerd 63 | # License: Apache-2.0 64 | RUN curl -LO https://github.com/linkerd/linkerd2/releases/download/stable-$LINKERD_VERSION/linkerd2-cli-stable-$LINKERD_VERSION-linux \ 65 | && mv ./linkerd2-cli-stable-$LINKERD_VERSION-linux /usr/local/bin/linkerd \ 66 | && chmod +x /usr/local/bin/linkerd \ 67 | && linkerd completion bash > ~/completions/linkerd.bash \ 68 | && echo "source ~/completions/linkerd.bash" >> ~/.bashrc 69 | 70 | # Install istioctl 71 | # License: Apache-2.0 72 | RUN curl -L https://github.com/istio/istio/releases/download/$ISTIO_VERSION/istio-$ISTIO_VERSION-linux.tar.gz | tar xz \ 73 | && cd ./istio-$ISTIO_VERSION \ 74 | && mv bin/istioctl /usr/local/bin/ \ 75 | && chmod +x /usr/local/bin/istioctl \ 76 | && cd ../ \ 77 | && rm -fr ./istio-$ISTIO_VERSION \ 78 | && istioctl collateral --bash -o ~/completions \ 79 | && echo "source ~/completions/istioctl.bash" >> ~/.bashrc 80 | 81 | # Install helm 82 | # License: Apache-2.0 83 | RUN mkdir helm-$HELM_VERSION \ 84 | && curl -L https://get.helm.sh/helm-v$HELM_VERSION-linux-amd64.tar.gz | tar xz -C helm-$HELM_VERSION --strip-components 1 \ 85 | && cd ./helm-$HELM_VERSION \ 86 | && mv helm /usr/local/bin/ \ 87 | && chmod +x /usr/local/bin/helm \ 88 | && cd ../ \ 89 | && rm -fr ./helm-$HELM_VERSION \ 90 | && helm completion bash > ~/completions/helm.bash \ 91 | && echo "source ~/completions/helm.bash" >> ~/.bashrc 92 | 93 | # Install kube-ps1 94 | # License: Apache-2.0 95 | COPY k8s-cli-ps1.sh /root/k8s-prompt/ 96 | RUN curl -L https://github.com/jonmosco/kube-ps1/archive/v$KUBE_PS1_VERSION.tar.gz | tar xz \ 97 | && cd ./kube-ps1-$KUBE_PS1_VERSION \ 98 | && mv kube-ps1.sh ~/k8s-prompt/ \ 99 | && chmod +x ~/k8s-prompt/*.sh \ 100 | && rm -fr ./kube-ps1-$KUBE_PS1_VERSION \ 101 | && echo "source ~/k8s-prompt/kube-ps1.sh" >> ~/.bashrc \ 102 | && echo "source ~/k8s-prompt/k8s-cli-ps1.sh" >> ~/.bashrc \ 103 | && echo "PROMPT_COMMAND=\"_kube_ps1_update_cache && k8s_cli_ps1\"" >> ~/.bashrc 104 | 105 | RUN rm -fr /tmp/install-utils \ 106 | && echo "alias k=kubectl" >> ~/.bashrc \ 107 | && echo "complete -o default -F __start_kubectl k" >> ~/.bashrc 108 | 109 | WORKDIR /workspace 110 | CMD bash -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Paul Bouwer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kubernetes CLI Toolset 2 | 3 | Provides the following [Kubernetes](https://kubernetes.io/) cli toolset: 4 | 5 | - kubectl **1.18.1** (with command completion) 6 | - kubie **0.8.3** (with command completion) 7 | - linkerd **stable-2.7.1** (with command completion) 8 | - istioctl **1.5.1** (with command completion) 9 | - helm **3.2.2** (with command completion) 10 | 11 | And the following utilities/tools: 12 | 13 | - curl 14 | - git 15 | - jq 16 | - less 17 | - vim 18 | 19 | Leverages kube-ps1 **0.7.0** to provide the current Kubernetes context and namespace on the bash prompt. The bash prompt works well with the [Nerd Font patched Cascadia Code](https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/CascadiaCode) font. 20 | 21 | ![Alt text](k8s-cli-toolset.png) 22 | 23 | ## Toolset 24 | 25 | ### kubectl 26 | 27 | [Kubernetes](https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/) is an open-source platform for automating deployment, scaling, and operations of application containers across clusters of hosts, providing container-centric infrastructure. Kubernetes is: 28 | 29 | - **Portable** - public, private, hybrid, multi-cloud 30 | - **Extensible** - modular, pluggable, hookable, composable 31 | - **Self-healing** - auto-placement, auto-restart, auto-replication, auto-scaling 32 | 33 | > [kubectl](https://kubernetes.io/docs/user-guide/kubectl-overview/) is a command line utility for running [commands](https://kubernetes.io/docs/user-guide/kubectl/v1.7/) against Kubernetes clusters. kubectl is configured with [command completion](https://kubernetes.io/docs/tasks/tools/install-kubectl/#on-linux-using-bash). 34 | 35 | ### kubie 36 | 37 | [kubie](https://github.com/sbstp/kubie) is an alternative to **kubectx**, **kubens** and the **k on** prompt modification script. It offers context switching, namespace switching and prompt modification in a way that makes each shell independent from others. It also has support for split configuration files, meaning it can load Kubernetes contexts from multiple files. You can configure the paths where kubie will look for contexts. 38 | 39 | A sample `kubie.yaml` file is included in this repo. Place this file in your `~/.kube` folder. 40 | 41 | ### linkerd 42 | 43 | [Linkerd](https://linkerd.io/2/overview/) is a service mesh for Kubernetes and other frameworks. It makes running services easier and safer by giving you runtime debugging, observability, reliability, and security—all without requiring any changes to your code. 44 | 45 | > The [linkerd](https://linkerd.io/2/reference/cli/) CLI is the primary way to interact with Linkerd. It can install the control plane to your cluster, add the proxy to your service and provide detailed metrics for how your service is performing. 46 | 47 | ### istioctl 48 | 49 | [Istio](https://istio.io) is an open platform that provides a uniform way to connect, manage, and secure microservices. Istio supports managing traffic flows between microservices, enforcing access policies, and aggregating telemetry data, all without requiring changes to the microservice code. Istio gives you: 50 | 51 | > [istioctl](https://istio.io/docs/reference/commands/istioctl.html) is a command line utility to create, list, modify, and delete configuration resources in the [Istio](https://istio.io/) system. 52 | 53 | ### helm 54 | 55 | [Helm](https://docs.helm.sh/) is the package manager for Kubernetes. It is a tool that streamlines installing and managing Kubernetes applications. Think of it like apt/yum/homebrew for Kubernetes. 56 | 57 | > [helm](https://github.com/kubernetes/helm) is a tool for managing Helm Charts. Helm Charts are packages of pre-configured Kubernetes resources. Only the helm client is installed. You will need to install the tiller component into your Kubernetes cluster using `helm init`. 58 | 59 | ### kube-ps1 60 | 61 | [kube-ps1](https://github.com/jonmosco/kube-ps1) is a script that lets you add the current Kubernetes context and namespace configured on kubectl to your bash/zsh prompt strings (i.e. the `$PS1`). It has been leveraged in this image to provide a customised prompt that provides information about the Kubernetes cluster that `kubectl` is currently targeting. 62 | 63 | ## Docker image 64 | 65 | The Docker image is built on top of the `Ubuntu 19.10` base image to provide a full weight environment. It is available on DockerHub as: 66 | 67 | - [paulbouwer/k8s-cli-toolset:0.15](https://hub.docker.com/r/paulbouwer/k8s-cli-toolset/) 68 | 69 | ### Run 70 | 71 | Run the image as follows. Ensure that you mount your ~/.kube and ~/.helm folders on your host into the Docker container for the utilities to operate correctly. 72 | 73 | Windows 74 | ``` 75 | PS> docker run -it --rm -v ${HOME}/.kube:/root/.kube -v ${HOME}/.helm:/root/.helm paulbouwer/k8s-cli-toolset:0.15 76 | ``` 77 | 78 | Linux/MacOS 79 | ``` 80 | $ docker run -it --rm -v ${HOME}/.kube:/root/.kube -v ${HOME}/.helm:/root/.helm paulbouwer/k8s-cli-toolset:0.15 81 | ``` 82 | 83 | ### Build 84 | 85 | If you'd like to build the image yourself, then you can do so as follows. The `build-arg` parameters provide values to the Docker image labels which follow the [OCI Image Spec Annotations](https://github.com/opencontainers/image-spec/blob/master/annotations.md) convention. 86 | 87 | Powershell 88 | ``` 89 | PS> docker build --no-cache --build-arg IMAGE_VERSION="0.15" --build-arg IMAGE_CREATE_DATE="$(Get-Date((Get-Date).ToUniversalTime()) -UFormat '%Y-%m-%dT%H:%M:%SZ')" --build-arg IMAGE_SOURCE_REVISION="$(git rev-parse HEAD)" -f Dockerfile -t "k8s-cli-toolset:0.15" . 90 | ``` 91 | 92 | Bash 93 | ``` 94 | $ docker build --no-cache --build-arg IMAGE_VERSION="0.15" --build-arg IMAGE_CREATE_DATE="`date -u +"%Y-%m-%dT%H:%M:%SZ"`" --build-arg IMAGE_SOURCE_REVISION="`git rev-parse HEAD`" -f Dockerfile -t "k8s-cli-toolset:0.15" . 95 | ``` -------------------------------------------------------------------------------- /k8s-cli-ps1.sh: -------------------------------------------------------------------------------- 1 | k8s_cli_ps1() { 2 | [ -f "${KUBE_PS1_DISABLE_PATH}" ] && return 3 | 4 | export PS1=$'\n\e[0;37;100m k8s-cli \e[0;90;43m\UE0B0\e[0;90;43m ${KUBE_PS1_CONTEXT}/${KUBE_PS1_NAMESPACE} \e[0;33;44m\UE0B0\e[0;37;44m \w \e[0;34;40m\UE0B0\e[0;39m\n$ ' 5 | } 6 | -------------------------------------------------------------------------------- /k8s-cli-toolset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbouwer/k8s-cli-toolset/16e4f3090ecb6a064e1c9c7f60a407f5ca5b71d5/k8s-cli-toolset.png -------------------------------------------------------------------------------- /kubie.yaml: -------------------------------------------------------------------------------- 1 | # Force kubie to use a particular shell, if unset detect shell currently in use. 2 | # Possible values: bash, dash, fish, zsh 3 | # Default: unset 4 | shell: bash 5 | 6 | # Configure where to look for kubernetes config files. 7 | configs: 8 | 9 | # Include these globs. 10 | include: 11 | - ~/.kube/config 12 | - ~/.kube/*.config 13 | 14 | # Exclude these globs. 15 | # Note: kubie's own config file is always excluded. 16 | exclude: 17 | - ~/.kube/kubie.yaml 18 | 19 | # Prompt settings. 20 | prompt: 21 | # Disable kubie's custom prompt inside of a kubie shell. This is useful 22 | # when you already have a prompt displaying kubernetes information. 23 | # Default: false 24 | disable: true 25 | 26 | # When using recursive contexts, show depth when larger than 1. 27 | # Default: true 28 | show_depth: true 29 | 30 | # When using zsh, show context and namespace on the right side using RPS1. 31 | # Default: false 32 | zsh_use_rps1: false --------------------------------------------------------------------------------