Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
duc-cnzj committed Mar 24, 2023
1 parent ebb88e3 commit e44e90c
Show file tree
Hide file tree
Showing 11 changed files with 396 additions and 256 deletions.
23 changes: 20 additions & 3 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,30 @@ export default defineConfig({
]
},
{
text: '快速开始',
text: '入门',
items: [
{ text: '安装', link: '/install' },
{ text: '配置', link: '/configure' },
{ text: '快速体验', link: '/quick-start' },
{ text: '让项目跑起来', link: '/run' },
]
},
{
text: '配置',
items: [
{ text: '项目全局配置', link: '/configure' },
{ text: '单独分支配置', link: '/yaml-configure' },
{ text: 'annotations', link: '/annotations' },
{ text: '环境变量', link: '/env' },
]
},
{
text: '可用插件',
items: [
{ text: 'git 仓库', link: '/gitserver' },
{ text: '域名', link: '/domain' },
{ text: '登录页背景图', link: '/picture' },
{ text: 'Websocket', link: '/ws' },
]
},
{
text: 'SDK 接入',
items: [
Expand Down
11 changes: 11 additions & 0 deletions docs/annotations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: 注解
lang: zh-cn
---

# Pod 可用注解

| name | 类型 | 介绍 |
| ----------------------------------------- | ------------------------ | ----------------------- |
| mars.duc-cnzj.github.io/ignore-containers | string "istio-proxy,app" | 过滤 sidecar 这样的容器 |
| mars.duc-cnzj.github.io/order-index | string "10" | 数值高的在前面 |
106 changes: 1 addition & 105 deletions docs/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,108 +24,4 @@ lang: zh-cn

配好 charts 后保存,会自动加载默认 `values.yaml` 文件,这个只是给你参考用的,然后按照提示配置玩其他字段,其中 `values.yaml` , 有内置变量可以使用,配置完后大概长下面这样

![配置完其他字段](./images/config4.png)

## 按分支单独配置

用法借鉴 `.gitlab.yml`, 使用时只需要在项目下面创建一个 `.mars.yaml` 就可以了。

`.mars.yaml` 配置参考:

```yaml
# 项目默认的配置文件(可选)
config_file: config.yaml
# 默认配置, 必须用 '|', 全局配置文件,如果没有设置 config_file 则使用这个
config_file_values: |
env: dev
port: 8000
# 配置文件的类型(如果有config_file,必填)
config_file_type: yaml
# config_field 对应到 helm values.yaml 中的哪个字段(如果有config_file,必填)
# 可以使用 '->' 指向下一级, 比如:'config->app_name', 会变成
# config:
# app_name: xxxx
config_field: conf
# charts 文件在项目中存放的目录(必填), 也可以是别的项目的文件,格式为 "pid|branch|path"
local_chart_path: charts
# 是不是单字段的配置(如果有config_file,必填)
is_simple_env: false
# 若配置则只会显示配置的分支, 默认 "*"(可选)
branches: - dev
- master
# values_yaml 和 helm 的 values.yaml 用法一模一样,但是可以使用变量
# 目前支持的变量有,使用 `<>` 作为 Delim,避免和内置模板语法冲突
# `<.ImagePullSecrets>` `<.Branch>` `<.Commit>` `<.Pipeline>` `<.ClusterIssuer>`
# `<.Host1>...<.Host10>` `<.TlsSecret1>...<.TlsSecret10>`
values_yaml: |
# Default values for charts.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: xxx
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "<.Branch>-<.Pipeline>"
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
ingress:
enabled: false
className: ""
annotations:
kubernetes.io/ingress.class: nginx
kubernetes.io/tls-acme: "true"
cert-manager.io/cluster-issuer: "<.ClusterIssuer>"
hosts:
- host: <.Host1>
paths:
- path: /
pathType: Prefix
tls:
- secretName: <.TlsSecret1>
hosts:
- <.Host1>
```


### 📒 `is_simple_env`, `config_file` 解释

::: tip
使用全局配置无需关注这个
:::

这是一份普通的 helm charts values.yaml 文件

```yaml
# Default values for charts.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image: repository: nginx
pullPolicy: IfNotPresent
tag: ""

# ... 省略

# 你的 app 的 config 配置应该是这样的, 这个 `conf` 字段会被你用到其他地方比如 configmap、secret 等等
# 下面这个你的 is_simple_env 应该是 false,因为他们都是单独的变量
# config_file 字段的值是 `conf`
conf: APP_PORT: 8080
DB_HOST: mysql
DB_PORT: 3306
#...

# 下面这个你的 is_simple_env 应该是 true,因为这部分配置是一个整体, config_file 字段的值是 `conf_two`
conf_two: |
APP_PORT: 8080
DB_HOST: mysql
DB_PORT: 3306
```

![配置完其他字段](./images/config4.png)
45 changes: 45 additions & 0 deletions docs/domain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: ingress 域名插件
lang: zh-cn
---

# ingress 域名插件

## 同步指定 namespace secret(推荐)

```yaml
domain_manager_plugin:
name: sync_secret_domain_manager
args:
wildcard_domain: "*.mars.local"
secret_name: ""
secret_namespace: ""
```

## 手动配置注入证书

```yaml
domain_manager_plugin:
name: manual_domain_manager
args:
wildcard_domain: "*.mars.local"
tls_key: ""
tls_crt: ""
```

## cert-manager issue 插件(不推荐)

```yaml
domain_manager_plugin:
name: cert-manager_domain_manager
args:
wildcard_domain: "*.mars.local"
cluster_issuer: "letsencrypt-mars"
```

## default_domain_manager (fake domain)

```yaml
domain_manager_plugin:
name: default_domain_manager
```
39 changes: 39 additions & 0 deletions docs/env.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: 环境变量
lang: zh-cn
---

# 环境变量


| 变量名称 | 介绍 |
| ------------------- | ------------------------------------ |
| <.Branch> | 分支名称,动态: dev/master... |
| <.Commit> | commit sha, 6位 |
| <.Pipeline> | gitlab 流水线id, github 目前获取不到 |
| <.ClusterIssuer> | Cert-manager 的issuer |
| <.Host1-10> | 域名 |
| <.TlsSecret1-10> | 域名对应的secret |
| <.ImagePullSecrets> | 拉取镜像的秘钥 |



```yaml
imagePullSecrets: <.ImagePullSecrets>
image:
tag: "<.Branch>-<.Pipeline>"

ingress:
enabled: false
annotations:
cert-manager.io/cluster-issuer: <.ClusterIssuer>
hosts:
- host: <.Host1>
paths:
- path: /
pathType: Prefix
tls:
- secretName: <.Secret1>
hosts:
- <.Host1>
```
27 changes: 27 additions & 0 deletions docs/gitserver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: Git 仓库
lang: zh-cn
---

# Git 仓库

## gitlab(推荐)

```yaml
git_server_plugin:
name: gitlab
args:
token: ""
baseurl: "https://gitlab.com/api/v4"
```

## github

> github 接口不太好用,集成较差,无法使用 `pipeline` 变量
```yaml
git_server_plugin:
name: github
args:
token: ""
```

0 comments on commit e44e90c

Please sign in to comment.