Skip to content

TreeKat71/sandbox-k8s-with-kind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

Steps

  1. Install kind
  2. Create cluster with config
    • generate config.yaml
    • create kubernetes cluster
  3. Get kind cluster credential
  4. Set kind cluster credential
  5. (optional) Install kubectl

Install kind

$ curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64

$ chmod +x ./kind

# Move it to your $PATH such as /usr/local/bin

Create kubernetes cluster

Generate config.yaml

# Ask your network administrator which IP you should use
$ sh gen_config.sh <IP> [nodePort_start] [nodePort_end] > config.yaml

The default range of NodePort service will be lauched from port 30000~32767, you can adjust the port range on your own if needed.

Create kubernetes cluster

$ kind create cluster --config=config.yaml

Get kind cluster credential

$ kind get kubeconfig > config_kind

Set kind cluster credential

Assume that you would like to access kind cluster remotely.

Then you have two options:

A>
Fill what you got from $ kind get kubeconfig in your local ~/.kube/config.

B>
To save your time, follow steps in this repo kubeconfig_merge. Then you just need to move the config_kind, generated from previous step, under your local ~/.kube.

(local) $ scp host_kind:/path/to/config_kind  ~/.kube/

(optional) Install kubectl

(local) $ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

# Move it to your $PATH such as /usr/local/bin

(optional) kubectl autocomplete & alias

source <(kubectl completion bash) # setup autocomplete in bash into the current shell, bash-completion package should be installed first.
echo "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.
alias k=kubectl
complete -F __start_kubectl k

Found mistakes?

Feel free to contact me through email in english or chinese.

About

Create testing kubernetes cluster with kind

Topics

Resources

Stars

Watchers

Forks

Languages