Ubuntu 22.04.3 LTS单机私有化部署sealos

  • 推荐使用奇数台 Master 节点和若干 Node 节点
  • 操作系统 :Ubuntu 22.04 LTS
  • 内核版本 :5.4 及以上
  • 配置推荐 :CPU 4 核 , 内存 8GB, 存储空间 100GB 以上
  • 最小配置 :CPU 2 核 , 内存 4GB, 存储空间 60GB

这里采用的Ubuntu 22.04.3 LTS  版本,Ubuntu 20.04.4 LTS这个版本应该也是可以的有兴趣可以测试一下。不想私有化部署的可以直接访问sealos Cloud

root@master:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy

 分区大小,搭建好后磁盘占用51G,所以分区一定要大,这里是通过扩容lvs增加的容量。

root@master:~# df -Th
Filesystem                        Type     Size  Used Avail Use% Mounted on
tmpfs                             tmpfs    791M  8.2M  783M   2% /run
/dev/mapper/ubuntu--vg-ubuntu--lv ext4      97G   51G   42G  55% /
tmpfs                             tmpfs    3.9G     0  3.9G   0% /dev/shm
tmpfs                             tmpfs    5.0M     0  5.0M   0% /run/lock
/dev/sda2                         ext4     2.0G  251M  1.6G  14% /boot
tmpfs                             tmpfs    791M  4.0K  791M   1% /run/user/0

 磁盘容量不够参考,磁盘容量足够请绕过此步骤

root@master:~# lvs
  LV        VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  ubuntu-lv ubuntu-vg -wi-ao---- <49.00g
root@master:~# vgs
  VG        #PV #LV #SN Attr   VSize   VFree
  ubuntu-vg   1   1   0 wz--n- <98.00g 49.00g
root@master:~# pvs
  PV         VG        Fmt  Attr PSize   PFree
  /dev/sda3  ubuntu-vg lvm2 a--  <98.00g 49.00g
root@master:~# lsblk
NAME                      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0                       7:0    0  63.5M  1 loop /snap/core20/2015
loop1                       7:1    0 111.9M  1 loop /snap/lxd/24322
loop2                       7:2    0  63.4M  1 loop /snap/core20/1974
loop3                       7:3    0  53.3M  1 loop /snap/snapd/19457
loop4                       7:4    0  40.8M  1 loop /snap/snapd/20092
sda                         8:0    0   100G  0 disk
├─sda1                      8:1    0     1M  0 part
├─sda2                      8:2    0     2G  0 part /boot
└─sda3                      8:3    0    98G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0    49G  0 lvm  /var/lib/containers/storage/overlay
                                                    /
sr0                        11:0    1  1024M  0 rom
 
root@master:~# lvextend -L +49G /dev/ubuntu-vg/ubuntu-lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from <49.00 GiB (12543 extents) to <98.00 GiB (25087 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.
root@master:~# df -Th
Filesystem                        Type     Size  Used Avail Use% Mounted on
tmpfs                             tmpfs    791M  3.3M  788M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv ext4      48G   40G  6.4G  86% /
tmpfs                             tmpfs    3.9G     0  3.9G   0% /dev/shm
tmpfs                             tmpfs    5.0M     0  5.0M   0% /run/lock
/dev/sda2                         ext4     2.0G  251M  1.6G  14% /boot
tmpfs                             tmpfs    791M  4.0K  791M   1% /run/user/0
 
 
root@master:~# resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 7, new_desc_blocks = 13
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 25689088 (4k) blocks long.
 
root@master:~# df -Th
Filesystem                        Type     Size  Used Avail Use% Mounted on
tmpfs                             tmpfs    791M  3.3M  788M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv ext4      97G   40G   53G  43% /
tmpfs                             tmpfs    3.9G     0  3.9G   0% /dev/shm
tmpfs                             tmpfs    5.0M     0  5.0M   0% /run/lock
/dev/sda2                         ext4     2.0G  251M  1.6G  14% /boot
tmpfs                             tmpfs    791M  4.0K  791M   1% /run/user/0

 首先安装sealos

apt install jq curl vim -y
curl --silent "https://api.github.com/repos/labring/sealos/releases" | jq -r '.[].tag_name'

echo "deb [trusted=yes] https://apt.fury.io/labring/ /" | sudo tee /etc/apt/sources.list.d/labring.list

sudo apt update && sudo apt install sealos -y

下面安装步骤是参考大佬的文章

Sealos 私有化部署完全指南_sealos 部署_米开朗基杨的博客-CSDN博客

  230   22:39:35 root  sealos apply -f Clusterfile
  231   22:41:17 root  sh sealos.sh
  232   22:59:47 root  kubectl get pods -A
  233   23:00:12 root  sealos run docker.io/labring/sealos-cloud:latest    --env cloudDomain="10.1.1.138.nip.io"

 Cluster

