• FAQ安装部署
  • KubeSphere 3.0.0 在阿里云、腾讯云、物理机单机 All-in-one 经验总结

我的服务器硬件信息说明

8核 16GB 5Mbps
公网IP:81.61.121.155
私有IP:172.16.0.5
安全组是开放所有端口

我的服务器软件信息说明

系统:CentOS 7.8

关闭 SELinux
setenforce 0 && sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

禁用防火墙
systemctl stop firewalld && systemctl disable firewalld && echo "vm.swappiness = 0" >> /etc/sysctl.conf && swapoff -a && sysctl -w vm.swappiness=0

安装一些简单工具:
yum install -y zip unzip lrzsz git epel-release wget htop deltarpm

服务器更换 CentOS YUM 源为阿里云
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all && yum makecache
yum update -y

时间同步
timedatectl && timedatectl set-ntp true

设置 hostname,这个最好设置一下,并且设置全部小写字母和数字,一定要小写字母
hostnamectl set-hostname master

开始在所选安装机器上设置免密登录,我这里选择了 master1
ssh-keygen -t rsa -b 2048 -N '' -f ~/.ssh/id_rsa

这里都是内网地址
ssh-copy-id -i /root/.ssh/id_rsa.pub -p 22 root@172.16.0.5

测试下是否可以免登陆:
ssh -p 22 root@172.16.0.5

安装 Docker

  • 虽然 kubekey 安装中间会自动帮我们安装 docker,但是安装后默认的源是 Docker 国外的会很慢
  • 所以我们可以考虑自己安装 Docker 并且修改源。当前时间 2020-10 KubeSphere 3.0.0 用的是 Docker version 19.03.13, build 4484c46d9d
  • 开始安装 Docker
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y containerd.io docker-ce-19.03.13 docker-ce-cli-19.03.13

systemctl start docker
systemctl enable docker

修改镜像源配置
vim /etc/docker/daemon.json

{
  "registry-mirrors": [
    "https://ldhc17y9.mirror.aliyuncs.com",
    "https://hub-mirror.c.163.com",
    "https://mirror.baidubce.com",
    "https://docker.mirrors.ustc.edu.cn"
  ]
}

systemctl daemon-reload
systemctl restart docker

安装 Kubernetes + KubeSphere

wget -c https://kubesphere.io/download/kubekey-v1.0.0-linux-amd64.tar.gz -O - | tar -xz
chmod +x kk

开始安装,终端会出现一个当前环境已有环境检查,比如 docker 已安装等
./kk create cluster --with-kubernetes v1.17.9 --with-kubesphere v3.0.0

如果安装过程出现错误中断了:Failed to init kubernetes cluster: interrupted by error
那就重新再执行下上面的脚本,重新来一次

当控制台出现这一行字,表示 kubesphere 开始进入守护进程方式安装后续部分了
INFO[12:51:25 CST] Installation is complete.
Please check the result using the command:
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f

这时候你可以看到你服务器已经下载了这些镜像:
[root@master1 ~]# docker images
REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE
kubesphere/ks-installer              v3.0.0              893b46ffa208        6 weeks ago         692MB
kubesphere/kube-proxy                v1.17.9             ddc09a4c2193        3 months ago        117MB
kubesphere/kube-controller-manager   v1.17.9             c7f1dde319ee        3 months ago        161MB
kubesphere/kube-apiserver            v1.17.9             7417868987f3        3 months ago        171MB
kubesphere/kube-scheduler            v1.17.9             f7b1228fa995        3 months ago        94.4MB
calico/node                          v3.15.1             1470783b1474        3 months ago        262MB
calico/pod2daemon-flexvol            v3.15.1             a696ebcb2ac7        3 months ago        112MB
calico/cni                           v3.15.1             2858353c1d25        3 months ago        217MB
calico/kube-controllers              v3.15.1             8ed9dbffe350        3 months ago        53.1MB
kubesphere/provisioner-localpv       1.10.0              6b5529f464f7        5 months ago        68.4MB
kubesphere/node-disk-operator        0.5.0               8741fafb7b21        5 months ago        167MB
kubesphere/node-disk-manager         0.5.0               dbbed43bcbdb        5 months ago        168MB
kubesphere/k8s-dns-node-cache        1.15.12             5340ba194ec9        6 months ago        107MB
coredns/coredns                      1.6.9               faac9e62c0d6        7 months ago        43.2MB
kubesphere/etcd                      v3.3.12             28c771d7cfbf        21 months ago       40.6MB
kubesphere/pause                     3.1                 da86e6ba6ca1        2 years ago         742kB

