Skip to content

Commit

Permalink
Merge pull request #184 from monlor/test
Browse files Browse the repository at this point in the history
docs: ✏️ 添加helm部署文档
  • Loading branch information
monlor authored Jul 8, 2024
2 parents daba7d5 + bef2db7 commit 0dbadf8
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 17 deletions.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,52 @@ docker compose up -d
docker compose logs
```

### 部署在 Kubernetes

1. 安装helm

```bash
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
```

2. 安装helmfile

```bash
ver=0.161.0
curl -LO https://github.com/helmfile/helmfile/releases/download/v${ver}/helmfile_${ver}_linux_arm64.tar.gz
tar zxvf helmfile_${ver}_linux_arm64.tar.gz -C helmfile
mv helmfile/helmfile /usr/local/bin
rm -rf helmfile helmfile_${ver}_linux_arm64.tar.gz
helm plugin install https://github.com/databus23/helm-diff
```

3. 下载helmfile配置

```bash
curl -#LO https://raw.githubusercontent.com/monlor/docker-xiaoya/main/helmfile.yaml
```

4. 修改helmfile的环境变量,环境变量含义看这里[alist](/alist)

```yaml
env:
...
WEBDAV_PASSWORD:
ALIYUN_TOKEN:
ALIYUN_OPEN_TOKEN:
ALIYUN_FOLDER_ID:
QUARK_COOKIE:
PAN115_COOKIE:
PIKPAK_USER:
...
```

5. 部署helm服务

```bash
helmfile sync -f helmfile.yaml
```

### 使用docker部署【不推荐】

1. 创建volume
Expand Down
18 changes: 9 additions & 9 deletions helmfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ releases:
- name: alist
namespace: media
chart: monlor/quickchart
version: 0.2.6
version: 0.3.2
values:
- port: 5678
extraPort:
Expand All @@ -24,12 +24,15 @@ releases:
pullPolicy: Always
env:
TZ: Asia/Shanghai
ALIYUN_TOKEN:
ALIYUN_OPEN_TOKEN:
ALIYUN_FOLDER_ID:
AUTO_UPDATE_ENABLED: true
AUTO_CLEAR_ENABLED: true
WEBDAV_PASSWORD:
ALIYUN_TOKEN:
ALIYUN_OPEN_TOKEN:
ALIYUN_FOLDER_ID:
QUARK_COOKIE:
PAN115_COOKIE:
PIKPAK_USER:
volumes:
- name: data
mountPath: /data
Expand Down Expand Up @@ -57,7 +60,7 @@ releases:
- name: metadata
namespace: media
chart: monlor/quickchart
version: 0.2.6
version: 0.3.2
values:
- nodeSelector:
kubernetes.io/hostname: nuc-1-node-1
Expand Down Expand Up @@ -109,7 +112,7 @@ releases:
- name: emby
namespace: media
chart: monlor/quickchart
version: 0.2.6
version: 0.3.2
values:
- port: 6908
extraPort:
Expand All @@ -124,7 +127,6 @@ releases:
pullPolicy: Always
env:
TZ: Asia/Shanghai
GIDLIST: 0,0
# ALIST_ADDR: http://alist:5678
volumes:
- name: media
Expand All @@ -146,8 +148,6 @@ releases:
enabled: false
strategy:
type: Recreate
podSecurityContext:
privileged: true
resources:
limits:
cpu: 4
Expand Down
2 changes: 1 addition & 1 deletion metadata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

`EMBY_APIKEY`: emby api 密钥,建议修改emby的api密钥,设置此变量,用于定期同步emby配置

`EMBY_URL`: emby地址,默认:http://emby:6908
`EMBY_ADDR`: emby地址,默认:http://emby:6908

`ALIST_ADDR`: alist地址,默认:http://alist:5678

Expand Down
14 changes: 7 additions & 7 deletions metadata/emby.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
set -e

EMBY_APIKEY=${EMBY_APIKEY:-e825ed6f7f8f44ffa0563cddaddce14d}
EMBY_URL=${EMBY_URL:-http://emby:6908}
EMBY_ADDR=${EMBY_ADDR:-http://emby:6908}
ALIST_ADDR=${ALIST_ADDR:=http://alist:5678}

EMBY_CONTROL_URL="${EMBY_URL/6908/8080}"
EMBY_CONTROL_URL="${EMBY_ADDR/6908/8080}"

MEDIA_DIR="/media"

check_emby_status() {
curl -s -f -m 5 "${EMBY_URL}" > /dev/null
curl -s -f -m 5 "${EMBY_ADDR}" > /dev/null
}

save_user_policy() {
Expand All @@ -22,7 +22,7 @@ save_user_policy() {
fi

echo "保留用户 Policy 中..."
curl -s "${EMBY_URL}/Users?api_key=${EMBY_APIKEY}" > /tmp/emby.response
curl -s "${EMBY_ADDR}/Users?api_key=${EMBY_APIKEY}" > /tmp/emby.response
}

download() {
Expand Down Expand Up @@ -109,11 +109,11 @@ update_data() {
wait_for_emby() {
local MAX_WAIT="300"

echo "Waiting for Emby service to start at $EMBY_URL..."
echo "Waiting for Emby service to start at $EMBY_ADDR..."

while true; do
local http_code
http_code=$(curl -s -o /dev/null -w "%{http_code}" "${EMBY_URL}/Users")
http_code=$(curl -s -o /dev/null -w "%{http_code}" "${EMBY_ADDR}/Users")
if [ "$http_code" -eq 401 ]; then
echo "Emby service is up and running."
return 0
Expand All @@ -136,7 +136,7 @@ recover_user_policy() {
id=$(jq -r ".[$i].Id" /tmp/emby.response)
name=$(jq -r ".[$i].Name" /tmp/emby.response)
policy=$(jq -r ".[$i].Policy | to_entries | from_entries | tojson" /tmp/emby.response)
USER_URL_2="${EMBY_URL}/Users/$id/Policy?api_key=${EMBY_APIKEY}"
USER_URL_2="${EMBY_ADDR}/Users/$id/Policy?api_key=${EMBY_APIKEY}"
status_code=$(curl -s -w "%{http_code}" -H "Content-Type: application/json" -X POST -d "$policy" "$USER_URL_2")
if [ "$status_code" == "204" ]; then
echo "成功更新 $name 用户Policy"
Expand Down

0 comments on commit 0dbadf8

Please sign in to comment.