kind原理
kind 的原理就是将 k8s 所需要的所有组件,全部部署在一个 docker 容器中,
kindest/node ,这个镜像里面包含了需要安装的所有东西,
包括了 kubectl、kubeadm、kubelet 二进制文件,
以及安装对应版本 k8s 所需要的镜像,
都以 tar 压缩包的形式放在镜像内的一个路径下
只需要一个镜像kindest/node 即可部署一套 k8s 环境,
其底层是使用 kubeadm 进行部署,CRI 使用 Containerd,CNI 使用 weave
kind 离线安装k8s
https://kind.sigs.k8s.io/docs/user/working-offline/
离线安装步骤
docker 环境
kind 命令 --二进制安装方式
kubectl 命令 二进制安装方式
kindest/node 镜像
1.安装 kind --类似于安装docker-compose
https://kind.sigs.k8s.io/dl/v0.11.1/kind-Linux-amd64
chmod +x ./kind
mv ./kind /usr/bin/ 或者 mv ./kind /usr/local/bin/
kind version
查看一下version,显示有版本号那就说明安装成功了
2.下载安装kubectl
https://dl.k8s.io/release/v1.23.0/bin/linux/amd64/kubectl
chmod +x kubectl
mv ./kubectl /usr/bin
kubectl version
3.下载镜像
对应版本
https://github.com/kubernetes-sigs/kind/releases
docker hub 下载镜像
https://hub.docker.com/r/kindest/node
4.执行命令
:~/.kind$ kind create cluster
Creating cluster "kind" ...
✓ Ensuring node image (kindest/node:v1.21.1) 🖼
✓ Preparing nodes 📦
✓ Writing configuration 📜
✓ Starting control-plane 🕹️
✓ Installing CNI 🔌
✓ Installing StorageClass 💾
Set kubectl context to "kind-kind"
You can now use your cluster with:
kubectl cluster-info --context kind-kind
Thanks for using kind! 😊
:~/.kind$
使用kind
01. kind create cluster 默认会创建一个单节点的集群
02. 如果想要创建更复杂的集群--通过配置文件的方式
# Create a new cluster with the config file
kind create cluster --image kindest/node:v1.18.2 --name k8s --config ./kind-3nodes.yaml
创建的集群进行一些定制化配置,kind 支持的配置见这里:https://kind.sigs.k8s.io/docs/user/configuration/
编写配置 kind 配置文件 config.yaml,然后在 kind 创建集群的时候指定配置文件: --config=/foo/bar/config.yaml
03.查看
kind get clusters
04.操作
Docker images can be loaded into your cluster nodes with:
kind load docker-image my-custom-image-0 my-custom-image-1
kind load image-archive /my-image-archive.tar
05.删除集群
kind delete cluster --name kind
k8s集群配置
docker exec kind-control-plane crictl ps
# 获取 k8s 集群所有资源示例
kubectl get all --all-namespaces
kubectl get node
kubectl config get-contexts
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/kind/deploy.yaml
Helm
Helm是Kubernetes的包管理器,类似于Python的pip centos的yum,主要用来管理 Charts
Helm Chart是用来封装Kubernetes原生应用程序的一系列YAML文件。可以在你部署应用的时候自定义应用程序的一些Metadata,
https://charts.bitnami.com/
Bitnami Charts
This is the Helm repository for Bitnami Charts.
Follow the steps below to start deploying any of them in your Kubernetes cluster. More info at https://github.com/bitnami/charts
$ helm repo add bitnami https://charts.bitnami.com/bitnami
$ helm search repo bitnami
$ helm install my-release bitnami/chart-name
k8s
~/soft/apache-dolphinscheduler-2.0.3-src/docker/kubernetes/dolphinscheduler
对比其他轻量化工具
不像minikube 或者 k3s 需要一下镜像
$ kubeadm config images list --kubernetes-version=v1.15.3
k8s.gcr.io/kube-apiserver:v1.15.3
k8s.gcr.io/kube-controller-manager:v1.15.3
k8s.gcr.io/kube-scheduler:v1.15.3
k8s.gcr.io/kube-proxy:v1.15.3
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.3.10
k8s.gcr.io/coredns:1.3.1
Kubeadm 所需的镜像。另外我们还需要两个辅助镜像:
kindest/node:v1.15.3 以及 registry:2.7.1
通过 docker pull 以通过下列命令下拉取相关镜像
通过docker tag命令来修改镜像的标签
docker pull kindest/node
docker pull kindest/node-amd64
docker pull kindest/haproxy
参考
https://kind.sigs.k8s.io/
WSL2 使用Kind创建Kubernetes开发集群环境 https://www.cnblogs.com/microestc/articles/13205798.html