first commit

This commit is contained in:
huanqing.shao
2019-07-25 00:47:21 +08:00
commit 97d19726a4
198 changed files with 13768 additions and 0 deletions

124
docs/.vuepress/config.js Normal file
View File

@ -0,0 +1,124 @@
module.exports = {
title: 'Kuboard',
description: 'A cool Kubernetes Dashboard',
markdown: {
toc: { includeLevel: [2, 3] }
},
themeConfig: {
nav: [
{ text: '首页', link: '/overview/' },
{ text: '安装', link: '/install/' },
{ text: '使用', link: '/guide/' },
{ text: '支持', link: '/support/' },
],
displayAllHeaders: false,
sidebarDepth: 2,
serviceWorker: {
updatePopup: true
},
sidebar: {
'/overview/': [
['', '简介'],
['why-kuboard', '为什么选择 Kuboard'],
['concepts', '如何降低K8S学习门槛']
],
'/install/': [
'',
'install-k8s',
'install-kubernetes',
'install-dashboard'
// {
// title: '概述',
// collapsable: false,
// children: [
// ['', '概述']
// ]
// },
// {
// title: '安装 Kubernetes',
// collapsable: false,
// children: [
// ['install-k8s', '安装 Kubernetes 用于测试'],
// ['install-kubernetes', '安装 Kubernetes 高可用'],
// ]
// },
// {
// title: '安装 Kuboard',
// collapsable: false,
// children: [
// ['install-dashboard', '安装 Kuboard'],
// ]
// },
],
'/guide/': [
{
title: '概述',
collapsable: false,
children: [
['', '概述']
]
},
{
title: 'Example',
collapsable: false,
children: [
'example/busybox',
'example/import',
'example/monitor',
]
},
{
title: '集群管理',
collapsable: false,
children: [
'cluster/computing',
'cluster/storage',
'cluster/namespace'
]
},
{
title: '应用管理',
collapsable: false,
children: [
'namespace/workload',
'namespace/secrets',
'namespace/configMap',
'namespace/pvc',
'namespace/adjustion',
'namespace/multi-env'
]
},
{
title: '问题诊断',
collapsable: false,
children: [
'diagonize/events',
'diagonize/logs',
'diagonize/port-forward'
]
},
{
title: '监控套件 alpha',
collapsable: false,
children: [
'monitor/',
'monitor/apis'
]
},
],
'/support/': [
''
],
// // fallback
// '/': [
// ''
// ]
}
}
}

View File

