使用 Sealos 在 3 分钟内快速部署一个生产级别的 Kubernetes 高可用集群
前提条件:
- 安装并启动docker, 高版本离线包自带docker,如没安装docker会自动安装
- 下载kubernetes 离线安装包.
- 下载最新版本sealos.
- 务必同步服务器时间
- 主机名不可重复
- master节点CPU必须2C以上
- 请使用sealos 3.2.0以上版本
1、下载并安装sealos, sealos是个golang的二进制工具,直接下载拷贝到bin目录即可, release页面也可下载
wget -c https://sealyun.oss-cn-beijing.aliyuncs.com/latest/sealos && chmod +x sealos && mv sealos /usr/bin
2、下载离线资源包
wget -c https://sealyun.oss-cn-beijing.aliyuncs.com/7b6af025d4884fdd5cd51a674994359c-1.18.0/kube1.18.0.tar.gz
3、使用默认配置文件安装高可用k8s集群:
1 2 3 4 5 6 7 8 9 10 11 12 | sealos init --master 192.168.131.60 \ --master 192.168.131.61 \ --master 192.168.131.62 \ --node 192.168.131.63 \ --node 192.168.131.64 \ --node 192.168.131.65 \ --node 192.168.131.66 \ --node 192.168.131.67 \ --node 192.168.131.68 \ --node 192.168.131.69 \ --version v1.18.0 \ --pkg-url /root/kube1.18.0.tar.gz |
参数名 | 含义 | 示例 |
---|---|---|
passwd | 服务器密码 | 123456 |
master | k8s master节点IP地址 | 192.168.0.2 |
node | k8s node节点IP地址 | 192.168.0.3 |
pkg-url | 离线资源包地址,支持下载到本地,或者一个远程地址 | /root/kube1.16.0.tar.gz |
version | 资源包对应的版本 | v1.16.0 |
注意:因为服务器之间我做了ssh免登陆,所以不需要使用密码参数,执行完sealos init命令几分钟一个高可用k8s集群就安装完了。
使用自定义kubeadm配置文件(添加外部etcd集群):
先获取配置文件模板:
1 | sealos config -t kubeadm >> kubeadm-config.yaml.tmpl |
修改kubeadm-config.yaml.tmpl
,文件即可, 编辑增加 sealyun.com
, 注意其它部分不用动,sealos会自动填充模板里面的内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | apiVersion: kubeadm.k8s.io/v1beta1 kind: ClusterConfiguration kubernetesVersion: {{.Version}} controlPlaneEndpoint: "{{.ApiServer}}:6443" imageRepository: {{.Repo}} networking: # dnsDomain: cluster.local podSubnet: {{.PodCIDR}} serviceSubnet: {{.SvcCIDR}} etcd: external: caFile: /data/etcd/ssl/ca.pem certFile: /data/etcd/ssl/server.pem keyFile: /data/etcd/ssl/server-key.pem endpoints: - https://192.168.131.60:2379 - https://192.168.131.61:2379 - https://192.168.131.62:2379 apiServer: certSANs: - 127.0.0.1 - {{.ApiServer}} {{range .Masters -}} - {{.}} {{end -}} {{range .CertSANS -}} - {{.}} {{end -}} - {{.VIP}} extraArgs: feature-gates: TTLAfterFinished=true extraVolumes: - name: localtime hostPath: /etc/localtime mountPath: /etc/localtime readOnly: true pathType: File controllerManager: extraArgs: feature-gates: TTLAfterFinished=true experimental-cluster-signing-duration: 876000h extraVolumes: - hostPath: /etc/localtime mountPath: /etc/localtime name: localtime readOnly: true pathType: File scheduler: extraArgs: feature-gates: TTLAfterFinished=true extraVolumes: - hostPath: /etc/localtime mountPath: /etc/localtime name: localtime readOnly: true pathType: File --- apiVersion: kubeproxy.config.k8s.io/v1alpha1 kind: KubeProxyConfiguration mode: "ipvs" ipvs: excludeCIDRs: - "{{.VIP}}/32" |
使用自定义配置文件安装高可用k8s集群:
1 2 3 4 5 6 7 8 9 10 11 12 13 | sealos init --kubeadm-config /data/kubeadm-config.yaml.tmpl \ --master 192.168.131.60 \ --master 192.168.131.61 \ --master 192.168.131.62 \ --node 192.168.131.63 \ --node 192.168.131.64 \ --node 192.168.131.65 \ --node 192.168.131.66 \ --node 192.168.131.67 \ --node 192.168.131.68 \ --node 192.168.131.69 \ --version v1.18.0 \ --pkg-url /root/kube1.18.0.tar.gz |
官方文档:https://sealyun.com/docs/
参考文章:https://www.cnblogs.com/hi-linux/archive/2019/10/14/11673002.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
2014-09-22 POJ2513:Colored Sticks(字典树+欧拉路径+并查集)