sealos gen labring/kubernetes:v1.25.6 \
    labring/helm:v3.12.0 \
    labring/calico:v3.24.1 \
    labring/cert-manager:v1.8.0 \
    labring/openebs:v3.4.0 \
    --masters 10.1.1.138 > Clusterfile


sealos apply -f Clusterfile

 等待集群就绪后 , 使用 kubectl get pods -A 查看集群状态:

vim sealos.sh

#!/bin/bash
set -e

cat << EOF > ingress-nginx-config.yaml
apiVersion: apps.sealos.io/v1beta1
kind: Config
metadata:
  creationTimestamp: null
  name: ingress-nginx-config
spec:
  data: |
    controller:
      hostNetwork: true
      kind: DaemonSet
      service:
        type: NodePort
  match: docker.io/labring/ingress-nginx:v1.5.1
  path: charts/ingress-nginx/values.yaml
  strategy: merge
EOF

sealos run docker.io/labring/kubernetes-reflector:v7.0.151\
    docker.io/labring/ingress-nginx:v1.5.1\
    docker.io/labring/zot:v1.4.3\
    docker.io/labring/kubeblocks:v0.5.3\
    --env policy=anonymousPolicy\
    --config-file ingress-nginx-config.yaml

echo "patch ingress-nginx-controller tolerations to allow run on master node, if you don't want to run on master node, please ignore this step"
kubectl -n ingress-nginx patch ds ingress-nginx-controller -p '{"spec":{"template":{"spec":{"tolerations":[{"key":"node-role.kubernetes.io/control-plane","operator":"Exists","effect":"NoSchedule"}]}}}}'

echo "waitting for kubeblocks crd created, this may take a while"
while ! kubectl get clusterdefinitions.apps.kubeblocks.io redis >/dev/null 2>&1; do
  sleep 5
done

echo "start patch redis clusterdefinition"
kubectl patch clusterdefinitions.apps.kubeblocks.io redis --type='json' -p '[{"op": "add", "path": "/spec/componentDefs/0/podSpec/containers/1/resources/limits", "value": {"cpu":"100m", "memory":"100Mi"}}]'
echo "patch redis success"

echo "wait for all pod to be ready then install Sealos"
kubectl get po -A

 sh sealos.sh

sh sealos.sh

 执行时间长耐心等待

kubectl get po -A

过程可能稍长,等待所有 Pod 均为 Ready 状态后,即可进行下一步。

最后一条命令

sealos run docker.io/labring/sealos-cloud:latest    --env cloudDomain="10.1.1.138.nip.io"

过程还是很曲折,不过最后总算成功了,其实大佬的文章还得仔细看,能节约不少时间,阿里云的无影云桌面有3个月的试用,使用阿里云的无影云桌面也测试成功,就是有一点没有搞定,登陆后可以输入密码,但是浏览器一直提示安全问题,ubuntu不知道怎么设置才能正常。

阿里云无影云桌面版本,浏览器打开的问题暂时还没有解决办法。

root@1:~# lsb_release -a
LSB Version:	core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.4 LTS
Release:	20.04
Codename:	focal

windows的CHROME的设置请看下面的解决办法。

mongodb需要avx支持,如果cpu不支持avx会失败,J1900不支持avx所以这个坑请跳过。

这里要非常感谢BXY大佬!

日志查看参考

kubectl logs  sealos-mongodb-mongodb-0 -n sealos

浏览器访问 Sealos 网址时提示“不安全”
如果您在部署过程中提供了正确的证书,但仍然收到这个提示,可以采取以下措施:

检查证书是否和域名匹配:证书需要解析 {{ $domain }} 及 *.{{ $domain }};
检查证书是否被正确地使用 base64 编码并写入到 tls-secret.yaml 文件中;
如果您在部署过程中没有提供证书,那么这种现象是正常的,因为默认使用的是 Sealos 的自签名证书。您可以选择以下两种方式解决:

信任证书:在浏览器中导出证书,然后双击证书打开,导入到受信任的根证书颁发机构中;
关闭浏览器的安全检查:以 Chrome 为例,修改 Chrome 浏览器的快捷方式,在目标后面添加 --ignore-certificate-errors 参数,然后重新打开浏览器。
部署时卡在 Waiting waiting for mongodb secret generated 怎么办?
Sealos 依赖 kubeblocks 提供的数据库服务。如果在部署过程中卡在这一步,说明在上一步,部署 Sealos 依赖组件时出错了。您应该尝试重新部署。

如何重新部署?
如果您需要重新部署,只需执行以下命令:

$ sealos reset
这个命令将清理所有集群资源,让您可以从头开始部署。
 

本文参考大佬米开朗基杨的文章,非常感谢!
https://blog.csdn.net/alex_yangchuansheng/article/details/131937199

 最后欣赏一下sealos的桌面Ubuntu 22.04.3 LTS单机私有化部署sealos_第1张图片

你可能感兴趣的:(ubuntu,linux,运维)