安装KubeSphere

发布于 2024-06-14  96 次阅读


目标:安装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 docker

2.安装KubeSphere

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-system

pod节点被污染错误可以通过下面的修改

# 修改错误的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 nodes
NAME             STATUS   ROLES                         AGE   VERSION
vm-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=FALSE
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'

3.创建工作负载

创建有状态副本集

DockerHub容器: mysql:5.7

# 端口
tcp-3306
tcp-33060
# 环境变量
MYSQL_ROOT_PASSWORD="youpassword"

4.创建服务

服务: mysql-nodeport

# 服务
http-3306

安装Redis

1.创建持久卷

创建redis-pvc持久卷

挂载目录:/data

2.创建配置字典

创建配置字典redis-config

键名:redis.conf

挂载目录:/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.rdb

3.创建工作负载

创建有状态副本集

DockerHub容器: redis:latest

# 端口
http-6379
# 环境变量
null

4.创建服务

服务: redis-nodeport

# 服务
http-6379

安装Consul

1.创建持久卷

不需要持久卷

2.创建配置字典

不需要字典

3.创建工作负载

创建有状态副本集

DockerHub容器: consul:latest

# 端口
tcp-8300	TCP	8300
tcp-8301	TCP	8301
udp-8301	UDP	8301
tcp-8302	TCP	8302
udp-8302	UDP	8302
tcp-8500	TCP	8500
tcp-8600	TCP	8600
udp-8600	UDP	8600
# 环境变量
null

4.创建服务

服务: consul-nodeport

# 服务
http-8500

安装Nacos

1.创建持久卷

不需要持久卷

2.创建配置字典

不需要配置字典

3.创建工作负载

创建有状态副本集

DockerHub容器: nacos/nacos-server:latest

# 端口
http-8848	TCP	8848
# 环境变量
MYSQL_SERVICE_HOST mysql-w8ws.go-rs // mysql服务的DNS
MYSQL_SERVICE_PORT 3306
MYSQL_SERVICE_DB_NAME nacos-data
MYSQL_SERVICE_USER root
MYSQL_SERVICE_PASSWORD ******
MODE standalone
JVM_XMS 512m
JVM_XMX 512m
JVM_XMN 256m

4.创建服务

服务: nacos-nodeport

# 服务
http-8848

安装Elasticsearch

1.创建持久卷

创建es-pvc持久卷

挂载目录:/elasticsearch/data

2.创建配置字典

创建配置字典es-config

键名:elasticsearch.yml

挂载目录:/elasticsearch/config/elasticsearch.yml

# config
http.host: 0.0.0.0
xpack.security.enabled: false

3.创建工作负载

创建有状态副本集

DockerHub容器: elasticsearch:8.12.2

# 端口
http-9200	TCP	9200
http-9300	TCP	9300
# 环境变量
discovery.type single-node
ES_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的DNS

4.创建服务

服务: kibana-nodeport

# 服务
http-5601

安装RocketMQ-Namesrv

1.创建持久卷

创建rocketmq-pvc持久卷(broker共用同一个)

挂载目录:/opt/store

2.创建配置字典

不需要配置字典

3.创建工作负载

创建有状态副本集

DockerHub容器: foxiswho/rocketmq:server

# 端口
http-9876	TCP	9876
# 环境变量
不需要创建

4.创建服务

服务: null

# 服务
不需要创建

安装RocketMQ-Broker

1.创建持久卷

创建rocketmq-pvc持久卷(broker共用同一个)

挂载目录:/opt/store

2.创建配置字典

创建配置字典rocketmq-config

键名:broker.conf

挂载目录:/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-b
brokerName=broker-a

# 0 表示 Master,> 0 表示 Slave
brokerId=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,false
autoCreateTopicEnable=true

# 是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true

# Broker 对外服务的监听端口
listenPort=10911

# 删除文件时间点,默认凌晨4点
deleteWhen=04

# 文件保留时间,默认48小时
fileReservedTime=120

# commitLog 每个文件的大小默认1G
mapedFileSizeCommitLog=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
# - SLAVE
brokerRole=ASYNC_MASTER

# 刷盘方式
# - ASYNC_FLUSH 异步刷盘
# - SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH

# 发消息线程池数量
# sendMessageThreadPoolNums=128
# 拉消息线程池数量
# pullMessageThreadPoolNums=128

3.创建工作负载

创建有状态副本集

DockerHub容器: foxiswho/rocketmq:broker

# 端口
http-10909	TCP	10909
http-10911	TCP	10911
# 环境变量
NAMESRV_ADDR  "namesrv的DNS":9876
JAVA_OPTS -Duser.home=/opt
JAVA_OPT_EXT -server -Xms256m -Xmx256m -Xmn256m # 如果是线上环境则按需设置

4.创建服务

服务: null

# 服务
不需要创建

安装RocketMQ-Console

1.创建持久卷

不需要挂载

2.创建配置字典

不需要配置字典

3.创建工作负载

创建有状态副本集

DockerHub容器: styletang/rocketmq-console-ng

# 端口
http-8080	TCP	8080
# 环境变量
不需要创建

4.创建服务

服务:rocketmq-console-nodeport

# 服务
http-8080

安装Jaeger

1.创建持久卷

不需要持久卷

2.创建配置字典

不需要字典

3.创建工作负载

创建有状态副本集

DockerHub容器: jaegertracing/all-in-one

# 端口
tcp-14250	TCP	14250
tcp-14268	TCP	14268
tcp-16686	TCP	16686
udp-5775	UDP	5775
tcp-5778	TCP	5778
udp-6831	UDP	6831
udp-6832	UDP	6832
# 环境变量
null

4.创建服务

服务: Jaeger-nodeport

# 服务
http-16686

届ける言葉を今は育ててる
最后更新于 2024-06-24