Skip to content

Commit

Permalink
Merge pull request #10 from paradeum-team/jyliu
Browse files Browse the repository at this point in the history
docs: add Rocky-Linux8.5部署单master-k8s.md
  • Loading branch information
ss75710541 authored Feb 18, 2022
2 parents 8d71498 + 355bbe0 commit cc7fab1
Show file tree
Hide file tree
Showing 2 changed files with 212 additions and 1 deletion.
163 changes: 163 additions & 0 deletions docs/Rocky-Linux8.5部署单master-k8s.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Rocky Linux部署单master k8s

## 主机规划

| IP | 主机名或用途 |
| ------------ | ------------------- |
| 172.30.1.198 | master1.solarfs.k8s |
| 172.30.1.199 | infra1.solarfs.k8s |

| 信息 | 备注 |
| ------------ | --------------- |
| 系统版本 | Rocky Linux 8.5 |
| Docker 版本 | 20.10 |
| K8s 版本 | 1.22.2 |
| Pod 网段 | 10.128.0.0/16 |
| Service 网段 | 10.96.0.0/12 |

## 下载 ansible-k8s

登录master1 主机

```
yum install -y git epel-release
yum install -y ansible
mkdir -p /data
cd /data
git clone https://github.com/paradeum-team/ansible-k8s.git
```

## 修改 ansible 配置

```
cd /data/ansible-k8s/
cp ansible.hosts.tpl ansible.hosts.tmp
```

修改 `ansible.hosts.tmp` 如下

```
[k8sCluster:children]
masters
nodes
install
new_nodes
# Set variables common for all k8s-cluster hosts
[k8sCluster:vars]
# SSH user, this user should allow ssh based auth without requiring a password
ansible_ssh_user=root
#ansible_ssh_pass=xxxxx
ansible_port=22
# If ansible_ssh_user is not root, ansible_become must be set to true
ansible_become=false
# 是否更新操作系统及内核
is_system_update=True
# 默认节点是否公网节点
public_network_node = False
# 是否开启 flannel
flannel_enable=True
# api server 域名, 单master 写master ip, 多master 写vip
master_vip="172.30.1.198"
master_vip_advertise_address="x.x.x.x"
node_domain=solarfs.k8s
install_domain=install.{{node_domain}}
api_server_domain="api-server.{{node_domain}}"
api_server_port="6443"
# k8s 版本
k8s_version=1.22.2
# 定义外部镜像仓库
registry_domain=registry.hisun.netwarps.com
registry_repo="{{registry_domain}}"
kubeadm_registry_repo="{{registry_domain}}"
coredns_image_repo="docker.io/coredns"
coredns_image_tag="1.8.0"
flannel_image_repo="quay.io"
flannel_image_tag="v0.15.1"
# subnet
service_subnet=10.96.0.0/12
pod_subnet=10.128.0.0/16
# helm
helm_binary_md5=24b16800f8c7f44b5dd128e3355ecf1b
helm_binary_url=https://pnode.solarfs.io/dn/file/{{helm_binary_md5}}/helm-v3.6.3-linux-amd64.tar.gz
[install]
master1.kuggatest.k8s
[masters]
master1.kuggatest.k8s ansible_host=172.30.1.198
[nodes]
infra1.kuggatest.k8s ansible_host=172.30.1.199
[new_nodes]
```

## 修改 config 配置

```
cp config.cfg.example config.cfg
```

修改 `config.cfg` 内容如下

