GithubHelp home page GithubHelp logo

trendyol / kink Goto Github PK

View Code? Open in Web Editor NEW
377.0 13.0 28.0 3.33 MB

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.

License: Apache License 2.0

Dockerfile 5.76% Makefile 5.74% Go 74.44% Shell 14.06%
kind kubernetes kind-in-kubernetes go cobra go-cli

kink's Introduction

kink Logo

kink

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

Apache 2.0 Go Report Build Status GitHub release Go Mod Codecov


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

Go

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

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

brew tap trendyol/trendyol-tap
brew install 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.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

$ kind create cluster

Run kink

$ 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 default

KUBECONFIG 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:
$ 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:
$ 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

$ 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

# 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.

kink's People

Contributors

bilalcaliskan avatar ciiiii avatar dentrax avatar dependabot[bot] avatar developer-guy avatar erkanzileli avatar paddatrapper avatar

Stargazers

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

Watchers

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

kink's Issues

Enable discussions?

This is a request to enable discussions, mostly because I wanted to ask a question, and don't really have a better place than right here to ask.

What did you use to make the architectural diagram? I like the "hand-drawn sketch" look.

Security Concerns with kink

While this seems like a cool project, the security implications that are required for running kink are very concerning.

kink/cmd/run.go

Line 212 in 42be76d

Privileged: ptrbool(true),

Running this fully privileged puts a massive risk on any K8 Cluster that runs Kink. The security impact of this project can probably be massively reduced by implementing the correct and relevant Security Context instead of running it in privileged Mode.

KIND endpoint in kubeconfig

Hi,

I can't access the API server of my kind-cluster. In the kubeconfig, i get only the internal ip adress.

- cluster:
    server: https://10.250.2.131:30063
  name: kind-kind-190634c5-9762-4762-bb0a-6e32700f49cc
contexts:

Is there somthing i do wrong?

kink is creating a svc from type `NodePort``

est                                                  NodePort    100.68.250.121   <none>        30001:30063/TCP                                 16m

Make the API service type configurable

There are a lot of gotchas with NodePorts, why not allow the service type to be specified? Even better since the API is just a web port in any case optionally fire up an ingress?

Even better fire up an Ingress(optionally). Incidentally, this tool is a fantastic idea.

Can't install kink via the tap on a mac m1

I tried installing kink using homebrew, but got the following error:

Error: Invalid formula: /opt/homebrew/Library/Taps/trendyol/homebrew-trendyol-tap/kink.rb
formulae require at least a URL
Error: Cannot tap trendyol/trendyol-tap: invalid syntax in tap!

This is on a MacM1, MacOS 11.5 and Homebrew 3.2.12

Updated issue to indicate that it's related to arm vs amd64.

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.