我们可以根据命令来查看守护进程安装进度:
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f

当我们看到这个就表示守护进程安装成功了
#####################################################
###              Welcome to KubeSphere!           ###
#####################################################

Console: http://172.16.0.5:30880
Account: admin
Password: P@88w0rd

NOTES:
  1. After logging into the console, please check the
     monitoring status of service components in
     the "Cluster Management". If any service is not
     ready, please wait patiently until all components
     are ready.
  2. Please modify the default password after login.

#####################################################
https://kubesphere.io             2020-10-30 17:18:00
#####################################################


这时候我们再来看看下载了哪些镜像:
[root@master1 ~]# docker images
REPOSITORY                                    TAG                 IMAGE ID            CREATED             SIZE
kubesphere/ks-installer                       v3.0.0              893b46ffa208        6 weeks ago         692MB
kubesphere/ks-controller-manager              v3.0.0              85bd13080839        2 months ago        82MB
kubesphere/ks-apiserver                       v3.0.0              d9fac59cfb8c        2 months ago        120MB
kubesphere/ks-console                         v3.0.0              d5987e1f99ac        2 months ago        95.5MB
prom/prometheus                               v2.20.1             b205ccdd28d3        2 months ago        145MB
kubesphere/notification-manager               v0.1.0              331a0e6ece23        3 months ago        47.5MB
kubesphere/notification-manager-operator      v0.1.0              c441b79e9606        3 months ago        44.4MB
kubesphere/kube-proxy                         v1.17.9             ddc09a4c2193        3 months ago        117MB
kubesphere/kube-apiserver                     v1.17.9             7417868987f3        3 months ago        171MB
kubesphere/kube-controller-manager            v1.17.9             c7f1dde319ee        3 months ago        161MB
kubesphere/kube-scheduler                     v1.17.9             f7b1228fa995        3 months ago        94.4MB
calico/node                                   v3.15.1             1470783b1474        3 months ago        262MB
calico/pod2daemon-flexvol                     v3.15.1             a696ebcb2ac7        3 months ago        112MB
calico/cni                                    v3.15.1             2858353c1d25        3 months ago        217MB
calico/kube-controllers                       v3.15.1             8ed9dbffe350        3 months ago        53.1MB
kubesphere/prometheus-config-reloader         v0.38.3             8011d6eb5bac        4 months ago        10.1MB
kubesphere/prometheus-operator                v0.38.3             a703e647b26f        4 months ago        38.6MB
prom/alertmanager                             v0.21.0             c876f5897d7b        4 months ago        55.5MB
kubesphere/kube-state-metrics                 v1.9.6              092e8ed1e0b3        5 months ago        32.8MB
kubesphere/provisioner-localpv                1.10.0              6b5529f464f7        5 months ago        68.4MB
kubesphere/node-disk-operator                 0.5.0               8741fafb7b21        5 months ago        167MB
kubesphere/node-disk-manager                  0.5.0               dbbed43bcbdb        5 months ago        168MB
kubesphere/linux-utils                        1.10.0              28c1cd0be1ea        5 months ago        11MB
osixia/openldap                               1.3.0               faac9bb59f83        5 months ago        260MB
kubesphere/metrics-server                     v0.3.7              07c9e703ca2c        6 months ago        55.4MB
kubesphere/k8s-dns-node-cache                 1.15.12             5340ba194ec9        6 months ago        107MB
coredns/coredns                               1.6.9               faac9e62c0d6        7 months ago        43.2MB
csiplugin/snapshot-controller                 v2.0.1              525889021849        9 months ago        41.4MB
kubesphere/node-exporter                      ks-v0.18.1          cfb0175954de        11 months ago       23.7MB
kubesphere/kubectl                            v1.0.0              7f81664a09d0        12 months ago       82.1MB
redis                                         5.0.5-alpine        ed7d2ff5a623        14 months ago       29.3MB
jimmidyson/configmap-reload                   v0.3.0              7ec24a279487        14 months ago       9.7MB
kubesphere/etcd                               v3.3.12             28c771d7cfbf        21 months ago       40.6MB
kubesphere/kube-rbac-proxy                    v0.4.1              70eeaa7791f2        21 months ago       41.3MB
kubesphere/pause                              3.1                 da86e6ba6ca1        2 years ago         742kB
mirrorgooglecontainers/defaultbackend-amd64   1.4                 846921f0fe0e        3 years ago         4.84MB


