1 Star 0 Fork 0

Gitee 极速下载 / KinK

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/Trendyol/kink
Clone or Download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

kink Logo

kink

A helper CLI that facilitates to manage KinD clusters as Kubernetes pods.


kink_v1.gif

Table of Contents

Introduction

Before getting started into the kink, we should talk about a bit KinD 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 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

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. In this repository, we are providing Docker images for different version of Docker and Kubernetes . 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 which is scheduled on to the CERT_SANS 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

If you have Go 1.16+, you can directly install by running:

$ export GOPRIVATE="gitlab.trendyol.com"
$ go install github.com/Trendyol/kink@latest

Note: Since we already sign the binaries and images using cosign, you can easily verify by using our public key: $ cosign verify -k ./cosign.pub] <FILE>.

and the resulting binary will be placed at $HOME/go/bin/kink.

Quick Start

$ kink --help
A helper CLI that facilitates to manage KinD clusters as Kubernetes pods

Usage:
  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

$ kink list-supported-versions
v1.16.0
v1.17.0
v1.18.0
v1.20.0
v1.21.2

Run KinD cluster

  • Choose one of your favorite Kubernetes distribution such as KinD, Minikube, k0s, k3s, etc and run it first.
$ kind create cluster
$ kink run --timeout 360
[1/1] Creating Pod kind-cluster-f1dc1e5a-eefa-4eea-94d8-bc6a99ea20db... 100% [===============] (0.184 kB/s)
KUBECONFIG file has been written to the directory: /var/folders/pf/6h9t0mnd4d342ncgpjq_3zl80000gp/T/kink_kubeconfig642727642/kubeconfig

Thanks for using kink!
Pod kind-cluster-f1dc1e5a-eefa-4eea-94d8-bc6a99ea20db and Service kind-cluster-f1dc1e5a-eefa-4eea-94d8-bc6a99ea20db created successfully!

You can view the logs by running the following command:
$ kubectl logs -f kind-cluster-f1dc1e5a-eefa-4eea-94d8-bc6a99ea20db -n default

KUBECONFIG file generated at path '/Users/batuhan.apaydin/workspace/projects/trendyol/kink/kubeconfig'.
Start managing your internal KinD cluster by running the following command:
$ KUBECONFIG=/Users/batuhan.apaydin/workspace/projects/trendyol/kink/kubeconfig kubectl get nodes -o wide%

List KinD clusters

$ kink list
NAMESPACE   NAME                                                    AGE    LABELS
default     pod/kind-cluster-f1dc1e5a-eefa-4eea-94d8-bc6a99ea20db   3d4h   generated-uuid=f1dc1e5a-eefa-4eea-94d8-bc6a99ea20db,runned-by=batuhan.apaydin_C02DM1U3MD6R

Delete KinD clusters

  • You can delete all the KinD clusters that you provisioned:
$ kink delete --all --force
Pod kind-cluster-f1dc1e5a-eefa-4eea-94d8-bc6a99ea20db and Service kind-cluster-f1dc1e5a-eefa-4eea-94d8-bc6a99ea20db will be deleted... Do you accept? (y/N) y
Deleting Pod kind-cluster-f1dc1e5a-eefa-4eea-94d8-bc6a99ea20db
  • or you can delete one of them:
$ kink delete --name kind-cluster-f1dc1e5a-eefa-4eea-94d8-bc6a99ea20db
Pod kind-cluster-f1dc1e5a-eefa-4eea-94d8-bc6a99ea20db and Service kind-cluster-f1dc1e5a-eefa-4eea-94d8-bc6a99ea20db will be deleted... Do you accept? (y/N) y
Deleting Pod kind-cluster-f1dc1e5a-eefa-4eea-94d8-bc6a99ea20db

Autocompletion Support

To load completions:

Bash

$ source <(kink completion bash)

# To load completions for each session, execute once:
# Linux:
$ yourprogra completion bash > /etc/bash_completion.d/kink
# macOS:
$ kink completion bash > /usr/local/etc/bash_completion.d/kink

Zsh

# 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

$ kink completion fish | source

# To load completions for each session, execute once:
$ kink completion fish > ~/.config/fish/completions/kink.fish

PowerShell

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.

Repository Comments ( 0 )

Sign in for post a comment

About

KinD 是一个使用 Docker 容器运行本地 Kubernetes 集群的工具,主要目的是用来测试,但也可用于本地开发 expand collapse
Shell and 4 more languages
Apache-2.0
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
Shell
1
https://toscode.gitee.com/mirrors/KinK.git
git@toscode.gitee.com:mirrors/KinK.git
mirrors
KinK
KinK
chore/homebrew

Search