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.
Kind 用途
安装部署
1. 部署安装工具包
apt install -y net-tools tcpdump chrony bridge-utils tree wget iftop ethtool curl
复制
2. 关闭swap
sed -ri 's/.*swap.*/#&/' etc/fstab
swapoff -a复制
3. 修改内核参数
# vi etc/sysctl.conf
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-arptables = 1
fs.inotify.max_user_instances=1024
fs.inotify.max_user_watches=524288
fs.file-max=524288
# vim etc/security/limits.conf
root soft nofile 655350
root hard nofile 655350
* soft nofile 655350
* hard nofile 655350复制
4. 添加阿里的repo
apt-get update && apt-get install -y apt-transport-https
apt upgrade -y
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
tee /etc/apt/sources.list.d/kubernetes.list <<-'EOF'
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF
apt-get update复制
5. 安装Docker并配置启动
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
mkdir -p /etc/docker
cat <<EOF > /etc/docker/daemon.json
{
"registry-mirrors": ["https://xxxx.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker
systemctl enable docker复制
6. 部署kind 工具
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.18.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind复制
kind 使用
1. 简单配置文件
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: testkind1
networking:
disableDefaultCNI: true
podSubnet: "10.244.0.0/16"
serviceSubnet: "10.96.0.0/12"
apiServerAddress: "0.0.0.0"
apiServerPort: 6543
kubeProxyMode: "ipvs"
containerdConfigPatches:
- |-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."k8s.gcr.io"]
endpoint = ["https://registry.aliyuncs.com/google_containers"]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."gcr.io"]
endpoint = ["https://registry.aliyuncs.com/google_containers"]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."quay.io"]
endpoint = ["https://quay-mirror.aliyuncs.com"]
nodes:
- role: control-plane
- role: worker
- role: worker复制
官网:https://kind.sigs.k8s.io/docs/user/configuration/
2. 部署命令
--wait 20m:k8s部署时间默认等待Ready 4m0s,如果下载镜像慢的话,有可能会失败,这里设置20m,但要注意一个问题,如果你配置文件中指定了disableDefaultCNI: true,不使用默认插件的话,这个如果再设置了--wait 20m,那么就会等待很长时间。如下图
docker exec -it testkind1-control-plane /bin/bash kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml
复制
3. 查看kind创建的集群
root@k8s-test:~/kind# kind get clusters |grep test
testkind1
root@k8s-test:~/kind#复制
4. 查看集群配置并导出
root@k8s-test:~/kind# kind get kubeconfig --name testkind1 > /root/.kube/config
root@k8s-test:~/kind#复制
或者
root@k8s-test:~/kind# kind export kubeconfig --name testkind1
Set kubectl context to "kind-testkind1"
root@k8s-test:~/kind#复制
5. 查看集群node节点列表
root@k8s-test:~/kind# kind get nodes --name testkind1
testkind1-control-plane
testkind1-worker
testkind1-worker2
root@k8s-test:~/kind#复制
6. 解决kind创建集群中无法下载镜像问题
kind load docker-image registry.k8s.io/metrics-server/metrics-server:v0.6.3 --name <集群名称>
复制
7. 解决kind创建集群的master节点无法调度
kubectl get nodes --no-headers -o custom-columns=NAME:.metadata.name |grep control-plane
kubectl taint nodes $controller_node node-role.kubernetes.io/master:NoSchedule-
kubectl get nodes -owide复制
总结
本文主要总结下kind的简单使用,方便快速创建一套可用集群进行测试或学习。
文章转载自Linux点滴运维实践,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
60分钟部署Oracle 21c RAC
王先生
236次阅读
2025-03-04 16:31:52
玩转DeepSeek系列:使用OCI GPU快速部署推理模型
甲骨文云技术
95次阅读
2025-03-03 09:46:33
GoldenDB数据库集群版本升级
Whill
91次阅读
2025-02-25 11:08:04
保姆级教程!带你一步步本地内网搭建RAGFlow
小周的数据库进阶之路
78次阅读
2025-02-28 15:08:21
100+项!YashanDB与Oracle全面对比 详解YashanDB如何做到1:1替代Oracle
YashanDB
58次阅读
2025-03-19 11:20:49
独家揭秘!Linux 服务器零网络搭建 DeepSeek - R1+WEB页面(多种方式),速建专属离线知识库,附安装包领取攻略
小周的数据库进阶之路
52次阅读
2025-02-25 09:26:37
centos下docker指定版本安装
在路上
45次阅读
2025-02-25 18:01:07
[译]DeepSeek发布开源smallpond项目开启DuckDB分布式之旅
萧少聪
41次阅读
2025-03-03 14:29:10
EMQX MCP Server:实现 Claude 与 MQTT 交互新可能
EMQX
40次阅读
2025-03-07 10:29:52
中免日上使用阿里云向量检索服务 Milvus 版搭建在线推荐系统
阿里云大数据AI技术
38次阅读
2025-03-11 14:13:34