linux安装KubeSphere
介绍
KubeSphere 是在目前主流容器调度平台 Kubernetes 之上构建的企业级分布式多租户容器平台,提供简单易用的操作界面以及向导式操作方式,在降低用户使用容器调度平台学习成本的同时,极大减轻开发、测试、运维的日常工作的复杂度,旨在解决 Kubernetes 本身存在的存储、网络、安全和易用性等痛点。除此之外,平台已经整合并优化了多个适用于容器场景的功能模块,以完整的解决方案帮助企业轻松应对敏捷开发与自动化运维、微服务治理、多租户管理、工作负载和集群管理、服务与网络管理、应用编排与管理、镜像仓库管理和存储管理等业务场景。
KubeSphere安装
先要安装k8s
linux安装部署k8s(kubernetes)和解决遇到的坑
在master节点上安装k8s
hostnamectl set-hostname q-master
reboot
sudo yum remove docker*
sudo yum install -y yum-utils
#配置docker的yum地址
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#安装指定版本
sudo yum install -y docker-ce-20.10.7 docker-ce-cli-20.10.7 containerd.io-1.4.6
#启动&开机启动docker
systemctl enable docker --now
# docker加速配置
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://82m9ar63.mirror.aliyuncs.com"],
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
#关闭swap
swapoff -a
sed -ri 's/.*swap.*/#&/' /etc/fstab
#允许 iptables 检查桥接流量
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sudo sysctl --system
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
#安装 kubelet,kubeadm,kubectl
sudo yum install -y kubelet-1.20.9 kubeadm-1.20.9 kubectl-1.20.9
#启动kubelet
sudo systemctl enable --now kubelet
#所有机器配置master域名
echo "172.16.0.22 q-master" >> /etc/hosts
kubeadm init --apiserver-advertise-address=172.16.0.22 --control-plane-endpoint=q-master --image-repository registry.cn-hangzhou.aliyuncs.com/lfy_k8s_images --kubernetes-version v1.20.9 --service-cidr=10.96.0.0/16 --pod-network-cidr=192.168.0.0/16
#执行成功后按提示执行
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
export KUBECONFIG=/etc/kubernetes/admin.conf
安装网络插件
#安装网络插件
vi calico.yaml
kubectl apply -f calico.yaml
kubectl get pod -A
watch -n 1 kubectl get pod -A
yum install -y nfs-utils
# 在master 执行以下命令
echo "/nfs/data/ *(insecure,rw,sync,no_root_squash)" > /etc/exports
# 执行以下命令,启动 nfs 服务;创建共享目录
mkdir -p /nfs/data
# 在master执行
systemctl enable rpcbind
systemctl enable nfs-server
systemctl start rpcbind
systemctl start nfs-server
# 使配置生效
exportfs -r
#检查配置是否生效
exportfs
安装其他插件
vi default-storage.yaml
kubectl apply -f default-storage.yaml
watch -n 1 kubectl get pod -A
vi metrics-server.yaml
kubectl apply -f metrics-server.yaml
watch -n 1 kubectl get pod -A
kubectl describe pod nfs-client-provisioner-df6455b66-d97z5
kubectl describe node q-master
kubectl taint nodes node-role.kubernetes.io/master:NoSchedule-
kubectl taint nodes q-master node-role.kubernetes.io/master:NoSchedule-
watch -n 1 kubectl get pod -A
安装kubesphere
vi kubesphere-installer.yaml
apply -f kubesphere-installer.yaml
kubectl apply -f kubesphere-installer.yaml
vi cluster-configuration.yaml
kubectl apply -f cluster-configuration.yaml
vi cluster-configuration.yaml
rm -f cluster-configuration.yaml
vi cluster-configuration.yaml
kubectl apply -f cluster-configuration.yaml
kubectl get pod -A
kubectl apply -f cluster-configuration.yaml
apply -f kubesphere-installer.yaml
kubectl apply -f kubesphere-installer.yaml
rm -f cluster-configuration.yaml
vi cluster-configuration.yaml
kubectl apply -f cluster-configuration.yaml
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f
kubectl get pod -A
kubectl get no
curl http://172.16.0.22:30880
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f
curl 133.198.29.22:30880
curl 172.16.0.22:30880
kubectl edit daemonset -n kube-system calico-node
kubectl get no
kubectl delete node edgenode-1
kubectl edit daemonset -n kube-system calico-node
kubectl edit daemonset -n kube-system kube-proxy
kubectl edit daemonset -n kube-system nodelocaldns
参考链接: https://blog.csdn.net/An1090239782/article/details/110038285 https://kubesphere.io/zh/docs/quick-start/minimal-kubesphere-on-k8s/ https://www.yuque.com/leifengyang/oncloud/gz1sls