Giter Club home page Giter Club logo

kindadm's Introduction

kindadm

Create and administer a local one or multi-node Kubernetes cluster(s) in Docker container(s) with properly configured Helm, Ingress Controller, MetalLB, Metrics Server, and Kubernetes Dashboard with simple interactive commands.

Supported Opt-In Software: Docker Container Registry, and Weave Scope.

Quick Start

To create a local one or multi-node Kubernetes (K8s) cluster(s) - please run:

## extra args are optional.
#
kindadm --nodes=[1-99] --k8s_ver=1.[x].[x] --helm_ver=[2/3].[x].[x]

To purge interactively any created cluster(s):

kindadm --purge

Helper Menu

# kindadm -h

Usage:
    --all-labelled,-al      Set labels on all K8s nodes.
    --all-tainted,-at       Set taints on all K8s nodes. A different label can be defined.
    --create-registry,-cr   Create local container registry for K8s cluster(s).
    --half-labelled,-hl     Set labels on half K8s nodes.
    --half-tainted,-ht      Set taints on half K8s nodes. A different label can be defined.
    --helm_ver,-hv          Set Helm version to be installed.
    --k8s_ver,-v            Set K8s version to be deployed.
    --list-oa,-loa          List supported optional app(s).
    --nodes,-n              Set number of K8s nodes to be created.
    --opt-apps,-oa          Deploy supported optional app(s).
    --purge,-p              Purge interactively any existing cluster(s) and related resources.
    --sys_wide,-sw          Install prerequisites system-wide.
    --help,-h               Prints this message.
Example:
    kindadm -n=2 -v=1.19.1 -hl='nodeType=devops' -ht -oa=weave-scope -cr -hv=2 -sw

Opt-In Components

Opt-In Apps

Access Deployed Services

Kubernetes Dashboard

To access Kubernetes Dashboard from your local workstation, you must create a secure channel to your Kubernetes cluster. Run the following command:

kubectl proxy

Now you can access the dashboard at:

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:https/proxy/.

Weave Scope

To access Weave Scope (if deployed) from your local workstation, run the following command:

kubectl port-forward -n weave svc/weave-scope-weave-scope 80

Now you can access the Weave Scope Frontend at:

http://localhost:80.

Prerequisites

By default kindadm does the following:

  • Checks and advises (no install) on the system-wide prerequisites:
  1. Linux Docker Container Runtime.
  • Checks and installs in a self-contained .cache dir:
  1. kubectl binary.
  2. helm binary.
  3. Helm plugins: helm-diff.
  4. helmfile binary.
  5. kind binary.

With --sys_wide flag the aforementioned binaries will be installed system-wide (in /usr/local/bin dir).

NOTE: Changes are applied only if needed.

Credits

My name is Miroslav Hadzhiev - a Cloud & DevOps Engineer located in Sofia, Bulgaria. I'm glad that you liked my automation.

License

GNU General Public License v2.0

kindadm's People

Contributors

xtigyro 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

Watchers

 avatar  avatar  avatar

kindadm's Issues

[BUG] Weave-scope Helm chart seems currently not working with latest K8s and Helm version

How to reproduce:

$ ./kindadm -n=2 -hl='nodeType=devops' -ht -oa=weave-scope -cr

Downloading kubectl binary...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 42.9M  100 42.9M    0     0  5740k      0  0:00:07  0:00:07 --:--:-- 5926k

kubectl installed:
clientVersion:
  buildDate: "2022-09-21T14:33:49Z"
  compiler: gc
  gitCommit: 5835544ca568b757a8ecae5c153f317e5736700e
  gitTreeState: clean
  gitVersion: v1.25.2
  goVersion: go1.19.1
  major: "1"
  minor: "25"
  platform: linux/amd64
kustomizeVersion: v4.5.7


Downloading Helm Client binary...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13.8M  100 13.8M    0     0  5602k      0  0:00:02  0:00:02 --:--:-- 5602k

Helm installed:
version.BuildInfo{Version:"v3.10.0", GitCommit:"ce66412a723e4d89555dc67217607c6579ffcb21", GitTreeState:"clean", GoVersion:"go1.18.6"}

Helm plugins present:
NAME	VERSION	DESCRIPTION                           
diff	3.6.0  	Preview helm upgrade changes as a diff

Downloading Helmfile binary...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 15.6M  100 15.6M    0     0  4461k      0  0:00:03  0:00:03 --:--:-- 5884k

Installed:
helmfile version 0.146.0

Downloading KinD binary...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 6712k  100 6712k    0     0  3318k      0  0:00:02  0:00:02 --:--:-- 5921k

Installed:
kind v0.16.0 go1.19.1 linux/amd64

โœ“ kindadm prerequisites - ready.