@ -0,0 +1,360 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
namespace: example
name: cloud-eureka
annotations:
k8s.eip.work/workload: cloud-eureka
k8s.eip.work/displayName: 服务注册
k8s.eip.work/service: ClusterIP
k8s.eip.work/ingress: 'true'
labels:
k8s.eip.work/layer: cloud
k8s.eip.work/name: cloud-eureka
spec:
selector:
matchLabels:
k8s.eip.work/layer: cloud
k8s.eip.work/name: cloud-eureka
template:
metadata:
labels:
k8s.eip.work/layer: cloud
k8s.eip.work/name: cloud-eureka
spec:
imagePullSecrets:
- {}
initContainers: []
containers:
- image: 'eipsample/example-cloud-eureka:v1.0.0-alpha.1'
imagePullPolicy: Always
name: cloud-eureka
volumeMounts: []
resources: {}
env:
- name: CLOUD_EUREKA_DEFAULT_ZONE
value: 'http://cloud-eureka-0:9200/eureka'
volumes: []
replicas: 1
volumeClaimTemplates: []
serviceName: cloud-eureka
---
apiVersion: v1
kind: Service
metadata:
namespace: example
name: cloud-eureka
annotations:
k8s.eip.work/workload: cloud-eureka
k8s.eip.work/displayName: 服务注册
labels:
k8s.eip.work/layer: cloud
k8s.eip.work/name: cloud-eureka
spec:
selector:
k8s.eip.work/layer: cloud
k8s.eip.work/name: cloud-eureka
type: ClusterIP
ports:
- port: 9200
targetPort: 9200
protocol: TCP
name: mtfsyi
nodePort: 0
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
namespace: example
name: cloud-eureka
annotations:
k8s.eip.work/workload: cloud-eureka
k8s.eip.work/displayName: 服务注册
labels:
k8s.eip.work/layer: cloud
k8s.eip.work/name: cloud-eureka
spec:
rules:
- host: cloud-eureka.example.demo.eip.work
http:
paths:
- path: /
backend:
serviceName: cloud-eureka
servicePort: mtfsyi
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: example
name: db-example
annotations:
k8s.eip.work/workload: db-example
k8s.eip.work/displayName: db-example
k8s.eip.work/service: ClusterIP
k8s.eip.work/ingress: 'false'
labels:
k8s.eip.work/layer: db
k8s.eip.work/name: db-example
spec:
selector:
matchLabels:
k8s.eip.work/layer: db
k8s.eip.work/name: db-example
template:
metadata:
labels:
k8s.eip.work/layer: db
k8s.eip.work/name: db-example
spec:
imagePullSecrets:
- {}
initContainers: []
containers:
- image: 'eipsample/example-db-example:v1.0.0-alpha.1'
imagePullPolicy: Always
name: db-example
volumeMounts:
- name: db-example-storage
mountPath: /var/lib/mysql
subPath: mysql
resources: {}
env:
- name: MYSQL_ROOT_PASSWORD
value: 'soqjdke4#es'
volumes:
- name: db-example-storage
persistentVolumeClaim:
claimName: db-example-storage
replicas: 1
---
apiVersion: v1
kind: Service
metadata:
namespace: example
name: db-example
annotations:
k8s.eip.work/workload: db-example
k8s.eip.work/displayName: db-example
labels:
k8s.eip.work/layer: db
k8s.eip.work/name: db-example
spec:
selector:
k8s.eip.work/layer: db
k8s.eip.work/name: db-example
type: ClusterIP
ports:
- port: 3306
targetPort: 3306
protocol: TCP
name: fp6ksw
nodePort: 0
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: example
name: gateway-example
annotations:
k8s.eip.work/workload: gateway-example
k8s.eip.work/displayName: gateway-example
k8s.eip.work/service: ClusterIP
k8s.eip.work/ingress: 'false'
labels:
k8s.eip.work/layer: gateway
k8s.eip.work/name: gateway-example
spec:
selector:
matchLabels:
k8s.eip.work/layer: gateway
k8s.eip.work/name: gateway-example
template:
metadata:
labels:
k8s.eip.work/layer: gateway
k8s.eip.work/name: gateway-example
spec:
imagePullSecrets:
- {}
initContainers: []
containers:
- image: 'eipsample/example-gateway-example:v1.0.0-alpha.1'
imagePullPolicy: Always
name: gateway-example
volumeMounts: []
resources: {}
env:
- name: CLOUD_EUREKA_DEFAULT_ZONE
value: 'http://cloud-eureka:9200/eureka'
- name: SPRING_PROFILES_ACTIVE
value: example
volumes: []
replicas: 1
---
apiVersion: v1
kind: Service
metadata:
namespace: example
name: gateway-example
annotations:
k8s.eip.work/workload: gateway-example
k8s.eip.work/displayName: gateway-example
labels:
k8s.eip.work/layer: gateway
k8s.eip.work/name: gateway-example
spec:
selector:
k8s.eip.work/layer: gateway
k8s.eip.work/name: gateway-example
type: ClusterIP
ports:
- port: 9201
targetPort: 9201
protocol: TCP
name: pdmd3y
nodePort: 0
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: example
name: svc-example
annotations:
k8s.eip.work/workload: svc-example
k8s.eip.work/displayName: svc-example
k8s.eip.work/service: none
k8s.eip.work/ingress: 'false'
labels:
k8s.eip.work/layer: svc
k8s.eip.work/name: svc-example
spec:
selector:
matchLabels:
k8s.eip.work/layer: svc
k8s.eip.work/name: svc-example
template:
metadata:
labels:
k8s.eip.work/layer: svc
k8s.eip.work/name: svc-example
spec:
imagePullSecrets:
- {}
initContainers: []
containers:
- image: 'eipsample/example-svc-example:v1.0.0-alpha.1'
imagePullPolicy: Always
name: svc-example
volumeMounts: []
resources: {}
env:
- name: CLOUD_EUREKA_DEFAULT_ZONE
value: 'http://cloud-eureka:9200/eureka'
- name: DB_EXAMPLE_URL
value: >-
jdbc:mysql://db-example:3306/eip_db_example?characterEncoding=utf8&useSSL=false
- name: DB_EXAMPLE_USERNAME
value: eip_user
- name: DB_EXAMPLE_PASSWORD
value: 1qaz2wsx
- name: snowflake.dataCenterId
value: '1'
- name: csp.sentinel.dashboard.server
value: monitor-sentinel
volumes: []
replicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: example
name: web-example
annotations:
k8s.eip.work/workload: web-example
k8s.eip.work/displayName: web-example
k8s.eip.work/service: ClusterIP
k8s.eip.work/ingress: 'true'
labels:
k8s.eip.work/layer: web
k8s.eip.work/name: web-example
spec:
selector:
matchLabels:
k8s.eip.work/layer: web
k8s.eip.work/name: web-example
template:
metadata:
labels:
k8s.eip.work/layer: web
k8s.eip.work/name: web-example
spec:
imagePullSecrets:
- {}
initContainers: []
containers:
- image: 'eipsample/example-web-example:v1.0.0-alpha.1'
imagePullPolicy: Always
name: web-example
volumeMounts: []
resources: {}
env: []
volumes: []
replicas: 1
---
apiVersion: v1
kind: Service
metadata:
namespace: example
name: web-example
annotations:
k8s.eip.work/workload: web-example
k8s.eip.work/displayName: web-example
labels:
k8s.eip.work/layer: web
k8s.eip.work/name: web-example
spec:
selector:
k8s.eip.work/layer: web
k8s.eip.work/name: web-example
type: ClusterIP
ports:
- port: 80
targetPort: 80
protocol: TCP
name: mawfrp
nodePort: 0
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
namespace: example
name: web-example
annotations:
k8s.eip.work/workload: web-example
k8s.eip.work/displayName: we-example
labels:
k8s.eip.work/layer: web
k8s.eip.work/name: web-example
spec:
rules:
- host: web-example.example.demo.eip.work
http:
paths:
- path: /
backend:
serviceName: web-example
servicePort: mawfrp

