Pre-req

tar, wget, kubectl

Step 1: Download Go

root@photon-machine [ ~ ]# wget <https://golang.org/dl/go1.15.14.linux-amd64.tar.gz>
--2021-07-19 04:52:09--  <https://golang.org/dl/go1.15.14.linux-amd64.tar.gz>
Resolving golang.org... 142.251.33.113, 2607:f8b0:400a:807::2011
Connecting to golang.org|142.251.33.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: <https://dl.google.com/go/go1.15.14.linux-amd64.tar.gz> [following]
--2021-07-19 04:52:09--  <https://dl.google.com/go/go1.15.14.linux-amd64.tar.gz>
Resolving dl.google.com... 172.217.14.238, 2607:f8b0:400a:803::200e
Connecting to dl.google.com|172.217.14.238|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 121105361 (115M) [application/x-gzip]
Saving to: ‘go1.15.14.linux-amd64.tar.gz’

go1.15.14.linux-amd64.tar.gz                             100%[=================================================================================================================================>] 115.49M   108MB/s    in 1.1s    

2021-07-19 04:52:10 (108 MB/s) - ‘go1.15.14.linux-amd64.tar.gz’ saved [121105361/121105361]

Step 2: Install

root@photon-machine [ ~ ]# tar -C /usr/local -xzf go1.15.14.linux-amd64.tar.gz
root@photon-machine [ /usr/local ]# ls
bin  go  include  lib  lib64  share  src
root@photon-machine [ /usr/local/go ]# export PATH=$PATH:/usr/local/go/bin

Step 3: Verification

root@photon-machine [ ~ ]# go version
go version go1.15.14 linux/amd64

root@photon-machine [ ~]# mkdir -p ~/kind/{bin,pkg,src}

root@photon-machine [ ~ ]# ls -al
total 118312
drwxr-x---  7 root root      4096 Jul 19 05:00 .
drwxr-xr-x 15 root root      4096 Jul 19 04:47 ..
-rw-------  1 root root       154 Jul 19 04:46 .bash_history
-rw-r--r--  1 root root       178 May 29  2020 .bash_logout
drwxr-x---  3 root root      4096 Jul 19 04:56 .cache
drwxr-x---  3 root root      4096 Jul 19 04:55 go
-rw-r-----  1 root root 121105361 Jul 12 22:21 go1.15.14.linux-amd64.tar.gz
drwxr-x---  5 root root      4096 Jul 19 05:00 kind
drwx------  2 root root      4096 May 29  2020 .ssh
drwxr-xr-x  3 root root      4096 Jul 19 04:44 .vim
-rw-------  1 root root      1552 Jul 19 04:56 .viminfo
-rw-r-----  1 root root       165 Jul 19 04:52 .wget-hsts

root@photon-machine [ ~/kind ]# export GOBIN="/root/kind/bin"
root@photon-machine [ ~/kind ]# export GOPATH="/root/kind/src"

root@photon-machine [ ~/kind/src ]# cat hello.go 
package main

import "fmt"

func main() {
    fmt.Printf("Hello, World\\n")
}

root@photon-machine [ ~/kind/src ]# go install hello.go
root@photon-machine [ ~/kind/bin ]# $GOBIN/hello
Hello, World

Step 4: Enable Docker Process

root@photon-machine [ ~ ]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: <https://docs.docker.com>
root@photon-machine [ ~ ]# systemctl start docker
root@photon-machine [ ~ ]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-07-19 05:24:46 UTC; 2s ago
     Docs: <https://docs.docker.com>
 Main PID: 1035 (dockerd)
    Tasks: 18 (limit: 2365)
   Memory: 173.0M
   CGroup: /system.slice/docker.service
           ├─1035 /usr/bin/dockerd
           └─1042 docker-containerd --config /var/run/docker/containerd/containerd.toml

Jul 19 05:24:46 photon-machine dockerd[1035]: time="2021-07-19T05:24:46.194300759Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc000104910, CONNECTING" module=grpc
Jul 19 05:24:46 photon-machine dockerd[1035]: time="2021-07-19T05:24:46.194741578Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc000104910, READY" module=grpc
Jul 19 05:24:46 photon-machine dockerd[1035]: time="2021-07-19T05:24:46.194866225Z" level=info msg="Loading containers: start."
Jul 19 05:24:46 photon-machine dockerd[1035]: time="2021-07-19T05:24:46.318935230Z" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP ad
dress"
Jul 19 05:24:46 photon-machine dockerd[1035]: time="2021-07-19T05:24:46.371593287Z" level=info msg="Loading containers: done."
Jul 19 05:24:46 photon-machine dockerd[1035]: time="2021-07-19T05:24:46.459272148Z" level=info msg="Docker daemon" commit=6d37f41 graphdriver(s)=overlay2 version=18.06.2-ce
Jul 19 05:24:46 photon-machine dockerd[1035]: time="2021-07-19T05:24:46.459856699Z" level=info msg="Daemon has completed initialization"
Jul 19 05:24:46 photon-machine dockerd[1035]: time="2021-07-19T05:24:46.467943396Z" level=warning msg="Could not register builder git source: failed to find git binary: exec: \\"git\\": executable file not found in $PATH"
Jul 19 05:24:46 photon-machine systemd[1]: Started Docker Application Container Engine.
Jul 19 05:24:46 photon-machine dockerd[1035]: time="2021-07-19T05:24:46.475841451Z" level=info msg="API listen on /var/run/docker.sock"