Creating cluster "kind-2" ...
 โœ“ Ensuring node image (kindest/node:v1.25.2) ๐Ÿ–ผ 
 โœ“ Preparing nodes ๐Ÿ“ฆ ๐Ÿ“ฆ ๐Ÿ“ฆ  
 โœ“ Writing configuration ๐Ÿ“œ 
 โœ“ Starting control-plane ๐Ÿ•น๏ธ 
 โœ“ Installing CNI ๐Ÿ”Œ 
 โœ“ Installing StorageClass ๐Ÿ’พ 
 โœ“ Joining worker nodes ๐Ÿšœ 
Set kubectl context to "kind-kind-2"
You can now use your cluster with:

kubectl cluster-info --context kind-kind-2

Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community ๐Ÿ™‚

โœ“ Cluster nodes - labelled.

โœ“ Cluster nodes - tainted.
Unable to find image 'registry:2' locally
2: Pulling from library/registry
213ec9aee27d: Already exists
5299e6f78605: Pulling fs layer
4c2fb79b7ce6: Pulling fs layer
74a97d2d84d9: Pulling fs layer
44c4c74a95e4: Pulling fs layer
44c4c74a95e4: Waiting
74a97d2d84d9: Download complete
5299e6f78605: Verifying Checksum
5299e6f78605: Download complete
5299e6f78605: Pull complete
4c2fb79b7ce6: Verifying Checksum
4c2fb79b7ce6: Download complete
44c4c74a95e4: Download complete
4c2fb79b7ce6: Pull complete
74a97d2d84d9: Pull complete
44c4c74a95e4: Pull complete
Digest: sha256:83bb78d7b28f1ac99c68133af32c93e9a1c149bcd3cb6e683a3ee56e312f1c96
Status: Downloaded newer image for registry:2

โœ“ Docker Container Registry - started.


Deploying default apps...
Adding repo stable https://charts.helm.sh/stable
"stable" has been added to your repositories

Adding repo bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories

Adding repo kubernetes-dashboard https://kubernetes.github.io/dashboard
"kubernetes-dashboard" has been added to your repositories

Upgrading release=kubernetes-dashboard, chart=kubernetes-dashboard/kubernetes-dashboard
Listing releases matching ^kubernetes-dashboard$

UPDATED RELEASES:
NAME                   CHART                                       VERSION
kubernetes-dashboard   kubernetes-dashboard/kubernetes-dashboard     5.4.1

Upgrading release=metallb, chart=bitnami/metallb
Listing releases matching ^metallb$

UPDATED RELEASES:
NAME      CHART             VERSION
metallb   bitnami/metallb     3.0.7

Upgrading release=metrics-server, chart=bitnami/metrics-server
Listing releases matching ^metrics-server$

UPDATED RELEASES:
NAME             CHART                    VERSION
metrics-server   bitnami/metrics-server    5.11.9

Upgrading release=nginx-ingress-controller, chart=bitnami/nginx-ingress-controller
Listing releases matching ^nginx-ingress-controller$

UPDATED RELEASES:
NAME                       CHART                              VERSION
nginx-ingress-controller   bitnami/nginx-ingress-controller     9.2.6

โœ“ Default apps - deployed.

Deploying optional apps...
Adding repo stable https://charts.helm.sh/stable
"stable" has been added to your repositories

Adding repo bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories

Adding repo kubernetes-dashboard https://kubernetes.github.io/dashboard
"kubernetes-dashboard" has been added to your repositories

in /tmp/test/kindadm/helmfiles/apps/optional/weave-scope/helmfile-v3.yaml: command "/tmp/test/kindadm/.cache/helm" exited with non-zero status:

PATH:
  /tmp/test/kindadm/.cache/helm

ARGS:
  0: /tmp/test/kindadm/.cache/helm (29 bytes)
  1: diff (4 bytes)
  2: upgrade (7 bytes)
  3: --reset-values (14 bytes)
  4: --allow-unreleased (18 bytes)
  5: weave-scope (11 bytes)
  6: stable/weave-scope (18 bytes)
  7: --version (9 bytes)
  8: 1.1.12 (6 bytes)
  9: --namespace (11 bytes)
  10: weave (5 bytes)
  11: --values (8 bytes)
  12: /tmp/helmfile1092981535/weave-weave-scope-values-75684b58d4 (59 bytes)
  13: --detailed-exitcode (19 bytes)

ERROR:
  exit status 1

EXIT STATUS
  1

STDERR:
  Error: Failed to render chart: exit status 1: WARNING: This chart is deprecated
  Error: unable to build kubernetes objects from release manifest: [resource mapping not found for name: "weave-scope-cluster-agent-weave-scope" namespace: "" from "": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1"
  ensure CRDs are installed first, resource mapping not found for name: "weave-scope-weave-scope" namespace: "" from "": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
  ensure CRDs are installed first]
  Error: plugin "diff" exited with error

