Skip to content

Commit

Permalink
Merge pull request labring#570 from oldthreefeng/develop
Browse files Browse the repository at this point in the history
fix readme_en add go test in pr.
  • Loading branch information
fanux authored Jan 5, 2021
2 parents df1a2b9 + 2bf74fe commit 2e763f4
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 118 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@ jobs:
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: build --snapshot --rm-dist --timeout=1h
args: build --snapshot --rm-dist --timeout=1h

- name: Get dependencies
run: go get -v -t -d ./...

- name: Test without docker
run: go test -v -timeout 200s ./...
65 changes: 52 additions & 13 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,27 +122,66 @@ sealos config -t kubeadm >> kubeadm-config.yaml.tmpl
See the config template file `cat kubeadm-config.yaml.tmpl`, edit it add `sealyun.com`:
```
apiVersion: kubeadm.k8s.io/v1beta1
kind: InitConfiguration
localAPIEndpoint:
advertiseAddress: {{.Master0}}
bindPort: 6443
---
apiVersion: kubeadm.k8s.io/v1beta1
kind: ClusterConfiguration
kubernetesVersion: {{.Version}}
controlPlaneEndpoint: "apiserver.cluster.local:6443"
controlPlaneEndpoint: "{{.ApiServer}}:6443"
imageRepository: {{.Repo}}
networking:
podSubnet: 100.64.0.0/10
# dnsDomain: cluster.local
podSubnet: {{.PodCIDR}}
serviceSubnet: {{.SvcCIDR}}
apiServer:
certSANs:
- sealyun.com # this is what I added
- 127.0.0.1
- apiserver.cluster.local
{{range .Masters -}}
- {{.}}
{{end -}}
- {{.VIP}}
certSANs:
- sealyun.com # add to 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"
excludeCIDRs:
- "{{.VIP}}/32"
```

Then using --kubeadm-config flag:
Expand All @@ -160,5 +199,5 @@ sealos init --kubeadm-config kubeadm-config.yaml.tmpl \

[简体中文](README_zh.md)