Step 5: Install Kind

root@photon-machine [ ~/kind/bin ]# GO111MODULE="on" go get sigs.k8s.io/[email protected]
go: downloading sigs.k8s.io/kind v0.11.1
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/alessio/shellescape v1.4.1
go: downloading k8s.io/apimachinery v0.20.2
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/spf13/cobra v1.1.1
go: downloading github.com/mattn/go-isatty v0.0.12
go: downloading gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
go: downloading github.com/pelletier/go-toml v1.8.1
go: downloading github.com/evanphx/json-patch v4.9.0+incompatible
go: downloading github.com/BurntSushi/toml v0.3.1
go: downloading golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
go: downloading sigs.k8s.io/yaml v1.2.0
go: downloading gopkg.in/yaml.v2 v2.2.8
go: downloading github.com/inconshreveable/mousetrap v1.0.0
go: downloading github.com/evanphx/json-patch/v5 v5.2.0

root@photon-machine [ ~/knid/bin ]# export PATH=$PATH:/root/kind/bin/

root@photon-machine [ ~/kind/src ]# kind version
kind v0.11.1 go1.15.14 linux/amd64
root@photon-machine [ ~/kind/src ]#

Step 6: Build a Kind cluster

root@photon-machine [ ~ ]# kind create cluster
Creating cluster "kind" ...
⢄⡱ Ensuring node image (kindest/node:v1.21.1) [?7h
⢆⡱ Ensuring node image (kindest/node:v1.21.1) [?7hy
 ✓ Installing StorageClass Set kubectl context to "kind-kind"
You can now use your cluster with:

kubectl cluster-info --context kind-kind

Have a nice day! [1;31mroot@photon-machine [ ~ ]# 

Step 7: Check the Kind cluster


root@photon-machine [ ~ ]# kubectl cluster-info --context kind-kind
Kubernetes control plane is running at <https://127.0.0.1:39163>
CoreDNS is running at <https://127.0.0.1:39163/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy>

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

root@photon-machine [ ~ ]# kubectl get pod  -A
NAMESPACE            NAME                                         READY   STATUS    RESTARTS   AGE
kube-system          coredns-558bd4d5db-bhhb2                     1/1     Running   0          4m26s
kube-system          coredns-558bd4d5db-f57tz                     1/1     Running   0          4m26s
kube-system          etcd-kind-control-plane                      1/1     Running   0          4m29s
kube-system          kindnet-mt9k8                                1/1     Running   0          4m27s
kube-system          kube-apiserver-kind-control-plane            1/1     Running   0          4m29s
kube-system          kube-controller-manager-kind-control-plane   1/1     Running   0          4m29s
kube-system          kube-proxy-js4jg                             1/1     Running   0          4m27s
kube-system          kube-scheduler-kind-control-plane            1/1     Running   0          4m29s
local-path-storage   local-path-provisioner-547f784dff-wwhn8      1/1     Running   0          4m26s

root@photon-machine [ ~ ]# k get node 
NAME                 STATUS   ROLES                  AGE     VERSION
kind-control-plane   Ready    control-plane,master   9m32s   v1.21.1

Step 8: Delete a Kind cluster

root@photon-machine [ ~/kind/src ]# kind delete cluster --name kind
Deleting cluster "kind" ...

Step 9: Build multi-nodes Kind cluster

root@photon-machine [ ~/kind/src ]# cat kind-config.yaml 
# three node (two workers) cluster config
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker

root@photon-machine [ ~/kind/src ]# kind create cluster --name kind01 --config kind-config.yaml 
Creating cluster "kind01" ...
 ✓ Joining worker nodes Set kubectl context to "kind-kind01"
You can now use your cluster with:

kubectl cluster-info --context kind-kind01

root@photon-machine [ ~/kind/src ]# k get node
NAME                   STATUS   ROLES                  AGE     VERSION
kind01-control-plane   Ready    control-plane,master   2m21s   v1.21.1
kind01-worker          Ready    <none>                 107s    v1.21.1
kind01-worker2         Ready    <none>                 107s    v1.21.1

root@photon-machine [ ~/kind/src ]# k get pod -A
NAMESPACE            NAME                                           READY   STATUS    RESTARTS   AGE
kube-system          coredns-558bd4d5db-c6vnh                       1/1     Running   0          2m17s
kube-system          coredns-558bd4d5db-pdpp4                       1/1     Running   0          2m17s
kube-system          etcd-kind01-control-plane                      1/1     Running   0          2m33s
kube-system          kindnet-jgzvn                                  1/1     Running   0          2m
kube-system          kindnet-jsg6q                                  1/1     Running   0          2m
kube-system          kindnet-v26wn                                  1/1     Running   0          2m18s
kube-system          kube-apiserver-kind01-control-plane            1/1     Running   0          2m20s
kube-system          kube-controller-manager-kind01-control-plane   1/1     Running   0          2m35s
kube-system          kube-proxy-8gk5c                               1/1     Running   0          2m
kube-system          kube-proxy-pnkqr                               1/1     Running   0          2m
kube-system          kube-proxy-wfw97                               1/1     Running   0          2m18s
kube-system          kube-scheduler-kind01-control-plane            1/1     Running   0          2m20s
local-path-storage   local-path-provisioner-547f784dff-whl6v        1/1     Running   0          2m17s