COMBINED OUTPUT:
  ********************
  	Release was not present in Helm.  Diff will show entire contents as new.
  ********************
  Error: Failed to render chart: exit status 1: WARNING: This chart is deprecated
  Error: unable to build kubernetes objects from release manifest: [resource mapping not found for name: "weave-scope-cluster-agent-weave-scope" namespace: "" from "": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1"
  ensure CRDs are installed first, resource mapping not found for name: "weave-scope-weave-scope" namespace: "" from "": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
  ensure CRDs are installed first]
  Error: plugin "diff" exited with error

[BUG] K8s version selection not working anymore after deprecated V1 registry list tags API was removed from DockerHub

K8s version selection not working anymore after deprecated V1 registry list tags API was removed from DockerHub.

How to reproduce:

$ ./kindadm -n=2 -v=1.25.2 -hl='nodeType=devops' -ht -oa=weave-scope -cr

Unsupported K8s node version.
Supported versions:

The is a result of the wget command in https://github.com/Xtigyro/kindadm/blob/main/kindadm#L210 returning a HTTP 410 error.

Personally, I would fix it with:

...
declare -A k8s_vers_avail="$(wget -q https://registry.hub.docker.com/v2/repositories/kindest/node/tags?page_size=100 -O - | jq '."results"[]["name"]' )"
...

...however this introduces requirement for having jq installed (plus if more than 100 tags exist they wouldn't be fetched)...

Cannot install successful using commands from README.md

OS:
uname -a
Linux dir3aux-work-station-h 5.3.0-53-generic #47~18.04.1-Ubuntu SMP Thu May 7 13:10:50 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

1 run: bash prerequisites-cmds.sh
2 run : bash create-nodes.sh 2

Expected: success message

Result : Get error

See below :

Creating cluster "kind-2" ...
 โœ“ Ensuring node image (kindest/node:v1.18.2) ๐Ÿ–ผ
 โœ“ Preparing nodes ๐Ÿ“ฆ ๐Ÿ“ฆ ๐Ÿ“ฆ  
 โœ“ Writing configuration ๐Ÿ“œ 
 โœ“ Starting control-plane ๐Ÿ•น๏ธ 
 โœ“ Installing CNI ๐Ÿ”Œ 
 โœ“ Installing StorageClass ๐Ÿ’พ 
 โœ“ Joining worker nodes ๐Ÿšœ 
Set kubectl context to "kind-kind-2"
You can now use your cluster with:

kubectl cluster-info --context kind-kind-2

Thanks for using kind! ๐Ÿ˜Š
Adding repo stable https://kubernetes-charts.storage.googleapis.com/
"stable" has been added to your repositories

Updating repo
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "confluent" chart repository
...Successfully got an update from the "oteemocharts" chart repository
...Successfully got an update from the "k8s-ovpn" chart repository
...Successfully got an update from the "incubator" chart repository
...Successfully got an update from the "c7n" chart repository
...Successfully got an update from the "bitnami" chart repository
...Successfully got an update from the "stable" chart repository
Update Complete. โŽˆ Happy Helming!โŽˆ 

Comparing release=ingress, chart=stable/nginx-ingress
Comparing release=metallb, chart=stable/metallb
Comparing release=metrics-server, chart=stable/metrics-server
Upgrading release=ingress, chart=stable/nginx-ingress
Upgrading release=metallb, chart=stable/metallb
Upgrading release=metrics-server, chart=stable/metrics-server

FAILED RELEASES:
NAME
ingress
metrics-server
metallb
in ./helmfile.yaml: 3 errors:
err 0: failed processing release ingress: the following cmd exited with status 1:
  /usr/local/bin/helm helm upgrade --install --reset-values ingress stable/nginx-ingress --force --atomic --cleanup-on-fail --create-namespace --namespace ingress --values /tmp/values220510012 --history-max 10

  Error: release ingress failed, and has been uninstalled due to atomic being set: timed out waiting for the condition
err 1: failed processing release metrics-server: the following cmd exited with status 1:
  /usr/local/bin/helm helm upgrade --install --reset-values metrics-server stable/metrics-server --force --atomic --cleanup-on-fail --create-namespace --namespace kube-system --values /tmp/values676404174 --history-max 10

  Error: release metrics-server failed, and has been uninstalled due to atomic being set: timed out waiting for the condition
err 2: failed processing release metallb: the following cmd exited with status 1:
  /usr/local/bin/helm helm upgrade --install --reset-values metallb stable/metallb --force --atomic --cleanup-on-fail --create-namespace --namespace metallb-system --values /tmp/values831479659 --history-max 10

  Error: release metallb failed, and has been uninstalled due to atomic being set: timed out waiting for the condition

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.