[More offline packages](http://store.lameleg.com)
[More offline packages](https://sealyun.com)

177 changes: 98 additions & 79 deletions README_zh.md
Original file line number Diff line number Diff line change
@@ -1,103 +1,122 @@
[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/fanux/sealos)
[![Build Status](https://cloud.drone.io/api/badges/fanux/sealos/status.svg)](https://cloud.drone.io/fanux/sealos)
<a href="https://trackgit.com">
<img src="https://us-central1-trackgit-analytics.cloudfunctions.net/token/ping/kexrkhvqjlzkdiap4zke" alt="trackgit-views" />
</a>

[简体中文,老版本](https://sealyun.com/post/sealos/)
![](https://socialify.git.ci/fanux/sealos/image?description=1&font=Source%20Code%20Pro&forks=1&language=1&pattern=Charlie%20Brown&stargazers=1&theme=Light)

[离线包购买市场](http://store.lameleg.com/)
<div align="center">
<p>
<b>一条命令部署 Kubernetes 高可用集群 👋</b>
</p>
<p>
<i>只能用丝滑一词形容的kubernetes高可用安装(kubernetes install)工具,一条命令,离线安装,包含所有依赖,内核负载不依赖haproxy keepalived,纯golang开发,99年证书,支持v1.20.0 v1.19.5 v1.18.13 v1.17.15!</i>
</p>
<p>

kubernetes 1.14以下版本请移步老掉牙教程[sealos 1.x docs](https://github.com/fanux/sealos/tree/v1.14.0)
[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/fanux/sealos)
[![Build Status](https://cloud.drone.io/api/badges/fanux/sealos/status.svg)](https://cloud.drone.io/fanux/sealos)
[![Website](https://img.shields.io/website?url=https%3A%2F%2Fpostwoman.io&logo=Postwoman)](https://sealyun.com)
[![Go Report Card](https://goreportcard.com/badge/github.com/fanux/sealos)](https://goreportcard.com/report/github.com/fanux/sealos)
[![Chat on Telegram](https://img.shields.io/badge/chat-Telegram-blueviolet?logo=Telegram)](https://t.me/gsealyun)

# Sealos 2.0
支持kubernetes 1.14.0 以上版本,HA不再依赖keeplived与haproxy, 通过ipvs直接代理masters节点
</p>
</div>

通过lvscare健康检测masters, 是一种非常先进且稳定的HA方式。安装失败率极低。
---

![](./arch.jpg)
**文档: _[官方文档](https://www.sealyun.com/instructions), [博客](https://fuckcloudnative.io)_**

# 快速使用
## 准备条件
* 装好docker并启动docker
*[离线安装包](http://store.lameleg.com) 下载好拷贝到执行节点的任意目录,不需要解压,sealos会自动检测各个节点是否有安装包,若不存在则会scp到该节点。如果有文件服务器更好,sealos也支持从一个服务器上wget到所有节点上。 离线包中sealos暂不支持scp,请到release界面下载最新版sealos
**加入组织: _钉钉群(35371178), [Telegram](https://t.me/gsealyun)_**

## 安装
sealos已经放在离线包中,解压后在kube/bin目录下(可以解压一个,获取sealos bin文件)
```
sealos init \
--master 192.168.0.2 \
--master 192.168.0.3 \
--master 192.168.0.4 \ # master地址列表
--node 192.168.0.5 \ # node地址列表
--user root \ # 服务用户名
--passwd your-server-password \ # 服务器密码,用于远程执行命令
--pkg-url /root/kube1.14.1.tar.gz \ # 离线安装包位置,可支持http/https服务器(http://store.lameleg.com/kube1.14.1.tar.gz)存放和本地(/root/kube1.14.1.tar.gz)存放两种方式。若对应节点上文件不存在则会从执行机器上scp文件到对应节点。
--version v1.14.1 # kubernetes 离线安装包版本,这渲染kubeadm配置时需要使用
```
然后,就没有然后了
![](./arch.png)

[English Docs](/README_en.md)

其它参数:
# 🚀 快速开始

```
--kubeadm-config string kubeadm-config.yaml local # 自定义kubeadm配置文件,如有这个sealos就不去渲染kubeadm配置
--vip string virtual ip (default "10.103.97.2") # 代理master的虚拟IP,只要与你地址不冲突请不要改
```
> 环境信息
主机名|IP地址
---|---
master0|192.168.0.2
master1|192.168.0.3
master2|192.168.0.4
node0|192.168.0.5

## 清理
```
sealos clean \
--master 192.168.0.2 \
--master 192.168.0.3 \
--master 192.168.0.4 \ # master地址列表
--node 192.168.0.5 \ # node地址列表
--user root \ # 服务用户名
--passwd your-server-password
```
服务器密码:123456

## 增加节点
新增节点可直接使用kubeadm, 到新节点上解压
```
cd kube/shell && init.sh
echo "10.103.97.2 apiserver.cluster.local" >> /etc/hosts # using vip
kubeadm join 10.103.97.2:6443 --token 9vr73a.a8uxyaju799qwdjv \
--master 10.103.97.100:6443 \
--master 10.103.97.101:6443 \
--master 10.103.97.102:6443 \
--discovery-token-ca-cert-hash sha256:7c2e69131a36ae2a042a339b33381c6d0d43887e2de83720eff5359e26aec866
```
**kubernetes .0版本不建议上生产环境!!!**

> 只需要准备好服务器,在任意一台服务器上执行下面命令即可
```sh
# 下载并安装sealos, sealos是个golang的二进制工具,直接下载拷贝到bin目录即可, release页面也可下载
$ wget -c https://sealyun.oss-cn-beijing.aliyuncs.com/latest/sealos && \
chmod +x sealos && mv sealos /usr/bin

## 安装dashboard prometheus等
离线包里包含了yaml配置和镜像,用户按需安装。
# 下载离线资源包
$ wget -c https://sealyun.oss-cn-beijing.aliyuncs.com/2fb10b1396f8c6674355fcc14a8cda7c-v1.20.0/kube1.20.0.tar.gz

# 安装一个三master的kubernetes集群
$ sealos init --passwd '123456' \
--master 192.168.0.2 --master 192.168.0.3 --master 192.168.0.4 \
--node 192.168.0.5 \
--pkg-url /root/kube1.20.0.tar.gz \
--version v1.20.0
```
cd /root/kube/conf
kubectl taint nodes --all node-role.kubernetes.io/master- # 去污点,根据需求看情况,去了后master允许调度
kubectl apply -f heapster/ # 安装heapster, 不安装dashboard上没监控数据
kubectl apply -f heapster/rbac
kubectl apply -f dashboard # 装dashboard
kubectl apply -f prometheus # 装监控

> 参数含义
参数名|含义|示例
---|---|---
passwd|服务器密码|123456
master|k8s master节点IP地址| 192.168.0.2
node|k8s node节点IP地址|192.168.0.3
pkg-url|离线资源包地址,支持下载到本地,或者一个远程地址|/root/kube1.20.0.tar.gz
version|[资源包](https://www.sealyun.com/goodsDetail?type=cloud_kernel&name=kubernetes)对应的版本|v1.20.0

> 增加master
```shell script
🐳 → sealos join --master 192.168.0.6 --master 192.168.0.7
🐳 → sealos join --master 192.168.0.6-192.168.0.9 # 或者多个连续IP
```

# 原理
> 增加node
```shell script
🐳 → sealos join --node 192.168.0.6 --node 192.168.0.7
🐳 → sealos join --node 192.168.0.6-192.168.0.9 # 或者多个连续IP
```
+----------+ +---------------+ virturl server: 127.0.0.1:6443
| mater0 |<----------------------| ipvs nodes | real servers:
+----------+ |+---------------+ 10.103.97.200:6443
| 10.103.97.201:6443
+----------+ | 10.103.97.202:6443
| mater1 |<---------------------+
+----------+ |
|
+----------+ |
| mater2 |<---------------------+
+----------+
> 删除指定master节点
```shell script
🐳 → sealos clean --master 192.168.0.6 --master 192.168.0.7
🐳 → sealos clean --master 192.168.0.6-192.168.0.9 # 或者多个连续IP
```
sealos 只是帮助用户去渲染配置远程执行命令,低层依赖两个东西,一个是lvscare,一个是定制化的超级kubeadm

关于[LVScare](https://github.com/fanux/LVScare)
> 删除指定node节点
关于超级kubeadm[简体中文,kubernetes v1.14.0+](https://sealyun.com/post/super-kubeadm/)
```shell script
🐳 → sealos clean --node 192.168.0.6 --node 192.168.0.7
🐳 → sealos clean --node 192.168.0.6-192.168.0.9 # 或者多个连续IP
```

会以类似kube-proxy的ipvs的形式去守护k8s master节点,一旦apiserver不可访问了,会自动清理掉所有node上对应的ipvs规则, master恢复正常时添加回来。
> 清理集群
```shell script
🐳 → sealos clean --all
```

# 公众号:
![sealyun](https://sealyun.com/kubernetes-qrcode.jpg)
# ✅ 特性

- [x] 支持ARM版本离线包,v1.20版本离线包支持containerd集成,完全抛弃docker
- [x] 99年证书, 支持集群备份,升级
- [x] 不依赖ansible haproxy keepalived, 一个二进制工具,0依赖
- [x] 离线安装,不同kubernetes版本下载对应不同版本的[资源包](https://www.sealyun.com/goodsDetail?type=cloud_kernel&name=kubernetes)即可,离线包包含所有二进制文件配置文件和镜像
- [x] 高可用通过ipvs实现的localLB,占用资源少,稳定可靠,类似kube-proxy的实现
- [x] 几乎可兼容所有支持systemd的x86_64架构的环境
- [x] 轻松实现集群节点的增加/删除
- [x] 上千用户在线上环境使用sealos,稳定可靠
- [x] 资源包放在阿里云oss上,再也不用担心网速
- [x] dashboard ingress prometheus等APP 同样离线打包,一键安装
4 changes: 2 additions & 2 deletions cert/kube_certs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
)

func TestGenerateAll(t *testing.T) {
BasePath := "/etc/kubernetes/pki"
EtcdBasePath := "/etc/kubernetes/pki/etcd"
BasePath := "/tmp/kubernetes/pki"
EtcdBasePath := "/tmp/kubernetes/pki/etcd"
tests := []struct {
name string
wantErr bool
Expand Down
2 changes: 1 addition & 1 deletion install/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func Test_generatorKubeadmConfig(t *testing.T) {
}

func TestTemplate(t *testing.T) {
var masters = []string{"172.20.241.205", "172.20.241.206", "172.20.241.207"}
var masters = []string{"172.20.241.205:22", "172.20.241.206:22", "172.20.241.207:22"}
var vip = "10.103.97.1"
config := sshutil.SSH{
User: "cuisongliu",
Expand Down
23 changes: 5 additions & 18 deletions install/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@ func TestPath(t *testing.T) {
t.Log(tt)
}

func TestProcess(t *testing.T) {
//fmt.Printf("%s \033[K\n", "--") // 输出一行结果
//fmt.Printf("\033[%dA\033[K", 1) // 将光标向上移动一行
//fmt.Printf("%s \033[K\n", "=-") // 输出第二行结果
//bar(100, 1, 0)
}

func TestNotReadyNode(t *testing.T) {
SSHConfig.User = "root"
SSHConfig.Password = "PaaS@123"
ss := isHostName("172.27.139.74", "172.27.139.126")
print(ss)
}

func TestPrint(t *testing.T) {
//User = "root"
//Passwd = "admin"
Expand Down Expand Up @@ -57,17 +43,17 @@ func TestParseIPs(t *testing.T) {
{
"test multiple ips",
args{[]string{"192.168.0.2-192.168.0.6"}},
[]string{"192.168.0.2", "192.168.0.3", "192.168.0.4", "192.168.0.5", "192.168.0.6"},
[]string{"192.168.0.2:22", "192.168.0.3:22", "192.168.0.4:22", "192.168.0.5:22", "192.168.0.6:22"},
},
{
"test multiple ips",
args{[]string{"192.168.0.2-192.168.0.3", "192.168.0.5-192.168.0.6"}},
[]string{"192.168.0.2", "192.168.0.3", "192.168.0.5", "192.168.0.6"},
[]string{"192.168.0.2:22", "192.168.0.3:22", "192.168.0.5:22", "192.168.0.6:22"},
},
{
"test multiple ips",
args{[]string{"192.168.0.2-192.168.0.4", "192.168.0.8"}},
[]string{"192.168.0.2", "192.168.0.3", "192.168.0.4", "192.168.0.8"},
[]string{"192.168.0.2:22", "192.168.0.3:22", "192.168.0.4:22", "192.168.0.8:22"},
},
}
for _, tt := range tests {
Expand Down Expand Up @@ -132,7 +118,7 @@ func TestFileExist(t *testing.T) {
args args
want bool
}{
{"file exist", args{"/home/louis/.ssh/id_rsa"}, true},
{"file exist", args{"utils.go"}, true},
{"file not exist", args{"/home/louis/.ssh/id_rsa.public"}, false},
{"PkgFile", args{"/root/kube1.18.0.tar.gz"}, false},
}
Expand Down Expand Up @@ -207,6 +193,7 @@ func TestCanUpgradeByNewVersion(t *testing.T) {
{"test01", args{"v1.18.5", "v1.16.14"}, true},
{"test02", args{"v1.19.3", "v1.18.9"}, false},
{"test03", args{"v1.15.11", "v1.18.9"}, true},
{"test03", args{"v1.20.1", "v1.19.6"}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Loading

0 comments on commit 2e763f4

Please sign in to comment.