Difference between revisions of "Kubernetes/Kind"
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
 (Created page with "[https://github.com/kubernetes-sigs/kind/ kind] is a tool for running local Kubernetes clusters using Docker container "nodes". kind was primarily designed for testing Kuberne...")  | 
				|||
| Line 11: | Line 11: | ||
# Completion  | # Completion  | ||
source <(kind completion bash)  | source <(kind completion bash)  | ||
</source>  | |||
= [https://kind.sigs.k8s.io/docs/user/quick-start/#creating-a-cluster Creating a cluster] =  | |||
<source lang=bash>  | |||
kind create cluster --config kind.yaml  | |||
cat > kind.yaml <<EOF  | |||
# three node (two workers) cluster config  | |||
kind: Cluster  | |||
apiVersion: kind.x-k8s.io/v1alpha4  | |||
nodes:  | |||
- role: control-plane  | |||
- role: worker  | |||
- role: worker  | |||
EOF  | |||
# Get KiND clusters  | |||
kind get clusters # -> kind  | |||
# Delete a cluster  | |||
kind delete cluster # -> Deleting cluster "kind" ...  | |||
</source>  | |||
All fields available example  | |||
<source lang=bash>  | |||
kind create cluster --config kind-example-config.yaml  | |||
cat > kind-example-config.yaml <<EOF  | |||
# this config file contains all config fields with comments  | |||
# NOTE: this is not a particularly useful config file  | |||
kind: Cluster  | |||
apiVersion: kind.x-k8s.io/v1alpha4  | |||
# patch the generated kubeadm config with some extra settings  | |||
kubeadmConfigPatches:  | |||
- |  | |||
  apiVersion: kubelet.config.k8s.io/v1beta1  | |||
  kind: KubeletConfiguration  | |||
  evictionHard:  | |||
    nodefs.available: "0%"  | |||
# patch it further using a JSON 6902 patch  | |||
kubeadmConfigPatchesJSON6902:  | |||
- group: kubeadm.k8s.io  | |||
  version: v1beta2  | |||
  kind: ClusterConfiguration  | |||
  patch: |  | |||
    - op: add  | |||
      path: /apiServer/certSANs/-  | |||
      value: my-hostname  | |||
# 1 control plane node and 3 workers  | |||
nodes:  | |||
# the control plane node config  | |||
- role: control-plane  | |||
# the three workers  | |||
- role: worker  | |||
- role: worker  | |||
- role: worker  | |||
EOF  | |||
</source>  | </source>  | ||
Latest revision as of 16:57, 28 December 2021
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.
Install
REPO=kubernetes-sigs 
PROJECT=kind
VERSION=$(curl --silent "https://api.github.com/repos/${REPO}/${PROJECT}/releases/latest" | jq -r .tag_name); echo $VERSION
TEMPDIR=$(mktemp -d)
curl -L https://kind.sigs.k8s.io/dl/${VERSION}/kind-linux-amd64 -o $TEMPDIR/kind
sudo install $TEMPDIR/kind /usr/local/bin/kind
# Completion
source <(kind completion bash)
Creating a cluster
kind create cluster --config kind.yaml cat > kind.yaml <<EOF # three node (two workers) cluster config kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 nodes: - role: control-plane - role: worker - role: worker EOF # Get KiND clusters kind get clusters # -> kind # Delete a cluster kind delete cluster # -> Deleting cluster "kind" ...
All fields available example
kind create cluster --config kind-example-config.yaml
cat > kind-example-config.yaml <<EOF
# this config file contains all config fields with comments
# NOTE: this is not a particularly useful config file
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
# patch the generated kubeadm config with some extra settings
kubeadmConfigPatches:
- |
  apiVersion: kubelet.config.k8s.io/v1beta1
  kind: KubeletConfiguration
  evictionHard:
    nodefs.available: "0%"
# patch it further using a JSON 6902 patch
kubeadmConfigPatchesJSON6902:
- group: kubeadm.k8s.io
  version: v1beta2
  kind: ClusterConfiguration
  patch: |
    - op: add
      path: /apiServer/certSANs/-
      value: my-hostname
# 1 control plane node and 3 workers
nodes:
# the control plane node config
- role: control-plane
# the three workers
- role: worker
- role: worker
- role: worker
EOF