Tuesday, July 20, 2021

Deploy kubernetes inside docker using kind

 Follow install steps from official site: https://kind.sigs.k8s.io/docs/user/quick-start/

And download the kind executable based on the platform


Simple single node cluster creation:

kind create cluster


Cluster creation with specific name:

kind create cluster --name mycluster


We can create multiple clusters by using --name with different names.


kind get clusters


To see the nodes created once the cluster is created:

kubectl get nodes -o wide

kubectl get pods -A


docker ps  --> the nodes are shown as docker containers


To connect the kubernetes master control plane node:

docker exec -it kind-control-plane bash

Inside the kubernetes master node(a docker container), you can execute below commands to check the cluster.

#which crictl

#crictl ps

#ls /etc/kubernetes/manifests

To delete a cluster once work is done:

kind delete cluster --name mycluster


The deploy a multi-node cluster, If you scroll quick-start page in the Advanced section, you can find yaml for Multi-node clusters. Create a yaml file with that content and use that to create the cluster.

kind create cluster --config /tmp/kind.yaml


sample:

---

# three node (two workers) cluster config

kind: Cluster

apiVersion: kind.x-k8s.io/v1alpha4

nodes:

- role: control-plane

- role: worker

- role: worker


docker inspect kind-external-load-balancer | less

#it uses kind network.


to use old k8s version:

Get releases info from kind repo in github

kind create cluster --image:<imageurlmetioned>

or provide in config file while creation, image


To configure storage classes for persistent volumes in kind:

to configure storage classes:

in repo justmeandopensource/kubernetes/yamls

pvc files samples.

4-pvc-nfs.yaml:

Skip the storage class and remove that as it takes standard by default.

accessModes, ReadWriteMany is not supported in local volumes, so keep ReadWriteOnce

kubectl get pv,pvc

kubectl get sc

The storage class will be in the "WaitForTheFirstConsumer" and will be changed when a deployment/pod uses it.

Sample ufage: busybox sample in the same folder.


No comments:

Post a Comment