| | ( _ ) ___ | | ___ ___ | | |__ _____ __
| |/ / _ / || / _ \ / _ | | ' \ / _ \ / /
| < () _ _| || () | () | | |) | () > <
|_|__/|/ __/ _/||./ _/_/_\
Helper to install Kubernetes clusters, based on kind, on any Linux system. Allow to easily setup:
- multi-nodes cluster
- use of Calico CNI
- use of an insecure private registry
Can be used for VMs launched by a CI/CD platform, including Github Action
Support kind v0.10.0 and k8s v1.20
Run kind on a workstation, in two lines of code
# Sudo access is required here
K8S_TOOLBOX_VERSION="v1.0.0-rc1"
curl -sfL https://raw.githubusercontent.com/k8s-school/k8s-toolbox/$K8S_TOOLBOX_VERSION/install.sh | bash
# Run a single node k8s cluster with kind
k8s-toolbox create -s
# Run a 3 nodes k8s cluster with kind
k8s-toolbox create
# Run a k8s cluster with Calico CNI
k8s-toolbox create -c
# Delete the kind cluster
k8s-toolbox delete
Example for bash on Linux
# install bash-completion
sudo apt-get install bash-completion
# Add the completion script to your .bashrc file
echo 'source <(k8s-toolbox completion bash)' >>~/.bashrc
# Apply changes
source ~/.bashrc
If you have an alias for k8s-toolbox
, you can extend your shell's completion to work with this alias:
echo 'alias k8x=k8s-toolbox' >>~/.bashrc
echo 'complete -o default -F __start_k8s-toolbox k8x' >>~/.bashrc
Run kind inside Github Actions
Pre-requisites
- Create a Github repository for a given application, for example: https://github.com/<GITHUB_ACCOUNT>/<GITHUB_REPOSITORY>
Setup
Enable Github Action by creating file .github/workflow/itests.yaml
, based on template below:
name: "Install k8s cluster"
on:
push:
pull_request:
branches:
- master
jobs:
k8s-install:
name: Install k8s
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: '^1.20.3'
- name: Create k8s/kind cluster
run: |
go install github.com/k8s-school/k8s-toolbox@main
k8s-toolbox create -s
k8s-toolbox install kubectl
- name: Install and test application
run: |
kubectl create deployment my-nginx --image=nginx
kubectl expose deployment my-nginx --port=80