目标:安装KubeSphere all-in-one
1.安装Docker
链接:阿里云的安装方法
以下是腾讯云安装方法
# 安装docker$ curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
# 启动docker$ systemctl start docker$ systemctl enable docker设置阿里云镜像源和腾讯云源
获取自己的阿里云镜像加速
链接:阿里云源
# 设置阿里云镜像源$ sudo mkdir -p /etc/docker
$ sudo tee /etc/docker/daemon.json <<-'EOF'{ "registry-mirrors": [ "https://mirror.ccs.tencentyun.com", "https://xxxx.mirror.aliyuncs.com", "https://docker.m.daocloud.io", "https://dockerproxy.com", "https://docker.nju.edu.cn", "https://docker.mirrors.ustc.edu.cn" ]}EOF
# 重启$ sudo systemctl daemon-reload$ sudo systemctl restart docker2.安装KubeSphere
安装依赖
# 安装依赖# 清除缓存$ yum makecache
$ yum -y install socat$ yum -y install conntrack-tools下载KubeSphere
下载完成后当前目录会有一个”kk”的文件
# 当服务器无法访问Github,需要设置$ export KKZONE=cn
# 下载$ curl -sfL https://get-kk.kubesphere.io | VERSION=v3.0.13 sh -安装
# 修改kk的文件可执行权限$ chmod +x kk
# 安装k8s和KubeSphere, 因为当前安装模式是all-in-one,所以基本不需要做任何配置./kk create cluster --with-kubernetes v1.22.12 --with-kubesphere v3.4.1安装的过程中有可能一直卡顿
# 如果一直有卡顿,可以使用下面命令去查看$ kubectl get pods -n kubesphere-system
# 详细提示通过以下命令# ks-console-85c97b6d7d-j6gnn,这个是上面的命令查看出来的kubectl describe pod ks-console-85c97b6d7d-j6gnn -n kubesphere-systempod节点被污染错误可以通过下面的修改
# 修改错误的pod节点,解决污染节点错误$ kubectl edit deployment ks-installer -n kubesphere-system
# 新增这个spec.template.spec下面的 tolerations: - key: "node-role.kubernetes.io/master" operator: "Exists" effect: "NoSchedule"方法二
# 查询所有节点$ kubectl get nodesNAME STATUS ROLES AGE VERSIONvm-0-12-centos Ready control-plane,master,worker 20h v1.22.12
# 清空污染节点信息, 可能会删除到某些东西,谨慎使用$ kubectl taint nodes vm-0-12-centos node-role.kubernetes.io/master-安装应用商店
# 安装应用商店的其中一种办法kubectl edit clusterconfiguration ks-installer -n kubesphere-system
# 更新以下内容openpitrix: store: enabled: true # 将“false”更改为“true”。安装Harbor
最简单的方式是通过应用商店安装
配置镜像
“insecure-registries”: [“ip:30002”]
安装Mysql
1.创建持久卷
创建mysql-pvc持久卷
挂载路径: /var/lib/mysql
2.创建配置字典
创建配置字典mysql-config
键名: my.cnf
挂载路径: /etc/mysql/conf.d
# config[client]default-character-set=utf8mb4
[mysql]default-character-set=utf8mb4
[mysqld]character-set-client-handshake=FALSEcharacter-set-server=utf8mb4collation-server=utf8mb4_unicode_ciinit_connect='SET NAMES utf8mb4'3.创建工作负载
创建有状态副本集
DockerHub容器: mysql:5.7
# 端口tcp-3306tcp-33060# 环境变量MYSQL_ROOT_PASSWORD="youpassword"4.创建服务
服务: mysql-nodeport
# 服务http-3306安装Redis
1.创建持久卷
创建redis-pvc持久卷
挂载目录:/data
2.创建配置字典
创建配置字典redis-config
键名
挂载目录:/usr/local/redis/conf/redis.conf
# config# Redis 配置文件
# 绑定到所有网络接口bind 0.0.0.0
# 禁用保护模式,允许从任何 IP 进行连接(注意安全性)protected-mode no
# 设置 Redis 监听的端口port 6379
# 设置持久化数据的存储目录dir /data
# 启用 AOF(追加文件)持久化模式appendonly yes
# 设置 Redis 访问密码,替换 yourpassword 为你的密码requirepass EctgV2ZLrmOFWnhI
# 最大内存使用限制(单位:字节),可根据需要调整maxmemory 256mb
# 当达到最大内存限制时的内存淘汰策略,这里使用所有键的 LRU(最近最少使用)策略maxmemory-policy allkeys-lru
# RDB 快照备份设置save 900 1 # 如果在 900 秒内至少有 1 个键被修改,则进行 RDB 快照备份save 300 10 # 如果在 300 秒内至少有 10 个键被修改,则进行 RDB 快照备份save 60 10000 # 如果在 60 秒内至少有 10000 个键被修改,则进行 RDB 快照备份
# RDB 文件名dbfilename dump.rdb3.创建工作负载
创建有状态副本集
DockerHub容器: redis
# 端口http-6379# 环境变量null4.创建服务
服务: redis-nodeport
# 服务http-6379安装Consul
1.创建持久卷
不需要持久卷
2.创建配置字典
不需要字典
3.创建工作负载
创建有状态副本集
DockerHub容器: consul
# 端口tcp-8300 TCP 8300tcp-8301 TCP 8301udp-8301 UDP 8301tcp-8302 TCP 8302udp-8302 UDP 8302tcp-8500 TCP 8500tcp-8600 TCP 8600udp-8600 UDP 8600# 环境变量null4.创建服务
服务: consul-nodeport
# 服务http-8500安装Nacos
1.创建持久卷
不需要持久卷
2.创建配置字典
不需要配置字典
3.创建工作负载
创建有状态副本集
DockerHub容器: nacos/nacos-server
# 端口http-8848 TCP 8848# 环境变量MYSQL_SERVICE_HOST mysql-w8ws.go-rs // mysql服务的DNSMYSQL_SERVICE_PORT 3306MYSQL_SERVICE_DB_NAME nacos-dataMYSQL_SERVICE_USER rootMYSQL_SERVICE_PASSWORD ******MODE standaloneJVM_XMS 512mJVM_XMX 512mJVM_XMN 256m4.创建服务
服务: nacos-nodeport
# 服务http-8848安装Elasticsearch
1.创建持久卷
创建es-pvc持久卷
挂载目录:/elasticsearch/data
2.创建配置字典
创建配置字典es-config
键名
挂载目录:/elasticsearch/config/elasticsearch.yml
# confighttp.host: 0.0.0.0xpack.security.enabled: false3.创建工作负载
创建有状态副本集
DockerHub容器: elasticsearch:8.12.2
# 端口http-9200 TCP 9200http-9300 TCP 9300# 环境变量discovery.type single-nodeES_JAVA_OPTS -Xms512m -Xmx512m // 如果生成环境则不需要限制4.创建服务
服务: es-nodeport
# 服务http-9200安装Kibana
1.创建持久卷
不需要持久卷
2.创建配置字典
不需要配置字典
3.创建工作负载
创建有状态副本集
DockerHub容器: kibana:8.12.2
# 端口http-5601 TCP 5601# 环境变量ELASTICSEARCH_HOSTS http://es-2gaq.go-rs:9200 // 这是es的DNS4.创建服务
服务: kibana-nodeport
# 服务http-5601安装RocketMQ-Namesrv
1.创建持久卷
创建rocketmq-pvc持久卷(broker共用同一个)
挂载目录:/opt/store
2.创建配置字典
不需要配置字典
3.创建工作负载
创建有状态副本集
DockerHub容器: foxiswho/rocketmq
# 端口http-9876 TCP 9876# 环境变量不需要创建4.创建服务
服务: null
# 服务不需要创建安装RocketMQ-Broker
1.创建持久卷
创建rocketmq-pvc持久卷(broker共用同一个)
挂载目录:/opt/store
2.创建配置字典
创建配置字典rocketmq-config
键名
挂载目录:/etc/rocketmq/broker.conf
# config# Licensed to the Apache Software Foundation (ASF) under one or more# contributor license agreements. See the NOTICE file distributed with# this work for additional information regarding copyright ownership.# The ASF licenses this file to You under the Apache License, Version 2.0# (the "License"); you may not use this file except in compliance with# the License. You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
# 所属集群名字brokerClusterName=DefaultCluster
# broker 名字,注意此处不同的配置文件填写的不一样,如果在 broker-a.properties 使用: broker-a,# 在 broker-b.properties 使用: broker-bbrokerName=broker-a
# 0 表示 Master,> 0 表示 SlavebrokerId=0
# nameServer地址,分号分割# namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
# 启动IP,如果 docker 报 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.120:10909> failed# 解决方式1 加上一句 producer.setVipChannelEnabled(false);,解决方式2 brokerIP1 设置宿主机IP,不要使用docker 内部IP# brokerIP1=192.168.50.75
# 在发送消息时,自动创建服务器不存在的topic,默认创建的队列数defaultTopicQueueNums=4
# 是否允许 Broker 自动创建 Topic,建议线下开启,线上关闭 !!!这里仔细看是 false,false,falseautoCreateTopicEnable=true
# 是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭autoCreateSubscriptionGroup=true
# Broker 对外服务的监听端口listenPort=10911
# 删除文件时间点,默认凌晨4点deleteWhen=04
# 文件保留时间,默认48小时fileReservedTime=120
# commitLog 每个文件的大小默认1GmapedFileSizeCommitLog=1073741824
# ConsumeQueue 每个文件默认存 30W 条,根据业务情况调整mapedFileSizeConsumeQueue=300000
# destroyMapedFileIntervalForcibly=120000# redeleteHangedFileInterval=120000# 检测物理文件磁盘空间diskMaxUsedSpaceRatio=88# 存储路径# storePathRootDir=/home/ztztdata/rocketmq-all-4.1.0-incubating/store# commitLog 存储路径# storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog# 消费队列存储# storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue# 消息索引存储路径# storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index# checkpoint 文件存储路径# storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint# abort 文件存储路径# abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort# 限制的消息大小maxMessageSize=65536
# flushCommitLogLeastPages=4# flushConsumeQueueLeastPages=2# flushCommitLogThoroughInterval=10000# flushConsumeQueueThoroughInterval=60000
# Broker 的角色# - ASYNC_MASTER 异步复制Master# - SYNC_MASTER 同步双写Master# - SLAVEbrokerRole=ASYNC_MASTER
# 刷盘方式# - ASYNC_FLUSH 异步刷盘# - SYNC_FLUSH 同步刷盘flushDiskType=ASYNC_FLUSH
# 发消息线程池数量# sendMessageThreadPoolNums=128# 拉消息线程池数量# pullMessageThreadPoolNums=1283.创建工作负载
创建有状态副本集
DockerHub容器: foxiswho/rocketmq
# 端口http-10909 TCP 10909http-10911 TCP 10911# 环境变量NAMESRV_ADDR "namesrv的DNS":9876JAVA_OPTS -Duser.home=/optJAVA_OPT_EXT -server -Xms256m -Xmx256m -Xmn256m # 如果是线上环境则按需设置4.创建服务
服务: null
# 服务不需要创建安装RocketMQ-Console
1.创建持久卷
不需要挂载
2.创建配置字典
不需要配置字典
3.创建工作负载
创建有状态副本集
DockerHub容器: styletang/rocketmq-console-ng
# 端口http-8080 TCP 8080# 环境变量不需要创建4.创建服务
服务
# 服务http-8080安装Jaeger
1.创建持久卷
不需要持久卷
2.创建配置字典
不需要字典
3.创建工作负载
创建有状态副本集
DockerHub容器: jaegertracing/all-in-one
# 端口tcp-14250 TCP 14250tcp-14268 TCP 14268tcp-16686 TCP 16686udp-5775 UDP 5775tcp-5778 TCP 5778udp-6831 UDP 6831udp-6832 UDP 6832# 环境变量null4.创建服务
服务: Jaeger-nodeport
# 服务http-16686