KubeSphere を使い始めるとクラッシュする

KubeSphereは、 Kubernetes上に構築されたアプリケーション中心のエンタープライズレベルの分散コンテナ プラットフォームです。使いやすい操作インターフェイスとウィザード スタイルの操作モードを提供します。ユーザーがコンテナ スケジューリング プラットフォームを使用するための学習コストを削減しながら、開発が大幅に容易になります。テスト、運用、メンテナンスの日常作業の複雑さは、ストレージ、ネットワーク、セキュリティ、Kubernetes 自体の使いやすさの問題点を解決することを目的としています。さらに、このプラットフォームは、コンテナーのシナリオに適した多数の機能モジュールを統合および最適化しており、企業がアジャイル開発と自動化された運用と保守、DevOps、マイクロサービス ガバナンス、グレースケール リリース、およびマルチテナント管理に簡単に対処できるようにする完全なソリューションを備えています。 、ワークロードとクラスターの管理、監視とアラーム、ログのクエリと収集、サービスとネットワーク、アプリケーション ストア、ミラー構築とミラー ウェアハウス管理、ストレージ管理、その他のビジネス シナリオ後続のバージョンでは、マルチクラスター管理、ビッグ データ、人工知能など、より複雑なビジネス シナリオも提供およびサポートされる予定です。
KubeSphere は、プロジェクトの初期段階から、プロジェクトの健全な開発にオープン ソースアプローチを採用しており、関連するプロジェクトのソース コードとドキュメントはすべてGitHubで公開されています。KubeSphere は、パブリック クラウド、プライベート クラウド、VM、BM、Kubernetes を含むあらゆるインフラストラクチャでの展開と運用をサポートし、オンラインおよびオフラインのインストールをサポートしています。現在、Alibaba Cloud、Tencent Cloud、Huawei Cloud、Qingyun、AWS、および Kubernetes の展開で利用可能です。テストが実行されました。
##画像.png

1. システムユーザーマップ

画像.png

2. ミドルウェアの導入

アプリケーション配備で注意すべき情報 【アプリケーション配備の3要素】
1. アプリケーション配備方法
2. アプリケーションデータのマウント(データ、設定ファイル)
3. アプリケーションのアクセシビリティ
画像.png

1. MySQL をデプロイする

1.mysqlコンテナを起動します。

docker run -p 3306:3306 --name mysql-01 \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql/conf.d \
-e MYSQL_ROOT_PASSWORD=ecJVNdEjcFuZY48E \
--restart=always \
-d mysql:5.7 

2. MySQLの設定例

[client]
default-character-set=utf8mb4
 
[mysql]
default-character-set=utf8mb4
 
[mysqld]
init_connect='SET collation_connection = utf8mb4_unicode_ci'
init_connect='SET NAMES utf8mb4'
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
skip-character-set-client-handshake
lower_case_table_names=1
skip-name-resolve

3. MySQL デプロイメント分析

画像.png

4.独自の導入方法

4.0 mysql設定ファイルの作成
画像.png
画像.png

4.1. サービス - 作成 - ステートフルサーバー

画像.png

4.2. ステートフルサーバー名 his-mysql-01 を作成する

画像.png

4.3. 鏡像の追加

画像.png

4.4、ミラー mysql:5.7 を追加、デフォルトのポートを使用

画像.png

4.5. 環境変数を追加し、ホストのタイムゾーンを同期し、チェックマークを選択して次のステップに進みます

画像.png

4.6. 永続ボリュームステートメントテンプレートの追加

画像.png

4.7. 設定辞書の追加

画像.png

4.8. ストレージと構成が追加されます - 「次へ」をクリックします

画像.png

4.9. 「作成」ボタンをクリックします。

画像.png

5.0. 外部アクセス NodePort の作成

画像.png

名前を作成する
画像.png

指定されたワークロード
画像.png

ポートの追加
画像.png

ノードポートの選択
画像.png

6.0、mysql 接続のテスト

his-mysql-01サービス DNSを表示する
画像.png
画像.png

1. クラスター内で、アプリケーションの [サービス名.プロジェクト名] を介して
mysql -uroot -hhis-mysql-01.his -pに直接アクセスします。

[root@k8s-master01 nfs_dir]# kubectl -n his exec -it his-mysql-01-v1-0 bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
root@his-mysql-v1-0:/# mysql -uroot -hhis-mysql-01.his -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.36 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

2. クラスターの外側では、
画像.png

6.1、mysql ログインに失敗しました


[root@k8s-master01 ~]# kubectl -n his get po
NAME                READY   STATUS    RESTARTS        AGE
his-mysql-01-v1-0   1/1     Running   1 (8m58s ago)   9m29s
[root@k8s-master01 ~]# 
#登入pod
[root@k8s-master01 ~]# kubectl -n his exec -it his-mysql-01-v1-0 bash

root@his-mysql-01-v1-0:/# mysql -u root -p

mysql> use mysql;

--修改root秘密
mysql> update user set authentication_string=passworD("ecJVNdEjcFuZY48E") where user='root';


--查看用户登入权限
mysql> SELECT HOST,USER from user;

--修改登入授权
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'ecJVNdEjcFuZY48E' WITH GRANT OPTION;

mysql> FLUSH PRIVILEGES;

mysql> exit

root@his-mysql-01-v1-0:/# exit


#登入pod
[root@k8s-master01 ~]# kubectl -n his exec -it his-mysql-01-v1-0 bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
root@his-mysql-01-v1-0:/# 

#内部pod登入测试
root@his-mysql-01-v1-0:/# mysql -uroot -hhis-mysql-01.his -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.7.36 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 


