Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Trendyol/kink
KinK is a helper CLI that facilitates to manage KinD clusters as Kubernetes pods. Designed to ease clusters up for fast testing with batteries included in mind.
https://github.com/Trendyol/kink
cobra go go-cli kind kind-in-kubernetes kubernetes
Last synced: 3 months ago
JSON representation
KinK is a helper CLI that facilitates to manage KinD clusters as Kubernetes pods. Designed to ease clusters up for fast testing with batteries included in mind.
- Host: GitHub
- URL: https://github.com/Trendyol/kink
- Owner: Trendyol
- License: apache-2.0
- Created: 2021-09-01T17:42:18.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-31T08:19:49.000Z (about 2 years ago)
- Last Synced: 2024-08-02T15:48:00.043Z (6 months ago)
- Topics: cobra, go, go-cli, kind, kind-in-kubernetes, kubernetes
- Language: Go
- Homepage:
- Size: 3.25 MB
- Stars: 375
- Watchers: 13
- Forks: 28
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
kink
A helper CLI that facilitates to manage KinD clusters as Kubernetes pods.
---
![kink_v1.gif](./assets/kink_v1.gif)
## Table of Contents
- [kink (KinD in Kubernetes)](#kink-kind-in-kubernetes)
- [Introduction](#introduction)
- [How it works ?](#how-it-works-)
- [Architectural Diagram](#architectural-diagram)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [List supported Kubernetes versions](#list-supported-kubernetes-versions)
- [Run KinD cluster](#run-kind-cluster)
- [List KinD clusters](#list-kind-clusters)
- [Delete KinD clusters](#delete-kind-clusters)
- [Autocompletion Support](#autocompletion-support)
- [Bash](#bash)
- [Zsh](#zsh)
- [fish](#fish)
- [PowerShell](#powershell)## Introduction
Before getting started into the **_kink_**, we should talk about a bit [KinD](https://kind.sigs.k8s.io) first who is not
familiar with this project. **_KinD_** is a tool for running local Kubernetes clusters using Docker container **_
nodes_**. **_KinD_** was primarily designed for testing Kubernetes itself, but may be used for local development or CI.So, what is **_kink_** then, where does this idea come from?
**_kink_** is a CLI application that facilitates to run KinD cluster in Kubernetes Pod and also manages the whole
lifecycle of these clusters such as by listing them, deleting them, etc. There is a very detailed guide about how you
can run KinD cluster in a Pod, for more detail,
please [see](https://d2iq.com/blog/running-kind-inside-a-kubernetes-cluster-for-continuous-integration) because this is
where the idea came from.The idea is that when you want to run ephemeral clusters by using projects like KinD in your CI/CD system instead of
having Kubernetes clusters, because it might cost more, you might want to run your KinD cluster in a Pod, especially if
you are using Gitlab as a CI/CD solution and running your jobs as Kubernetes Pod. This project specifically aims to
solve that problem. By using **_kink_**, you can easily manage whole lifecycle of your KinD cluster no matter how many
they are as Kubernetes Pod.## How it works ?
### Architectural Diagram
![kink_v1](./assets/kink_v1.png)
**_kink_** is a just a wrapper around managing Docker images which are purposely built to run **_KinD_** on Kubernetes
clusters inside a Pod. As I mentioned above, there is very detailed guide that explains all the necessary details to
run **_Kind_** on Kubernetes clusters inside Pod. So, there are some Docker images which we maintained
it [here](https://gitlab.trendyol.com/platform/base/poc/running-kind-cluster-in-pod-images). In this repository, we are
providing Docker images for different version
of [Docker](https://gitlab.trendyol.com/platform/base/poc/running-kind-cluster-in-pod-images/-/blob/master/dind/Dockerfile.buster#L3)
and [Kubernetes](https://gitlab.trendyol.com/platform/base/poc/running-kind-cluster-in-pod-images/-/blob/master/kind-cluster/node/Dockerfile#L1)
. Then, **_kink_** allows you to create Kubernetes Pods based on Docker images we provide and connect to the cluster
running inside a Pod. In order the connect to the cluster running inside a Pod, **_kink_** does some tricks such as
creating **_Kubernetes Service_**
and [adding node IP](https://github.com/Trendyol/kink/-/blob/master/cmd/run.go#L145-152) which is scheduled on to
the [CERT_SANS](https://gitlab.trendyol.com/platform/base/poc/running-kind-cluster-in-pod-images/-/blob/master/kind-cluster/entrypoint-wrapper.sh#L17)
addresses to make the connection secure over HTTPS.> **_kink_** uses labels to follow the user activities because we have to provide multi-tenancy support for our users in order to avoid stepping each other toes in same Kubernetes environment,
> you can see the label which we are currently using to achieve uniqueness.
> https://github.com/Trendyol/kink/-/blob/master/cmd/run.go#L91## Installation
### Go
If you have Go 1.16+, you can directly install by running:
```shell
$ go install github.com/Trendyol/kink@latest
```and the resulting binary will be placed at **_$HOME/go/bin/kink_**.
### Homebrew
If you have brew installed, then you can easily download this with the following commands:
```shell
brew tap trendyol/trendyol-tap
brew install kink
```## Quick Start
```shell
$ kink --help
A helper CLI that facilitates to manage KinD clusters as Kubernetes podsUsage:
kink [command]Available Commands:
completion Generate completion script
delete Ephemeral cluster could be deleted by delete command
help Help about any command
list List all ephemeral cluster
list-supported-versions List all supported k8s versions
run Ephemeral cluster could be created by run command
```This shows how to:
* list supported Kubernetes versions
* pick one of these versions and run KinD cluster
* list KinD clusters
* delete KinD clusters### List supported Kubernetes versions
```shell
$ kink list-supported-versions
v1.16.15
v1.17.17
v1.19.11
v1.20.7
v1.21.2
```### Run KinD cluster
* Choose one of your favorite Kubernetes distribution such as KinD, Minikube, k0s, k3s, etc and run it first.
Create custer with **_kind_**
```shell
$ kind create cluster
```Run **_kink_**
```shell
$ kink run hello-world --timeout 360
[1/1] Creating Pod hello-world... 100% [===============] (0.001 kB/s)KUBECONFIG file has been written to
the directory: /var/folders/pf/6h9t0mnd4d342ncgpjq_3zl80000gp/T/kink_kubeconfig3638074110/kubeconfig
Thanks for using kink!
Pod hello-world and Service hello-world created successfully!You can view the logs by running the following command:
$ kubectl logs -f hello-world -n defaultKUBECONFIG file generated at path '/Users/batuhan.apaydin/workspace/projects/trendyol/k8s-common/kubeconfig'.
Start managing your internal KinD cluster by running the following command:
$ KUBECONFIG=/Users/batuhan.apaydin/workspace/projects/trendyol/k8s-common/kubeconfig kubectl get nodes -o wide
```### List KinD clusters
* You can list all the KinD cluster provisied by yourself:
```shell
$ kink list
NAMESPACE NAME AGE LABELS
default pod/hello-world 5m5s generated-uuid=99596236-4b08-4e09-82ec-db3158840a1c,runned-by=batuhan.apaydin_C02DM1U3MD6R
```### Delete KinD clusters
* You can delete all the KinD clusters that you provisioned:
```shell
$ kink delete --all --force
Deleting Pod hello-world
Deleting Service hello-world```
* or you can delete one of them by speficying its name in the **_-name_** flag.
## Autocompletion Support
To load completions:
### Bash
```shell
$ source <(kink completion bash)# To load completions for each session, execute once:
# Linux:
$ kink completion bash > /etc/bash_completion.d/kink
# macOS:
$ kink completion bash > /usr/local/etc/bash_completion.d/kink
```### Zsh
```shell
# If shell completion is not already enabled in your environment,
# you will need to enable it. You can execute the following once:$ echo "autoload -U compinit; compinit" >> ~/.zshrc
# To load completions for each session, execute once:
$ kink completion zsh > "${fpath[1]}/_kink"# You will need to start a new shell for this setup to take effect.
```### fish
```shell
$ kink completion fish | source# To load completions for each session, execute once:
$ kink completion fish > ~/.config/fish/completions/kink.fish
```### PowerShell
```shell
PS> kink completion powershell | Out-String | Invoke-Expression# To load completions for every new session, run:
PS> kink completion powershell > kink.ps1
# and source this file from your PowerShell profile.
```