单机 KubeSphere v3.0的安装

单机 KubeSphere v3.0的安装

我是在虚拟机环境中安装的,4C、32G、120GB
注意:平台之间依赖厂家经过测试的版本,千万不要选择未经测试的版本,否则会卡在哪里得不到解决。
选择CentOS 7.7 + docker 19.3.14 + kubernetes 1.18.6 + kubesphere 3.0.0

0、安装虚拟机

VMware workstations

1、安装Linux

CentOS 7.7,最小安装,然后配置网卡

2、安装Docker

参考如下,贴子很多

systemctl disable firewalld
systemctl status firewalld
sed -i 's/enforcing/disabled/' /etc/selinux/config
setenforce 0
cat /etc/selinux/config
swapoff -a
sed -ri 's/.*swap.*/#&/' /etc/fstab
free -l -h
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
echo "net.bridge.bridge-nf-call-ip6tables = 1" >> /etc/sysctl.conf
echo "net.bridge.bridge-nf-call-iptables = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.all.forwarding = 1"  >> /etc/sysctl.conf
sysctl -p
yum remove docker \
           docker-client \
           docker-client-latest \
           docker-common \
           docker-latest \
           docker-latest-logrotate \
           docker-logrotate \
           docker-engine
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 docker-ce-19.03.14 docker-ce-cli-19.03.14 containerd.io
systemctl enable docker
systemctl start docker
docker version

3、安装KubeSphere

export KKZONE=cn
curl -sfL https://get-kk.kubesphere.io | VERSION=v1.0.1 sh -

Downloading kubekey v1.0.1 from https://kubernetes.pek3b.qingstor.com/kubekey/releases/download/v1.0.1/kubekey-v1.0.1-linux-amd64.tar.gz …

Kubekey v1.0.1 Download Complete!

chmod +x kk
docker version
yum install -y socat conntrack

保证如下组件安装了:sudo curl openssl ebtables socat ipset conntrack docker,务必在开始下面命令前安装完这些相关必要的组件

./kk create cluster --with-kubernetes v1.18.6 --with-kubesphere v3.0.0

下面为这个命令的输出:
Continue this installation? [yes/no]: yes
INFO[13:04:49 CST] Downloading Installation Files
INFO[13:04:49 CST] Downloading kubeadm …
INFO[13:04:50 CST] Downloading kubelet …
INFO[13:04:51 CST] Downloading kubectl …
INFO[13:04:51 CST] Downloading helm …
INFO[13:04:51 CST] Downloading kubecni …
INFO[13:04:52 CST] Configurating operating system …

INFO[13:04:55 CST] Installing docker …
INFO[13:04:55 CST] Start to download images on all nodes
[k8s-kubesphere] Downloading image: kubesphere/etcd:v3.3.12
[k8s-kubesphere] Downloading image: kubesphere/pause:3.2

[k8s-kubesphere] Downloading image: coredns/coredns:1.6.9
[k8s-kubesphere] Downloading image: kubesphere/k8s-dns-node-cache:1.15.12
[k8s-kubesphere] Downloading image: calico/kube-controllers:v3.15.1

[k8s-kubesphere] Downloading image: calico/pod2daemon-flexvol:v3.15.1

Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown ( i d − u ) : (id -u): (id−u):(id -g) $HOME/.kube/config

You should now deploy a pod network to the cluster.
Run “kubectl apply -f [podnetwork].yaml” with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/

You can now join any number of control-plane nodes by copying certificate authorities
and service account keys on each node and then running the following as root:
kubeadm join lb.kubesphere.local:6443 --token 7n691x.e88u2nmc7cy99plj
–discovery-token-ca-cert-hash sha256:f535950e23fbc39e1956e6f4c5ccecd29a9ffd1d432d2f157cbaad5bbdd873a8
–control-plane

Then you can join any number of worker nodes by running the following on each as root:
kubeadm join lb.kubesphere.local:6443 --token 7n691x.e88u2nmc7cy99plj
–discovery-token-ca-cert-hash sha256:f535950e23fbc39e1956e6f4c5ccecd29a9ffd1d432d2f157cbaad5bbdd873a8

NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
k8s-kubesphere NotReady master,worker 46s v1.18.6 8.1.3.151 CentOS Linux 7 (Core) 3.10.0-1062.el7.x86_64 docker://19.3.14
INFO[13:08:48 CST] Deploying KubeSphere …
v3.0.0

