Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete Chart Support #312

Merged
merged 1 commit into from
Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 122 additions & 26 deletions helm/README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,143 @@
# Chart 使用说明
<!-- TOC depthFrom:2 -->
<!--- app-name: bilibili-tool -->

- [1. 前期工作](#1-前期工作)
- [1.1. 环境准备](#11-环境准备)
- [2. 方式:Chart 安装](#2-方式-Chart安装)
- [2.1. 启动](#21-启动)
# BiliBili Tool

<!-- /TOC -->
## 1. 前期工作
BiliBiliTool 是一个自动执行任务的工具,当我们忘记做某项任务时,它会像一个贴心小助手,按照我们预先吩咐它的命令,在指定频率、时间范围内帮助我们完成计划的任务。

### 1.1. 环境准备
[Overview of BiliBili Tool](https://github.com/RayWangQvQ/BiliBiliToolPro)

## TL;DR

请确认已安装了Kubernetes所需环境([Kubernetes](https://kubernetes/kubernetes.io))
### 在集群中通过本地代码直接部署

请确认已具有了健康运行的Kubernetes集群,或者也可以使用kind([kind](https://kind.sigs.k8s.io/))来本地运行
```console
$ git clone https://github.com/RayWangQvQ/BiliBiliToolPro.git
$ cd ${local_code_repo}/helm/bilibili-tool
$ vim values.yaml # provides your cookie and cron
$ helm install <my_release_name> .
```

### 在集群中通过chart部署

```console
$ git clone https://github.com/RayWangQvQ/BiliBiliToolPro.git
$ cd ${local_code_repo}/helm/bilibili-tool
$ helm cm-push . <your_chart_repo>
```
Then on the cluster control plane
```console
$ mkdir /tmp/bilibili-tool && cd /tmp/bilibili-tool
$ helm repo add <your_chart_repo> <your_chart_repo_url>
$ helm update && helm pull <your_chart_repo>/bilibili-tool
$ tar -zvxf <tar> -C . && cd <chart_name>
$ vim values.yaml # provides your cookie and cron
$ helm install <my_release_name> .
```

## Introduction

这个chart通过[Helm](https://helm.sh)在[Kubernetes](https://kubernetes.io)集群上拉起一个[BiliBiliToolPro](https://github.com/RayWangQvQ/BiliBiliToolPro)deployment


## Prerequisites

- Kubernetes
- Helm

或者

请确认已安装了Helm工具([Helm](https://helm.sh/))
- Kind
- Helm

## 2. 方式:Chart 安装
## 安装Chart

### 2.1. 启动
安装Chart并命名为 `my-release`:

```console
$ helm repo add my-repo <my_chart_repo>
$ helm install my-release my-repo/bilibili-tool(:0.2.1)
```
# 进入目录
cd helm

# 修改Chart values文件
上述命令需要用户在values.yaml里提供cookie等必须信息
[Parameters](#parameters) 部分列出了所有可供自定义的值

修改values.yaml,填写env下cookie以及定时触发cron表达式,其他的环境变量设置可以按需设置
> **Tip**: `helm list` 可以列出当前已经列出的所有的release

helm install <your_release_name> .
## 卸载 Chart

如果您想先检查一下生成的资源文件以及是否可以部署在集群中
卸载 `my-release` deployment:

helm install <your_release_name> . --dry-run > workload.yaml
```console
$ helm delete my-release
```

上述命令卸载掉所有的release相关资源

## Parameters

| Name | Description | Value | Required |
| ------------------------- | ----------------------------------------------- | ----- | -------- |
| `replicaCount` | Deployment Relicas Count | `1` | true |
| `image.repository` | Global Dockevr registry | `zai7lou/bilibili_tool_pro` | true |
| `image.tag` | Image Tag | `0.2.1` | true |
| `image.pullPolicy` | Image Pull Policy | `IfNotPresent` | true |
| `imagePullSecrets` | Image Pull Secrets | `[]` | false |
| `nameOverride` | Deployment name in the Chart | `""` | false |
| `fullnameOverride` | Release name when set | `""` | false |
| `resources.limits` | The resources limits for the BiliBili Tool containers | `{}` | true |
| `resources.limits.memory` | The limited memory for the BiliBili Tool containers | `180Mi` | true |
| `resources.limits.cpu` | The limited cpu for the BiliBili Tool containers | `100m` | true |
| `resources.requests` | The resources requests for the BiliBili Tool containers | `{}` | true |
| `resources.requests.memory` | The requested memory for the BiliBili Tool containers | `180Mi` | true |
| `resources.requests.cpu` | The requested cpu for the BiliBili Tool containers | `100m` | true |
| `affinity` | Affinity for pod assignment | `{}` | false |
| `nodeSelector` | Node labels for pod assignment | `{}` | false |
| `tolerations` | Tolerations for pod assignment | `[]` | false |
| `env` | Environment variables for the BiliBili Tool container, Ray_BiliBiliCookies__1 and Ray_DailyTaskConfig__Cron are required, others vars pls take a look at [supported envvars](https://github.com/RayWangQvQ/BiliBiliToolPro/blob/main/docs/configuration.md) | `[]` | true |
| `volumes.enabled` | Enable persistent log volume for BiliBili Tool or not | `"false"` | true |
| `volumes.path` | The host path mounted into pod | `"/tmp/Logs"` | false |
| `volumes.name` | The volume name | `"bili-tool-vol"` | false |
| `podAnnotations` | The annotations for the BiliBili Tool pod | `{}` | false |

可以用指定helm install命令行参数 `--set key=value[,key=value]`, 比如

```console
$ helm install my-release \
--set \
relicas=1
```

也可以通过指定一个YAML格式的values文件来配置以上参数,比如

```console
$ helm install my-release -f values.yaml my_chart_repo/bilibili-tool
```

kubectl apply -f workload.yaml --dry-run=server
> **Tip**: 你可以使用默认的 [values.yaml](bilibili-tool/values.yaml)进行配置

确认无误后

helm install <your_release_name> .
当想更新一些变量时,可以通过指定参数或者直接修改YAML的values文件进行更新

# 查看启动日志
kubectl logs <your-bilibilitool-pod-name> -f
```console
$ helm upgrade my-release my_chart_repo/bilibili-tool <-f values> or <--set-file ...>
```

## [Optional]本地Cluster运行

通过安装[kind](https://kind.sigs.k8s.io/docs/user/quick-start/)工具在本地运行一个Kubernetes Cluster

### Prerequisites

go 1.17+ and Docker installed

```console
$ go install sigs.k8s.io/[email protected] && kind create cluster <--config kind_config_file>
$ cat <kind_config_file>
$ kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
$ EOF
```
at least one worker node otherwise you have to provides tolerations in the values.yaml to schedule on master node
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 10 additions & 15 deletions helm/values.yaml → helm/bilibili-tool/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,24 @@ imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

# For more envs pls take a view at https://github.com/RayWangQvQ/BiliBiliToolPro/blob/main/docs/configuration.md
env:
# cookie - required
- name: Ray_BiliBiliCookies__1
# past your cookie value
value: ""
# DailyTrigger - required
- name: Ray_DailyTaskConfig__Cron
# This means BiliBili Toll triggers at every day's 08:10 AM
value: "10 8 * * *"

# Optional fields
- name: Ray_Security__IntervalSecondsBetweenRequestApi
value: "20"
- name: Ray_Security__RandomSleepMaxMin
value: "20"
#- name: Ray_LiveLotteryTaskConfig__Cron
# value: ""
#- name: Ray_UnfollowBatchedTaskConfig__Cron
# value: ""
#- name: Ray_VipBigPointConfig__Cron
# value: ""
# Add your custom env vars like
# - name: Ray_Security__IntervalSecondsBetweenRequestApi
# value: "20"
# - name: Ray_Security__RandomSleepMaxMin
# value: "20"
# - name: Ray_LiveLotteryTaskConfig__Cron
# value: ""

volumes:
enabled: false
Expand All @@ -44,10 +42,7 @@ volumes:
podAnnotations: {}

resources:
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# Recommended to set this resources field
limits:
cpu: 100m
memory: 180Mi
Expand Down