```
#!/bin/bash
set -x
# 当前ansible-k8s目录所在路径,默认一般情况下不需要改动,如有变动请根据实际情况修改
BASE_DIR="/data/ansible-k8s"
# local network card
LOCAL_ENNAME=eth0 ## Need to check
# 是否线下安装
is_offline=False
# 主机环境实际使用的上游dns server,酌情修改,公司内部实际使用的dns服务ip地址
upstream_dns_ips="100.100.2.136 100.100.2.138 114.114.114.114"
# 是否安装时间同步服务(chronyd),True表示安装,False表示不安装,默认True,只有已经安装了 ntp 时间同步服务的情况下不安装;
chronyd_install="True"
# chronyd_install=True 时才生效,定义外部 ntp_server, ntp.cloud.aliyuncs.com 为阿里云内部 ntp 同步 server, 非阿里云主机访问可以改为 ntp.aliyun.com, 或自定义的 ntp server
ntp_server="ntp.aliyun.com"
export LOCAL_IP=`ip a show $LOCAL_ENNAME|awk '/inet.*brd.*'$LOCAL_ENNAME'/{print $2}'|awk -F "/" '{print $1}'` # 无需改动
if [ -z "$LOCAL_IP" ];then
echo "get $LOCAL_ENNAME ip error!" && exit 1
fi
# yum repo && config server
export CONFIGSERVER_IP="$LOCAL_IP"
export CONFIGSERVER_PORT="8081"
```

## 配置master1免密登录自己和其它主机


## 安装 k8s

所有主机初始化, 初始化完成后所有主机会重启

```
./base_init.sh
```

登录 master1 主机,安装 k8s

```
./install_k8s.sh
```

## 安装 ingress-nginx

参考:[使用helm在k8s1.22.2安装ingress-nginx](https://github.com/paradeum-team/operator-env/blob/main/ingress/使用helm在k8s1.22.2安装ingress-nginx.md)
50 changes: 49 additions & 1 deletion docs/部署keepalived+haproxy高可用k8s1.22.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Service 网段|10.96.0.0/12
登录 master1 主机

```
yum install -y git ansible
yum install -y git epel-release
yum install -y ansible
mkdir -p /data
cd /data
git clone https://github.com/paradeum-team/ansible-k8s.git
Expand Down Expand Up @@ -124,6 +125,53 @@ logging3.solarfs.k8s ansible_host=172.16.115.194
```

## 修改 `config.cfg`

```
cp config.cfg.example config.cfg
```

修改 `config.cfg` 内容如下

```
#!/bin/bash
set -x
# 当前ansible-k8s目录所在路径,默认一般情况下不需要改动,如有变动请根据实际情况修改
BASE_DIR="/data/ansible-k8s"
# local network card
LOCAL_ENNAME=eth0 ## Need to check
# 是否线下安装
is_offline=False
# 主机环境实际使用的上游dns server,酌情修改,公司内部实际使用的dns服务ip地址
upstream_dns_ips="172.16.21.86 172.16.21.87 114.114.114.114"
# 是否安装时间同步服务(chronyd),True表示安装,False表示不安装,默认True,只有已经安装了 ntp 时间同步服务的情况下不安装;
chronyd_install="True"
# chronyd_install=True 时才生效,定义外部 ntp_server, ntp.cloud.aliyuncs.com 为阿里云内部 ntp 同步 server, 非阿里云主机访问可以改为 ntp.aliyun.com, 或自定义的 ntp server
ntp_server="ntp.aliyun.com"
export LOCAL_IP=`ip a show $LOCAL_ENNAME|awk '/inet.*brd.*'$LOCAL_ENNAME'/{print $2}'|awk -F "/" '{print $1}'` # 无需改动
if [ -z "$LOCAL_IP" ];then
echo "get $LOCAL_ENNAME ip error!" && exit 1
fi
# yum repo && config server
export CONFIGSERVER_IP="$LOCAL_IP"
export CONFIGSERVER_PORT="8081"
# 高可用部署开关,True为部署高可用版,False为单机版一般无需改动
if [ `$BASE_DIR/read-ansible-hosts.py -k masters|wc -l` -gt 1 ] ;then
HA="True"
else
HA="False"
fi
```

## 配置master1免密登录自己和其它主机

Expand Down

0 comments on commit cc7fab1

Please sign in to comment.