2. Redis のデプロイ

1. Redisコンテナが起動します

#创建配置文件
## 1、准备redis配置文件内容
mkdir -p /mydata/redis/conf && vim /mydata/redis/conf/redis.conf


##配置示例
appendonly yes
port 6379
bind 0.0.0.0


#docker启动redis
docker run -d -p 6379:6379 --restart=always \
-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \
-v  /mydata/redis-01/data:/data \
 --name redis-01 redis:6.2.5 \
 redis-server /etc/redis/redis.conf

2. Redis デプロイメント分析

画像.png

インターフェイスの作成起動コマンドが追加されました
画像.png

画像.png

3. エラスティック検索を導入する

1.esコンテナが起動します

# 创建数据目录
mkdir -p /mydata/es-01 && chmod 777 -R /mydata/es-01

# 容器启动
docker run --restart=always -d -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms512m -Xmx512m" \
-v es-config:/usr/share/elasticsearch/config \
-v /mydata/es-01/data:/usr/share/elasticsearch/data \
--name es-01 \
elasticsearch:7.13.4

2. ES導入分析

画像.png

注: サブパス マウントでは、構成が変更された後、k8s は Pod 内の関連する構成ファイルをホット アップデートしないため、Pod を自分で再起動する必要があります。

[root@075a91de5863 config]# cat elasticsearch.yml

cluster.name: "docker-cluster"
network.host: 0.0.0.0

[root@075a91de5863 config]# cat jvm.options

################################################################
##
## JVM configuration
##
################################################################
##
## WARNING: DO NOT EDIT THIS FILE. If you want to override the
## JVM options in this file, or set any additional options, you
## should create one or more files in the jvm.options.d
## directory containing your adjustments.
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/jvm-options.html
## for more information.
##
################################################################



################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required, it should be done through a file in jvm.options.d,
## and the min and max should be set to the same value. For
## example, to set the heap to 4 GB, create a new file in the
## jvm.options.d directory containing these lines:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################


################################################################
## Expert settings
################################################################
##
## All settings below here are considered expert settings. Do
## not adjust them unless you understand what you are doing. Do
## not edit them in this file; instead, create a new file in the
## jvm.options.d directory containing your adjustments.
##
################################################################

## GC configuration
8-13:-XX:+UseConcMarkSweepGC
8-13:-XX:CMSInitiatingOccupancyFraction=75
8-13:-XX:+UseCMSInitiatingOccupancyOnly

## G1GC Configuration
# NOTE: G1 GC is only supported on JDK version 10 or later
# to use G1GC, uncomment the next two lines and update the version on the
# following three lines to your version of the JDK
# 10-13:-XX:-UseConcMarkSweepGC
# 10-13:-XX:-UseCMSInitiatingOccupancyOnly
14-:-XX:+UseG1GC

## JVM temporary directory
-Djava.io.tmpdir=${ES_TMPDIR}

## heap dumps

# generate a heap dump when an allocation from the Java heap fails; heap dumps
# are created in the working directory of the JVM unless an alternative path is
# specified
-XX:+HeapDumpOnOutOfMemoryError

# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
-XX:HeapDumpPath=data

# specify an alternative path for JVM fatal error logs
-XX:ErrorFile=logs/hs_err_pid%p.log

## JDK 8 GC logging
8:-XX:+PrintGCDetails
8:-XX:+PrintGCDateStamps
8:-XX:+PrintTenuringDistribution
8:-XX:+PrintGCApplicationStoppedTime
8:-Xloggc:logs/gc.log
8:-XX:+UseGCLogFileRotation
8:-XX:NumberOfGCLogFiles=32
8:-XX:GCLogFileSize=64m

# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m

3. 環境変数を追加する

画像.png

4. サブパスの個々のサブファイルを追加します (jvm.options および elasticsearch.yml)。

/usr/share/elasticsearch/config/elasticsearch.yml
画像.png

画像.png

/usr/share/elasticsearch/config/jvm.options
画像.png

画像.png

4. アプリストア

dev-zhao でログインし、アプリストアからデプロイできます

5. アプリケーションウェアハウス

エンタープライズ スペース管理者 (wuhan-boss) を使用してログインし、アプリケーション ウェアハウスをセットアップして
Helm を学習し、helm のアプリケーション マーケットに移動してウェアハウス アドレスを追加します (例: bitnami)。

charts.bitnami.com/bitnami

画像.png

画像.png

3. DevOps の開始

1. Maven セット Alibaba Cloud

画像.png
構成辞書 - ks-devops-agent-edit 構成 - MavenSetting (以下に追加)

<mirror>
    <id>nexus-aliyun</id>
    <mirrorOf>central</mirrorOf>
    <name>Nexus aliyun</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

2. DevOps プロジェクトを作成する

2.1 プラットフォーム管理 - アクセス制御 - エンタープライズ スペース - 深セン - DevOps プロジェクト - 作成

画像.png

2.2 パイプラインの作成 - 次のステップ - 作成

画像.png

2.3 パイプラインの編集 - テンプレートの選択 (CI/CD を選択) - 次のステップ - 作成 - OK

画像.png

2.4 パイプラインの予備建設

画像.png

継続的に更新中...

参考サイト:
【クラウドネイティブJavaアーキテクトのはじめてのレッスン K8s+Docker+KubeSphere+DevOps】https://www.bilibili.com/video/BV13Q4y1C7hS?p=85&vd_source=2d34fd2352ae451c4f6d4cb20707e169

おすすめ

転載: blog.csdn.net/qq_35583325/article/details/131999462