等个 5 分钟再来看看有哪些 pod:
[root@master ~]# kubectl get pods -A
NAMESPACE                      NAME                                               READY   STATUS    RESTARTS   AGE
kube-system                    calico-kube-controllers-59d85c5c84-qbwqb           1/1     Running   0          12m
kube-system                    calico-node-zn84s                                  1/1     Running   0          12m
kube-system                    coredns-74d59cc5c6-plx4c                           1/1     Running   0          12m
kube-system                    coredns-74d59cc5c6-zct54                           1/1     Running   0          12m
kube-system                    kube-apiserver-master                              1/1     Running   0          12m
kube-system                    kube-controller-manager-master                     1/1     Running   0          12m
kube-system                    kube-proxy-9672d                                   1/1     Running   0          12m
kube-system                    kube-scheduler-master                              1/1     Running   0          12m
kube-system                    metrics-server-5ddd98b7f9-dbc2n                    1/1     Running   0          11m
kube-system                    nodelocaldns-6w4rr                                 1/1     Running   0          12m
kube-system                    openebs-localpv-provisioner-84956ddb89-jkdns       1/1     Running   0          12m
kube-system                    openebs-ndm-fcrlq                                  1/1     Running   0          12m
kube-system                    openebs-ndm-operator-6896cbf7b8-sz2pv              1/1     Running   1          12m
kube-system                    snapshot-controller-0                              1/1     Running   0          9m46s
kubesphere-controls-system     default-http-backend-5d464dd566-cns9c              1/1     Running   0          9m24s
kubesphere-controls-system     kubectl-admin-6c9bd5b454-54xhj                     1/1     Running   0          6m22s
kubesphere-monitoring-system   alertmanager-main-0                                2/2     Running   0          7m35s
kubesphere-monitoring-system   kube-state-metrics-5c466fc7b6-z8w2c                3/3     Running   0          8m30s
kubesphere-monitoring-system   node-exporter-jvgws                                2/2     Running   0          8m31s
kubesphere-monitoring-system   notification-manager-deployment-7ff95b7544-zzk6p   1/1     Running   0          4m12s
kubesphere-monitoring-system   notification-manager-operator-5cbb58b756-pnpwr     2/2     Running   0          8m17s
kubesphere-monitoring-system   prometheus-k8s-0                                   3/3     Running   1          7m25s
kubesphere-monitoring-system   prometheus-operator-78c5cdbc8f-hjg7p               2/2     Running   0          8m31s
kubesphere-system              ks-apiserver-566f7d5c96-rnk96                      1/1     Running   0          7m57s
kubesphere-system              ks-console-fb4c655cf-nkq5q                         1/1     Running   0          9m12s
kubesphere-system              ks-controller-manager-64459d95bb-p9jz7             1/1     Running   0          7m57s
kubesphere-system              ks-installer-85854b8c8-cmppw                       1/1     Running   0          12m
kubesphere-system              openldap-0                                         1/1     Running   0          9m35s
kubesphere-system              redis-6fd6c6d6f9-96rs2                             1/1     Running   0          9m40s
    1 年 后

    奇怪的是腾讯云的VM是大写,而后面的具体主机又是小写,应该是Linux的严格大小写区分的问题。导致的提示

    这里写一下修改命令,以便帮到后面可能遇到问题的人。

    `hostnamectl set-hostname <NAME>`

    cdk8s-meek 你有配置腾讯云的负载均衡网关吗?我现在卡在这一步了,也没有对应的文档。