前提条件:
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集群:
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集群):
先获取配置文件模板:
sealos config -t kubeadm >> kubeadm-config.yaml.tmpl
修改kubeadm-config.yaml.tmpl,文件即可, 编辑增加 sealyun.com, 注意其它部分不用动,sealos会自动填充模板里面的内容:
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"
官方文档:https://sealyun.com/docs/
参考文章:https://www.cnblogs.com/hi-linux/archive/2019/10/14/11673002.html
使用 Sealos 在 3 分钟内快速部署一个生产级别的 Kubernetes 高可用集群
原文:https://www.cnblogs.com/zhangmingcheng/p/13710946.html