INFO[13:14:29 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

4、验证安装是否正常

执行下面命令

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://8.1.3.151: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             2021-01-14 08:20:51
#####################################################

单机 KubeSphere v3.0的安装
单机 KubeSphere v3.0的安装
单机 KubeSphere v3.0的安装

5、出现错误的情况

安装完成后,我都是重启了两遍虚拟机,然后才全部正常的

最常见的就是下载组件pod等时网络不通或者速度过慢,导致失败
一般就是反复尝试并切换到国内的镜像源上。

部署Kubernetes时出现ImagePullBackOff或ErrImagePull情况

参考:https://blog.csdn.net/lin_yx/article/details/111599937

第一步:查看那些pod不正常
kubectl get pod --all-namespaces

#kubectl get pod --all-namespaces
NAMESPACE                      NAME                                               READY   STATUS    RESTARTS   AGE
kube-system                    calico-kube-controllers-578894d4cd-jdsmt           1/1     Running   2          20h
kube-system                    calico-node-gpvlx                                  1/1     Running   2          20h
kube-system                    coredns-6b55b6764d-84mxp                           1/1     Running   2          20h
kube-system                    coredns-6b55b6764d-k6bzr                           1/1     Running   2          20h
kube-system                    kube-apiserver-k8s-kubesphere                      1/1     Running   2          20h
kube-system                    kube-controller-manager-k8s-kubesphere             1/1     Running   2          20h
kube-system                    kube-proxy-f7wrb                                   1/1     Running   4          20h
kube-system                    kube-scheduler-k8s-kubesphere                      1/1     Running   2          20h
kube-system                    metrics-server-f47758d8f-rswq5                     1/1     Running   2          18h
kube-system                    nodelocaldns-tfrlx                                 1/1     Running   2          20h
kube-system                    openebs-localpv-provisioner-84446d4bd7-b4hft       1/1     Running   1          20h
kube-system                    openebs-ndm-l9cp7                                  1/1     Running   3          20h
kube-system                    openebs-ndm-operator-6456dc9db-w2d6w               1/1     Running   2          20h
kube-system                    snapshot-controller-0                              1/1     Running   1          18h
kubesphere-controls-system     default-http-backend-857d7b6856-g8ljk              1/1     Running   1          18h
kubesphere-controls-system     kubectl-admin-58f985d8f6-jsshk                     1/1     Running   1          17h
kubesphere-monitoring-system   alertmanager-main-0                                2/2     Running   2          18h
kubesphere-monitoring-system   kube-state-metrics-95c974544-nw6vw                 3/3     Running   3          18h
kubesphere-monitoring-system   node-exporter-29zwp                                2/2     Running   2          18h
kubesphere-monitoring-system   notification-manager-deployment-7c8df68d94-6mk8m   1/1     Running   1          17h
kubesphere-monitoring-system   notification-manager-operator-6958786cd6-5hphl     2/2     Running   2          18h
kubesphere-monitoring-system   prometheus-k8s-0                                   3/3     Running   4          18h
kubesphere-monitoring-system   prometheus-operator-84d58bf775-kz29n               2/2     Running   2          18h
kubesphere-system              ks-apiserver-67c5fcfc66-xdlnw                      1/1     Running   0          91m
kubesphere-system              ks-console-b4df86d6f-vc8bl                         1/1     Running   1          18h
kubesphere-system              ks-controller-manager-57b966f8f4-b2p72             1/1     Running   0          91m
kubesphere-system              ks-installer-7cb866bd-bsfrt                        1/1     Running   1          20h
kubesphere-system              openldap-0                                         1/1     Running   1          18h
kubesphere-system              redis-644bc597b9-5kzsp                             1/1     Running   1          18h

kubectl get pods -n kube-system
第二步:查看这些不正常pod的原因
kubectl describe kubesphere-system/xxxxx --namespace kube-system
注意:一定要加上命名空间
第三步:手动下载pod,那个有问题就下载那个,一定要加上版本
docker pull kubesphere/xxxxx,卡在哪就下哪个,而且下载用describe看到的版本

上一篇:第一章 sysrepod概述


下一篇:自从上了K8S,项目更新都不带停机的!