27
docs/guide/README.md Normal file
View File

@ -0,0 +1,27 @@
# 使用手册
**Kuboard 的设计目标**
* 降低 Kubernetes 学习门槛,让初学者先把 Kubernetes 用起来,再逐步理解 Kubernetes 中的各种概念
* 提高 Kubernetes 运维的便捷性,让资深 Kubernetes 运维人员脱离 kubectl 命令行,直接在 Kuboard 界面中完成日常运维工作
**熟悉 Kuboard 的最佳途径**
* 创建一个最简单的工作负载
[创建 busybox](example/busybox)
* 导入一套最简单的 Spring Cloud 微服务工作负载
[导入 example](example/import)
* 根据微服务上下文查看监控结果
[在微服务上下文中监控 example](example/monitor)
**Kuboard 可用于**
* 管理 Kubernetes 集群
* 管理部署于 Kubernetes 的微服务
* 诊断集群中的问题
* 监控部署于 Kubernetes 的微服务

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

View File

@ -0,0 +1,48 @@
# 计算资源管理
## 前提
必须具备如下条件:
* Kubernetes 集群
* 已在集群中安装 Kuboard
## 添加节点
集群完成安装后,可以随时向集群中添加计算节点,请参考 [初始化 worker 节点](/install/install-k8s.html#初始化-worker节点)
## 查看节点
登录 Kuboard 之后,即可看到集群中的计算资源列表,在左下角,如下图所示:
![image-20190720224950653](./computing.assets/image-20190720224950653.png)
* 点击 ***demo-worker002*** 可查看该节点的详细信息,如下图所示:
![image-20190720225123111](./computing.assets/image-20190720225123111.png)
## 移除节点
* 点击 ***节点*** 详情页上方的 ***删除***
并确认要删除的节点的名称后,即可删除该节点
![image-20190720225222622](./computing.assets/image-20190720225222622.png)
> * 此时只是从 kubenetes 集群的配置中删除了该节点,该节点上的工作负载将被自动迁移到其他可用节点上。如果重启该节点对应的 linux 操作系统,该节点会重新注册到集群中来。
>
> * 要想彻底删除该节点,您还需要登录该节点所在机器的 linux 终端,并以 root 身份执行如下命令
>
> ```bash
> kubadm reset
> ```
>
>

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

View File

@ -0,0 +1,51 @@
# 名称空间管理
## 创建名称空间
### 前提
必须具备如下条件:
* Kubernetes 集群
* 已在集群中安装 Kuboard
* 已进入 Kuboard 操作界面 [安装并进入 Kuboard](/install/install-dashboard)
假设您已经进入了 Kuboard 界面,如下图所示:
![image-20190723105606081](./namespace-create.assets/image-20190723105606081.png)
### 准备
* 点击 ***创建*** 按钮,创建名称空间
并填写:
| 字段名称 | 填写内容 | 说明 |
| -------- | -------- | ---------------------------- |
| 名称 | example | Kubernetes 的 namespace 名称 |
![image-20190723105644937](./namespace-create.assets/image-20190723105644937.png)
* 点击 ***保存***
![image-20190723105722999](./namespace-create.assets/image-20190723105722999.png)
* 点击 ***应用***
![image-20190723105748435](./namespace-create.assets/image-20190723105748435.png)
* 点击 ***完成***
此时可在名称空间列表中查看到刚刚创建好的名称空间 *example*
![image-20190723105809872](./namespace-create.assets/image-20190723105809872.png)
* 点击 *example* 名称空间
点击 *example* 名称空间后,可进入该名称空间的页面。刚刚初始化的名称空间的界面布局如下图所示:
![image-20190723105830318](./namespace-create.assets/image-20190723105830318.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

View File

@ -0,0 +1,137 @@
# 存储空间管理
## 创建存储类
前提
必须具备如下条件:
* Kubernetes 集群 (安装在阿里云,本文将使用阿里云的 NFS 服务作为存储资源Kuboard 也可以运行在其他云环境或者私有环境中。)
* 已在集群中安装 Kuboard
### 在阿里云创建 NAS 服务
如果您在其他 IaaS 供应商搭建了 Kubernetes 集群,请参考该 IaaS 供应商的文档,创建 NFS 服务。您也可以自行搭建 NFS 服务器,用来为 Kubernetes 集群提供存储资源。
* 进入阿里云 ***文件存储 NAS 服务*** 控制台
登录 www.aliyun.com 后,在控制台界面的产品与服务中选择 ***文件存储 NAS***
如下图所示
![image-20190717113807552](./storage-create.assets/image-20190717113807552.png)
****文件存储 NAS*** 控制台中点击 ***创建文件系统***
![image-20190717114304953](./storage-create.assets/image-20190717114304953.png)
* 填写表单
| 字段名称 | 填写内容 | 说明 |
| -------- | -------------------------------------- | ---------------------------------- |
| 地域 | 请选择您的 Kubernetes 集群所在的地域 | 文件系统所在地域 |
| 存储类型 | 容量型 / 或 SSD型 | 测试目的,使用价格便宜的容量型即可 |
| 协议类型 | NFS | 请选择NFS |
| 可用区 | 请选择您的 Kubernetes 集群所在的可用区 | 文件系统所在可用区 |
| 存储包 | 如果当下没有存储包,可以后续绑定 | 不绑定存储包,将无法使用该文件系统 |
![image-20190717114354610](./storage-create.assets/image-20190717114354610.png)
* 点击 ***确定***
点击确定后,可查看到该文件系统已创建成功
![image-20190717115020848](./storage-create.assets/image-20190717115020848.png)
* 绑定存储包
请自行在阿里云中为该文件系统绑定存储包,如果不绑定存储包,将无法使用该文件系统。
* 点击刚创建文件系统的 ***管理*** 按钮
![image-20190717115403374](./storage-create.assets/image-20190717115403374.png)
* 点击 ***添加挂载点***
并填写表单
| 字段名称 | 填写内容 | 说明 |
| ---------- | -------------------------------------- | -------------- |
| 挂载点类型 | 专有网络 | |
| VPC网络 | 请选择您的 Kubernetes 集群所在的VPC | |
| 交换机 | 请选择您的 Kubernetes 集群所在的交换机 | |
| 权限组 | VPC默认权限组全部允许 | 请选择全部允许 |
![image-20190717115457614](./storage-create.assets/image-20190717115457614.png)
* 点击 ***确定***
点击确定后,将完成挂载点创建,如下图所示:
![image-20190717115829821](./storage-create.assets/image-20190717115829821.png)
* 获取 NFS 连接参数:
在上图界面中,将 ***V4 Mount*** 的指令复制下来后,如下所示:
<div style="font-family: Monaco,Menlo,Consolas,Bitstream Vera Sans Mono,monospace; padding: 20px; background-color: rgb(244, 244, 245);border-radius: 4px;">
sudo mount -t nfs -o vers=4,minorversion=0,noresvport <span style="color: red; background-color: rgb(254, 240, 240);">189344a39c-lex38.cn-beijing.nas.aliyuncs.com</span>:<span style="color: blue; background-color: rgb(217, 236, 255);">/</span> /mnt
</div>
其中红色字体的文字为 NFS Server 的地址,蓝色字体的文字为 NFS Path。如下表所示
| 字段名称 | 字段取值 | 说明 |
| ---------- | -------------------------------------------- | ------------------------------ |
| NFS Server | 189344a39c-lex38.cn-beijing.nas.aliyuncs.com | |
| NFS Path | / | NFS Server和NFS Path以冒号分隔 |
### 在 Kuboard 创建存储类
* 进入 Kuboard ***集群概览页***
参考 [访问 Kuboard](install/install-dashboard?id=访问)
如下图所示:
![image-20190723112105018](./storage-create.assets/image-20190723112105018.png)
* 点击 ***创建存储类***
填写表单
| 字段名称 | 填写内容 | 说明 |
| -------------- | --------------- | ------------------------------------------------------------ |
| 名称 | cluster-storage | 填写你喜欢的名称 |
| 限定名称空间 | 不填写 | 如果限定名称空间,<br />则在 Kuboard 中,您只能在指定的名称空间中使用该存储类<br />在 kubectl 中,不受影响 |
| 存储类型 | NFS | 目前 Kuboard 只支持 NFS将要增加其他类型的存储如 CephFS、Cinder 等 |
| 回收策略 | 回收后删除 | 当该存储类创建的 存储卷Persistent Volume被删除后之前该存储卷中的文件可以被回收后删除 / 回收后保留 |
| 存储卷绑定模式 | 首次使用时绑定 | 即刻绑定:当 存储卷被创建时,就在 NFS 中为其分配空间,并绑定;<br />首次使用时绑定: 在存储卷被第一次使用到时,才绑定 |
![image-20190723112143032](./storage-create.assets/image-20190723112143032.png)
* 点击 ***保存***
![image-20190723112204681](./storage-create.assets/image-20190723112204681.png)
* 点击 ***应用***
![image-20190723113250521](./storage-create.assets/image-20190723113250521.png)
* 点击 ***完成***
此时可在存储资源列表中查看到刚创建的存储类
![image-20190723113312360](./storage-create.assets/image-20190723113312360.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 KiB

View File

@ -0,0 +1,46 @@
# 集群事件
通过观察 KUberetes 集群事件,可以快速诊断部署时发生的问题。
Kuboard 建立了与 kubernetes apiserver 的长连接,可以在第一时间将集群中的事件更新以通知的形式显示在 dashboad 上。
## 错误事件提示
如果存在与某一个工作负载相关的错误事件,名称空间界面中,将以红色显示该工作负载,如下图所示:
![image-20190721104153954](./events.assets/image-20190721104153954.png)
## 全局事件
### 查看全局事件
在任何页面点击界面左上角的 ***事件*** 按钮,进入事件列表页:
![image-20190721101812895](./events.assets/image-20190721101812895.png)
### 删除事件
* 点击全局事件列表中的 ***类型*** 标签,
![image-20190721101954560](./events.assets/image-20190721101954560.png)
* 点击 ***确定***
该事件已删除。如果事件对应的错误原因没有被解决,该事件又会在下一次 kubernetes 调度系统资源的时候重新出现。
## 微服务上下文相关的事件
打开工作负载页面,如下图所示:
容器组信息中包含了与该容器组相关的所有集群事件。
![image-20190721103324863](./events.assets/image-20190721103324863.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 541 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

View File

@ -0,0 +1,35 @@
# 日志及终端
# 日志
通过 Kuboard 可以实时跟踪容器的日志信息。
假设您已经进入 ***工作负载*** 详情页,如下图所示:
![image-20190721104348908](./logs.assets/image-20190721104348908.png)
* 点击容器信息中的 ***日志*** 按钮
可进入日志追踪界面,如下图所示:
![image-20190721104415732](./logs.assets/image-20190721104415732.png)
# 终端
* 点击容器信息中的 ***终端*** 按钮
可进入终端界面,如下图所示:
> * 在终端中,可以执行的 shell 命令取决于该容器预装的命令。许多容器为了精简自身的大小,只保留了最基本的命令。
>
> * 通常会进入终端执行如下诊断操作:
> * export 命令查看容器内的环境变量是否被正确设置
> * ping, curl 命令检查容器内与集群内其他服务,集群外服务的网络连通性
> * vi 命令,临时修改容器内应用程序的配置,并在容器内重启应用程序,以临时性的尝试修复问题,如果有效再将修改更新到应用程序代码或者 Dockerfile
![image-20190721104522870](./logs.assets/image-20190721104522870.png)

View File

@ -0,0 +1,27 @@
# 端口转发
微服务环境中,各个服务都通过 TCP / UDP 端口的形式提供访问。按调用者所在位置、通信协议的形式来划分,大致有如下几种情况:
| 调用者所在位置 | 通信协议 | 临时性 | 常见场景 | 推荐配置方式 |
| -------------- | ------------ | ------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| VPC外 | http / https | 日常性 | 用户从互联网(亦可能是公司内网)<br />访问 web 页面,或者 restful 接口 | Kubernetes Ingress<br />可在Kuboard中直接配置***互联网入口*** |
| VPC外 | tcp / udp | 临时性 | 例如开发者临时需要访问数据库端口、Redis端口等 | 在客户端所在机器配置 kubectl<br /><span style="color: #F56C6C;">通过 kubectl port-forwad 进行端口转发</span> |
| VPC外 | tcp / udp | 日常性 | 暂不讨论 | |
| VPC内/集群外 | http / https | 日常性 | 通过接口网关为周边系统提供服务 | Kubernetes Service NodePort<br />可在Kuboard中直接配置***访问方式/VPC内访问*** |
| VPC内/集群外 | tcp / udp | 同上 | 同上 | |
| 集群内 | http / https | 日常性 | **场景1**Web层访问微服务网关<br />**场景2**:微服务网关调用微服务,微服务之间的互相调用等。 | **场景1**Kubernetes Service ClusterIP <br />可在Kuboard中直接配置 ***访问方式/集群内访问*** <br />**场景2**Spring Cloud中使用Eureka/Consul等服务发现<br />Kuboard中 ***访问方式/不配置*** |
| 集群内 | tcp / udp | 日常性 | 微服务访问数据库、微服务访问Redis等 | Kubernetes Service ClusterIP <br />可在Kuboard中直接配置 ***访问方式/集群内访问*** |
## Feature planned
在作者使用 Kuboard 的运维实践中,有如下两个场景不能脱离 kubeadm / kubectl 命令行:
* 初始化集群 / 向集群添加节点
* 开发者临时需要访问数据库端口、Redis端口时通过 kubectl port-forward 进行端口转发
Kuboard 计划实现类似 kubectl port-forward 的功能,提高问题诊断过程中的便利性。

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

View File

@ -0,0 +1,103 @@
# 部署 busybox
## 前提
必须具备如下条件:
* Kubernetes 集群
* 已在集群中安装 Kuboard
假设您已经进入了 Kuboard 名称空间界面,如下图所示。可参考 [创建名称空间](/guide/cluster/namespace.html#创建名称空间)
![image-20190723115721514](./pre-condition.assets/image-20190723115721514.png)
## 部署 busybox
[查看 busybox 介绍](https://hub.docker.com/_/busybox)
Busybox 是一个非常小巧不到5M的容器此处用它来展示如何将一个 docker image 通过 Kuboard 部署到 kubernetes 集群中。
* 点击 ***创建工作负载按钮***
填写表单如下:
| 字段名称 | 填写内容 | 说明 |
| -------- | ------------ | ------------------------------------------------------------ |
| 服务类型 | Deployment | Kubernetes 的 Deployment 类型 |
| 服务分层 | 中间件 | 生成的Kuberenetes对象以 cloud- 作为前缀,<br />并显示在中间件分层中 |
| 服务名称 | busybox | 显示在 Kuboard 中的名称 |
| 副本数量 | 1 | replicas |
| 容器名称 | busybox | |
| 镜像 | busybox:1.29 | hub.docker.com 中的 busybox 镜像 |
| Command | sleep | |
| Command | 3600 | |
![image-20190723115852719](./busybox.assets/image-20190723115852719.png)
* 完成表单填写后,点击***保存***
Kuboard 将对表单参数进行校验,通过后,方可执行对集群的变更操作。
![image-20190723115912645](./busybox.assets/image-20190723115912645.png)
* 点击***应用***
Kuboard 执行对集群的变更操作,变更的过程中,产生的事件以通知消息的形式显示出来。
![image-20190723115940862](./busybox.assets/image-20190723115940862.png)
## 验证工作负载
* 点击***完成***
点击完成后,可查看工作负载的信息。该界面分成四个区域:
* 页头区
页头区包含对该工作负载(本案例中为 Deployment的操作按钮。可执行的操作有***编辑*** / ***伸缩*** / ***刷新*** / ***删除***
* 工作负载基本信息
基本信息区显示了工作负载的 ***基本信息*** 、***运行时信息***、***访问方式***Service、***互联网入口***Ingress
* 容器组列表
容器组列表区显示了该当前对应的所有容器组Pod容器组列表区监听集群的动态变化当您执行伸缩操作、或者删除容器组操作时无需刷新就可以查看到最新的容器组信息。
* 容器组详情
容器组详情区显示了当前选中容器组的信息,其中包括:
* 容器组相关事件
* 容器组基本信息,及删除容器组的操作按钮。(此区域还包括容器组相关的监控操作,监控模块在后续的章节中介绍)
* 容器基本信息,及查看容器日志、打开容器终端的按钮。(此区域还包括容器相关的监控操作,监控模块在后续的章节中介绍)
![image-20190723120011972](./busybox.assets/image-20190723120011972.png)
* 点击***终端***
此时打开了该容器的控制台Kuboard 默认使用 /bin/bash 终端程序,而 busybox 镜像中并不包含 /bin/bash因此您会看到一个如下图所示的错误提示
![image-20190723120050894](./busybox.assets/image-20190723120050894.png)
* 点击***切换到 /bin/sh***
点击屏幕左上角的 ***切换到 /bin/sh***
![image-20190723120104474](./busybox.assets/image-20190723120104474.png)
* 输入 *export* 并回车
输入 *export* 并回车后,可查看该容器当前的环境变量。您也可以在终端中执行任何容器内部的命令。在您完成容器的部署之后,终端界面是非常有效的问题诊断工具之一。
![image-20190723120125425](./busybox.assets/image-20190723120125425.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View File

@ -0,0 +1,165 @@
# 导入 example 微服务
## 前提
必须具备如下条件:
* Kubernetes 集群 (安装在阿里云,本文将使用阿里云的 NFS 服务作为存储资源Kuboard 也可以运行在其他云环境或者私有环境中。)
* 已在集群中安装 Kuboard
## 创建存储资源
example中用到了存储卷声明请在 Kuboard 中 [创建存储类](/guide/cluster/storage?id=创建存储类) ,否则不能完成 example 的导入操作。
## 创建名称空间
创建新的名称空间,用来导入 exmaple。可参考 [创建名称空间](/guide/cluster/namespace?id=创建名称空间)
假设您已经进入了 Kuboard 名称空间界面,如下图所示:
![image-20190723115721514](./pre-condition.assets/image-20190723115721514.png)
## 导入 example
* 下载 <a :href="$withBase('/kuboard_example.yaml')" download="kuboard_example.yaml">kuboard_example.yaml</a> 文件
> 在 Kuboard 中,您无需手写 yaml 文件,此 yaml 文件的内容生成步骤如下:
> * 通过 [创建工作负载](busybox) 完成微服务应用的部署
> * 通过 **导出工作负载** 将名称空间中的微服务配置导出到一个 yaml 文件中
* 点击 ***导入工作负载*** 按钮
![image-20190723120730196](./import.assets/image-20190723120730196.png)
* 点击 ***上传文件*** 按钮
并选择刚才下载的 export_example.yaml 文件
![image-20190723120753533](./import.assets/image-20190723120753533.png)
* 点击 ***下一步***
默认选择所有的工作负载
![image-20190723120832778](./import.assets/image-20190723120832778.png)
* 点击***下一步***
默认选择所有要导入的配置example中没有使用到配置信息
![image-20190723120912377](./import.assets/image-20190723120912377.png)
* 点击 ***下一步***
默认选择所有 Secrets
![image-20190723120926747](./import.assets/image-20190723120926747.png)
* 点击***下一步***
填写表单:
| 字段名称 | 填写内容 | 说明 |
| ------------------ | ------------------ | ------------------------------------------------------------ |
| 数据卷类型 | db-example-storage | NFS容器组直连NFS<br />存储卷声明:容器组使用存储卷声明 |
| 是否新建存储卷声明 | 创建新存储卷声明 | 使用已有存储卷声明:可以使用事先创建好的存储卷声明<br />创建新存储卷声明:可以创建新存储卷声明 |
| 分配模式 | 动态分配 | |
| 读写模式 | 可被多节点读写 | 只能被单节点读写、可被多节点只读、可被多节点读写 |
| 总量 | 2Gi | 2Gi代表 2G空间 |
![image-20190723120956821](./import.assets/image-20190723120956821.png)
* 点击***下一步***
填写表单:
| 字段名称 | 填写内容 | 说明 |
| ---------------- | ---------------------------------- | ------------------------------------------------------------ |
| cloud-eureka域名 | cloud-eureka.example.demo.eip.work | 使用您自己的域名,<br />在测试环境建议使用如下域名格式:<br />workloadname.namespace-name.cluster-name.domain.com<br />该域名应该解析到您worker节点的外网地址或者worker 节点 80/443 端口对应负载均衡服务器的外网地址。 |
| web-example | web-example.example.demo.eip | |
![image-20190723121019167](./import.assets/image-20190723121019167.png)
* 点击***下一步***
![image-20190723121035917](./import.assets/image-20190723121035917.png)
* 点击 ***确定***
![image-20190723121055648](./import.assets/image-20190723121055648.png)
* 点击 ***应用***
![image-20190723121117514](./import.assets/image-20190723121117514.png)
* 点击 ***完成***
![image-20190723121132991](./import.assets/image-20190723121132991.png)
* 点击 ***已完成***
可再名称空间中查看到刚才导入的 example 的所有工作负载及存储卷声明
![image-20190723121433809](./import.assets/image-20190723121433809.png)
## 验证 web-example
* 点击工作负载 ***web-example***
![image-20190723121412027](./import.assets/image-20190723121412027.png)
* 点击 互联网入口中的域名 ***http://web-example.example.demo.eip.work***
**Example 部署成功**
![image-20190717193548703](./import.assets/image-20190717193548703.png)
> web-example容器的日志中会出现如下异常错误原因是example使用了一个监控套件该监控套件要求将容器注册到monitor-eureka中当下我们并没有安装该监控套件。此错误并不影响 example 程序的使用。暂时忽略该异常。
>
> ```
> [DiscoveryClient-InstanceInfoReplicator-0] WARN com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient - Request execution failed with message: java.net.UnknownHostException: monitor-eureka
> [DiscoveryClient-InstanceInfoReplicator-0] WARN com.netflix.discovery.DiscoveryClient - DiscoveryClient_WEB-ADMIN/web-example-7f668c75db-j7ncx - registration failed Cannot execute request on any known server
> com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
> at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:112)
> at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
> at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59)
> at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)
> at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
> at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:829)
> at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:121)
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
> at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> at java.lang.Thread.run(Thread.java:748)
> [DiscoveryClient-InstanceInfoReplicator-0] WARN com.netflix.discovery.InstanceInfoReplicator - There was a problem with the instance info replicator
> com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
> at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:112)
> at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
> at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59)
> at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)
> at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
> at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:829)
> at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:121)
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
> at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> at java.lang.Thread.run(Thread.java:748)
> ```
>
>

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 KiB

View File

@ -0,0 +1,211 @@
# 监控 example (alpha)
## 前提
必须具备如下条件:
* 已完成 [导入 example 微服务](/guide/example/import)
!> 监控套件相关的功能目前处于 alpha 状态,虽然在实际投产项目中取得了非常好的效果,但是产品化封装还需要进一步改进。
假设您已进入 example 名称空间,如下图所示:
![image-20190723121433809](./import.assets/image-20190723121433809.png)
## 安装监控套件
### 安装全局监控套件
* 在 master 节点执行
```bash
kubectl -n kube-system create secret generic etcd-certs --from-file=/etc/kubernetes/pki/etcd/server.crt --from-file=/etc/kubernetes/pki/etcd/server.key
```
* 将鼠标移到 ***设置*** 菜单
![image-20190723150525017](./monitor.assets/image-20190723150525017.png)
* 点击 ***监控套件 - example***
![image-20190723150616633](./monitor.assets/image-20190723150616633.png)
* 点击 ***全局监控套件 / 查找并安装***
![image-20190723150853277](./monitor.assets/image-20190723150853277.png)
* 点击 ***资源层监控套件 / 安装***
![image-20190723151045112](./monitor.assets/image-20190723151045112.png)
* 点击 ***全局监控套件 / 资源层监控套件 / 安装***
![image-20190723151103353](./monitor.assets/image-20190723151103353.png)
* 根据向导提示,完成工作负载的导入
![image-20190723151339137](./monitor.assets/image-20190723151339137.png)
* 点击 ***资源层监控套件 / 初始化***
由于下载镜像需要时间您可能需要等待5-10分钟后才能成功执行初始化。初始化成功的话您将看到如下提示信息。
![image-20190723151357262](./monitor.assets/image-20190723151357262.png)
### 安装名称空间监控套件
* 点击 ***名称空间监控套件 example / 查找并安装***
![image-20190723151422460](./monitor.assets/image-20190723151422460.png)
* 重复前述过程,安装监控套件
重复前述过程,完成如下监控套件的安装和初始化:
* Pinpoint 监控套件
* Prometheus 监控套件
* 熔断及限流 Sentinel
安装完成后,界面如下图所示:
![image-20190723151711230](./monitor.assets/image-20190723151711230.png)
### 查看监控套件的工作负载
* 点击 ***后退***
回到名称空间后,可查看到刚才安装监控套件时导入的监控层工作负载。
> 全局监控套件安装在 kube-system 名称空间
![image-20190723151804727](./monitor.assets/image-20190723151804727.png)
## 重启 example 容器组
* 点击导航栏中的 ***容器组列表***
在筛选条件中选择
* 展现层
* 网关层
* 服务层
* 持久层
* 中间件
并点击刷新
> * Kuboard 创建工作负载时,默认将其 imagePullPolicy 设置为 **Always**
>
> * 删除容器组时Kubernetes 将为该工作负载启动一个新的容器组以尽可能地使工作负载的容器组数量等于该工作负载期望的副本数replicas
> * Kubernetes 在启动容器组时,根据 imagePullPolicy 的设置 Always将会尝试从镜像仓库抓取最新镜像这一特性可以用于开发环境和测试环境的版本更新因为您的 devops 系统肯能不会为 daily build 生成新的镜像标签;
> * 此处删除容器组的目的是,重新启动容器,以便容器中的监控探针能够检测到其对应监控套件的存在。
![image-20190723151845303](./monitor.assets/image-20190723151845303.png)
* 在列表中选择
选中如下容器组:
* cloud-eureka-0
* db-example-xxxxxx-xxxx
* gateway-example-xxxxxx-xxxx
* svc-example-xxxxxx-xxxx
* web-example-xxxxxx-xxxx
![image-20190723151902003](./monitor.assets/image-20190723151902003.png)
* 点击 ***删除*** 按钮
![image-20190723151914994](./monitor.assets/image-20190723151914994.png)
* 点击 ***确定***
![image-20190723151932871](./monitor.assets/image-20190723151932871.png)
* 点击 ***应用***
![image-20190723151951910](./monitor.assets/image-20190723151951910.png)
* 等待,直到容器组调整完成
![image-20190723152020605](./monitor.assets/image-20190723152020605.png)
* 点击 ***后退***
![image-20190723152040219](./monitor.assets/image-20190723152040219.png)
## 查看监控信息
### 查看资源层监控信息
* 点击 ***展现层 / web-example***
如果您在下图中没有看到 ***Nginx 监控*** ***容器组监控*** 等,请刷新您的页面,因为监控套件初始化之后需要刷新页面才能加载并显示。
![image-20190723152124196](./monitor.assets/image-20190723152124196.png)
* 点击 ***所在节点监控***
可查看所在节点的资源使用情况监控信息
![image-20190718104156232](./monitor.assets/image-20190718104156232.png)
### 查看中间件层监控信息
#### 查看 Nginx 监控
* 点击 Nginx 监控
![image-20190718104729472](./monitor.assets/image-20190718104729472.png)
#### 查看 MySQL 监控
* 返回 ***example*** 名称空间
* 点击 ***持久层 / example db***
* 点击 ***MySQL 监控***
![image-20190718105420599](./monitor.assets/image-20190718105420599.png)
#### 查看 JVM 监控
* 返回 ***example*** 名称空间
* 点击 ***微服务层 / example***
* 点击 ***Java 虚拟机监控***
![image-20190718105641651](./monitor.assets/image-20190718105641651.png)
### 查看链路追踪监控信息
****微服务层 / example*** 中点击 ***链路追踪***
![image-20190718120957255](./monitor.assets/image-20190718120957255.png)
![image-20190718121133160](./monitor.assets/image-20190718121133160.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

View File

@ -0,0 +1,6 @@
# 监控套件
文档建设中...
> * 请参考 [监控 example (alpha)](/guide/example/monitor) 体验 Kuboard 在监控套件方面的设想
> * 监控套件以插件的形式整合到 Kuboard在不使用监控套件的情况下Kuboard 的所有功能都可正常工作

View File

@ -0,0 +1,6 @@
# 自定义监控套件
文档建设中...
> * 请参考 [监控 example (alpha)](/guide/example/monitor) 体验 Kuboard 在监控套件方面的设想
> * 监控套件以插件的形式整合到 Kuboard在不使用监控套件的情况下Kuboard 的所有功能都可正常工作

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Some files were not shown because too many files have changed in this diff Show More