自学内容网 自学内容网

KubeSphere介绍及一键安装k8s

KubeSphere介绍

官网地址:https://kubesphere.io/zh/

KubeSphere愿景是打造一个以 Kubernetes 为内核的云原生分布式操作系统,它的架构可以非常方便地使第三方应用与云原生生态组件进行即插即用(plug-and-play)的集成,支持云原生应用在多云与多集群的统一分发和运维管理。提供简单易用的操作界面以及向导式操作方式,在降低用户使用容器调度平台学习成本的同时,极大减轻开发、测试、运维的日常工作的复杂度。

全栈的 Kubernetes 容器云 PaaS 解决方案,KubeSphere 是在 Kubernetes 之上构建的以应用为中心的多租户(NS、sa )容器平台,提供全栈的 IT 自动化运维的能力,简化企业的 DevOps 工作流。KubeSphere 提供了运维友好的向导式操作界面,帮助企业快速构建一个强大和功能丰富的容器云平台。

KubeSphere 作为企业级的全栈化容器平台,为用户提供了一个极致体验的 Web 控制台,让您能够像使用任何其他互联网产品一样,快速上手各项功能与服务。KubeSphere 目前提供了工作负载管理、微服务治理、DevOps 工程、Source to Image、多租户管理、多维度监控、日志查询与收集、告警通知、服务与网络、应用管理、基础设施管理、镜像管理、应用配置密钥管理等功能模块,并支持对接多种开源的存储与网络方案,支持高性能的商业存储与网络服务。

线上Demo体验:https://kubesphere.cloud/login/?redirect=%2Fconsole%2Fmanaged-cluster%2F

参考设置pwd:Aa123456.

KubeKey一键部署K8S集群

官方文档:https://kubesphere.io/zh/docs/v3.4/installing-on-linux/introduction/multioverview/

一台master node(初始化主节点)、两台 work node( join加入主节点)

安装docker

#移除以前的docker
sudo yum remove docker \
    docker-client \
    docker-client-latest \
    docker-common \
    docker-latest \
    docker-latest-logrotate \
    docker-logrotate \
    docker-engine

# 配置yum源
sudo yum install -y yum-utils
sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

# 安装docker    
sudo yum install -y docker-ce docker-ce-cli containerd.io

# 配置阿里云镜像
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://qiyb9988.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

# 启动Docker
sudo systemctl start docker
# 设置开机启动Docker
sudo systemctl enable docker
 
# 检查是否安装成功
sudo docker run hello-world

系统环境准备

# 节点之中不可以有重复的主机名,mac地址等,设置不同的hostname
hostnamectl set-hostname k8s-master
hostnamectl set-hostname k8s-node1
hostnamectl set-hostname k8s-node2

# 关闭防火墙
sudo systemctl stop firewalld 
sudo systemctl disable firewalld

# 将SElinux设置为permissive模式,禁用
sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcin$/SELINUX=permissive/' /etc/selinux/config 

# 关闭swap分区
sudo swapoff -a
sudo 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

# 安装依赖
yum -y install socat conntrack ebtables ipset net-tools

# 配置ssh互访,所有节点
ssh-keygen

ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.111

ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.112

ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.113

下载KubeKey

使用这里下载好的解压即可,也可使用curl 这行命令进行下载
链接:https://pan.baidu.com/s/1eiGc2t–IXmBFhtIQVK9Sg?pwd=c8ly
提取码:c8ly

# 只在master上执行即可
export KKZONE=cn

curl -sfL https://get-kk.kubesphere.io | sh -

# 为 kk 添加可执行权限:
chmod +x kk

创建集群

# 创建集群配置文件
./kk create config --with-kubernetes v1.22.12 --with-kubesphere v3.4.0

vim config-sample.yaml

spec:
  hosts:
  - {name: master, address: 192.168.0.111, internalAddress: 192.168.0.111, user: root, password: "123456"}
  - {name: node1, address: 192.168.0.112, internalAddress: 192.168.0.112, user: root, password: "123456"}
  - {name: node2, address: 192.168.0.113, internalAddress: 192.168.0.113, user: root, password: "123456"}
  roleGroups:
    etcd:
    - master
    control-plane: 
    - master
    worker:
    - node1
    - node2

# 创建集群 整个安装过程可能需要 10 到 20 分钟,具体取决于您的计算机和网络环境
./kk create cluster -f config-sample.yaml

# 安装完成后,您会看到如下内容
10:17:15 CST success: [master]
#####################################################
###              Welcome to KubeSphere!           ###
#####################################################

Console: http://192.168.0.110:30880
Account: admin
Password: P@88w0rd
NOTES:
  1. After you log into the console, please check the
     monitoring status of service components in
     "Cluster Management". If any service is not
     ready, please wait patiently until all components 
     are up and running.
  2. Please change the default password after login.

#####################################################
https://kubesphere.io             2023-10-26 10:25:15
#####################################################
10:25:32 CST success: [master]
10:25:32 CST Pipeline[CreateClusterPipeline] execute successfully
Installation is complete.

Please check the result using the command:

kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l 'app in (ks-install, ks-installer)' -o jsonpath='{.items[0].metadata.name}') -f

在这里插入图片描述

看到这里就算安装成功!


原文地址:https://blog.csdn.net/qq_45371023/article/details/140702528

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!