feat(lancache-monolithic) add sidecar lancache-prefill (#12334)

**Description**
Sidecar to download and install BattleNetPrefill and/or EpicPrefill
and/or SteamPrefill and run the prefill on a cron schedule.

⚒️ Fixes  # <!--(issue)-->

**⚙️ Type of change**

- [X] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [ ] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [X] 🔃 Refactor of current code

**🧪 How Has This Been Tested?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ Checklist:**

- [X] ⚖️ My code follows the style guidelines of this project
- [X] 👀 I have performed a self-review of my own code
- [ ] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made corresponding changes to the documentation
- [ ] ⚠️ My changes generate no new warnings
- [ ] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [X] ⬆️ I increased versions for any altered app according to semantic
versioning

** App addition**

If this PR is an app addition please make sure you have done the
following.

- [ ] 🪞 I have opened a PR on
[truecharts/containers](https://github.com/truecharts/containers) adding
the container to TrueCharts mirror repo.
- [ ] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`

---

_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._
This commit is contained in:
Xstar97TheNoob
2023-09-10 04:15:46 -04:00
committed by GitHub
parent a07048c445
commit 801ff8039b
5 changed files with 332 additions and 126 deletions

View File

@@ -1,27 +1,27 @@
apiVersion: v2
kubeVersion: ">=1.16.0-0"
name: lancache-monolithic
version: 5.0.0
appVersion: "latest"
description: A monolithic lancache service capable of caching all CDNs in a single instance.
type: application
dependencies:
- name: common
repository: https://library-charts.truecharts.org
version: 14.0.1
deprecated: false
description: A monolithic lancache service capable of caching all CDNs in a single instance.
home: https://truecharts.org/charts/stable/lancache-monolithic
icon: https://truecharts.org/img/hotlink-ok/chart-icons/lancache-monolithic.png
keywords:
- monolithic
- lancache
sources:
- https://github.com/truecharts/charts/tree/master/charts/stable/lancache-monolithic
- https://github.com/lancachenet/monolithic
dependencies:
- name: common
repository: https://library-charts.truecharts.org
version: 14.0.1
kubeVersion: ">=1.16.0-0"
maintainers:
- email: info@truecharts.org
name: TrueCharts
url: https://truecharts.org
name: lancache-monolithic
sources:
- https://github.com/truecharts/charts/tree/master/charts/stable/lancache-monolithic
- https://github.com/lancachenet/monolithic
type: application
version: 5.1.0
annotations:
truecharts.org/catagories: |
- gaming

View File

@@ -16,48 +16,14 @@ Like TrueNAS Scale WebUI.
## Lancache-dns
- It's highly recommended to also install the `lancache-dns` chart along side the monolithic chart.
- It's highly recommended to also install the [lancache-dns](https://truecharts.org/charts/stable/lancache-dns/) chart along side the monolithic chart.
## Prefill Tools
## Lancache-Prefill
- You can run the Prefill tools directly inside the chart's shell.
- [SteamPrefill](https://github.com/tpill90/steam-lancache-prefill)
- [BattleNetPrefill](https://github.com/tpill90/battlenet-lancache-prefill)
Basic setup guides from upstream.
- In order for those tools to function you will need to install a apt pkg called `unzip`. This pkg will not persist between updates. It will need to be reinstalled before updating the tools everytime.
- BattleNet [docs](https://github.com/tpill90/battlenet-lancache-prefill#initial-setup)
- The following scripts are examples, but can be used to not only install them but also update them too. The scripts are a bit modified from the original that comes from [SteamPrefill](https://github.com/tpill90/steam-lancache-prefill/blob/master/scripts/update.sh).
- Steam [docs](https://github.com/tpill90/steam-lancache-prefill#initial-setup)
:::danger
Always be cautious when running unkown scripts and read them over before executing.
:::
### SteamPrefill
- This is a small modified update script from SteamPrefill to install the tool.
- Add this script to the `/data` dir and name it for ex: `install_steam.sh`.
- run this command on the script `chmod +x install_steam.sh` to be able to execute it from the shell.
- This script will create a new dir called `Steam` and grab the latest zip from `tpill90` repo for SteamPrefill and auto chmod +x for you.
- Then `cd Steam` if still in `/data` and execute `./SteamPrefill select-apps`.
- If you are not login into Steam yet, the tool will ask for:
- Username.
- Password.
- Steam Guard Code(if enabled on the account).
- Checkout the [install_steam.sh](https://gist.github.com/Xstar97/769878e95e4c505d7339fc840b88c82e) here.
### BattleNetPrefill
- This is a small modified update script from SteamPrefill to install BattleNetPrefill.
- Add this script to the `/data` dir and name it for ex: `install_battlenet.sh`.
- run this command on the script `chmod +x install_battlenet.sh` to be able to execute it from the shell.
- This script will create a new dir called `BattleNet` and grab the latest zip from `tpill90` repo for BattlenetPrefill and auto chmod +x for you.
- Then `cd BattleNet` if still in `/data` and execute `./BattleNetPrefill -h`.
- BattleNetPrefill doesnt require an account. But the command to prefill are a bit different.
- In order to prefill a specific game. you need to run this command first `./BattleNetPrefill list-products` to get the product ID.
- Then you can run `./BattleNetPrefill prefill -p PRODUCT_ID`.
- Checkout the [install_battlenet.sh](https://gist.github.com/Xstar97/ebb42ccbd9b00a1407e363dbd917309b) here.
- Epic [docs](https://github.com/tpill90/epic-lancache-prefill#initial-setup)

View File

@@ -9,58 +9,195 @@ questions:
# Include{podSpec}
# Include{containerMain}
- variable: env
group: "App Configuration"
label: "Image Environment"
schema:
additional_attrs: true
type: dict
attrs:
- variable: CACHE_DOMAINS_REPO
label: "CACHE DOMAINS REPO"
description: "The github repo url for the cache_domains files to use to populate the cdn maps."
schema:
type: string
default: "https://github.com/uklans/cache-domains.git"
- variable: CACHE_DOMAINS_BRANCH
label: "CACHE DOMAINS BRANCH"
description: "The branch of the CACHE_DOMAINS_REPO to use"
schema:
type: string
default: "master"
- variable: NOFETCH
label: "NO FETCH"
description: "Turn off all git pull operations and use stored data"
schema:
type: boolean
default: false
- variable: UPSTREAM_DNS
label: "UPSTREAM DNS"
description: "Upstream DNS server(s) the cache should use(separated by spaces). Do NOT point this at lancache-dns)"
schema:
type: string
default: "1.1.1.1 1.0.0.1"
- variable: CACHE_DISK_SIZE
label: "CACHE DISK SIZE"
description: "The amount of disk space the container should use for caching data"
schema:
type: string
default: "1000000m"
- variable: CACHE_MAX_AGE
label: "CACHE MAX AGE"
description: "The maximum amount of time a file should be held in cache"
schema:
type: string
default: "3560d"
- variable: CACHE_INDEX_SIZE
label: "CACHE INDEX SIZE"
description: "Amount of index memory for the nginx cache manager. We recommend 250m of index memory per 1TB"
schema:
type: string
default: "500m"
# Include{containerBasic}
# Include{containerAdvanced}
- variable: monolithic
group: App Configuration
label: LanCache Monolithic
schema:
additional_attrs: true
type: dict
attrs:
- variable: cache_domains_repo
label: Cache Domains Repo
description: The github repo url for the cache_domains files to use to populate the cdn maps.
schema:
type: string
default: "https://github.com/uklans/cache-domains.git"
- variable: cache_domains_branch
label: Cache Domains Repo
description: The branch of the CACHE_DOMAINS_REPO to use.
schema:
type: string
default: "master"
- variable: upstream_dns
label: Upstream DNS
description: Upstream DNS server(s). (Do NOT point this at lancache-dns)
schema:
type: list
empty: false
default:
- 1.1.1.1
- 1.0.0.1
required: true
items:
- variable: dns
label: DNS
schema:
type: string
required: true
default: ""
- variable: cache_disk_size
label: Cache Disk Size
description: The amount of disk space the container should use for caching data.
schema:
type: string
default: "1000000m"
- variable: cache_max_age
label: Cache Max Age
description: The maximum amount of time a file should be held in cache.
schema:
type: string
default: "3560d"
- variable: cache_index_size
label: Cache Index Size
description: Amount of index memory for the nginx cache manager. We recommend 250m of index memory per 1TB.
schema:
type: string
default: "500m"
- variable: no_fetch
label: No Fetch
description: Turn off all git pull operations and use stored data
schema:
type: boolean
default: false
- variable: prefill
group: App Configuration
label: LanCache Prefill
schema:
additional_attrs: true
type: dict
attrs:
- variable: enabled
label: Enable Prefill Sidecar
schema:
type: boolean
default: true
- variable: updates
label: Updates
description: enable to check for updates from BattleNetPrefill/SteamPrefill on container start/restart.
schema:
type: boolean
default: true
- variable: on_start
label: Prefill On Start
description: Force a Prefill on every container start/restart. (please be careful with this option and enable only when you know what you are doing!)
schema:
type: boolean
default: false
- variable: log_clean_up
label: Log Clean Up
description: enable to clean up the logs directory on each start/restart.
schema:
type: boolean
default: true
- variable: default_cron
label: Default Cron
description: Specify a cron schedule to override the individual schedules for BatteNetPrefill and SteamPrefill. (leave empty to set cron individually)
schema:
type: string
default: ""
- variable: battlenet
label: BattleNet Configuration
schema:
additional_attrs: true
type: dict
attrs:
- variable: enabled
label: Enabled
description: Enable or disable BattleNetPrefill.
schema:
type: boolean
default: true
show_subquestions_if: true
subquestions:
- variable: cron
label: cron
description: Set your cron schedule for the BattleNetPrefill.
schema:
type: string
default: ""
- variable: epic
label: Epic Configuration
schema:
additional_attrs: true
type: dict
attrs:
- variable: enabled
label: Enabled
description: Enable or disable EpicPrefill.
schema:
type: boolean
default: true
show_subquestions_if: true
subquestions:
- variable: params
label: Params
description: list of parameters for EpicPrefill.
schema:
type: list
default: []
required: true
items:
- variable: param
label: Param
schema:
type: string
required: true
default: ""
- variable: cron
label: cron
description: Set your cron schedule for the EpicPrefill.
schema:
type: string
default: ""
- variable: steam
label: Steam Configuration
schema:
additional_attrs: true
type: dict
attrs:
- variable: enabled
label: Enabled
description: Enable or disable SteamPrefill.
schema:
type: boolean
default: true
show_subquestions_if: true
subquestions:
- variable: params
label: Params
description: list of parameters for SteamPrefill. (if you want to only prefill your selected apps then leave this variable empty)
schema:
type: list
default: []
required: true
items:
- variable: param
label: Param
schema:
type: string
required: true
default: ""
- variable: cron
label: cron
description: Set your cron schedule for the SteamPrefill.
schema:
type: string
default: ""
# Include{containerConfig}
# Include{podOptions}
# Include{serviceRoot}
@@ -113,8 +250,8 @@ questions:
# Include{serviceList}
# Include{persistenceRoot}
- variable: config
label: "App Config Storage"
description: "Stores the Application Configuration."
label: "App Cache Storage"
description: "Stores the Application Cache."
schema:
additional_attrs: true
type: dict
@@ -127,6 +264,14 @@ questions:
additional_attrs: true
type: dict
attrs:
# Include{persistenceBasic}
- variable: prefill
label: "App Prefill Storage"
description: "Stores the Application Prefill."
schema:
additional_attrs: true
type: dict
attrs:
# Include{persistenceBasic}
# Include{persistenceList}
# Include{ingressRoot}

View File

@@ -1 +1,10 @@
{{ include "tc.v1.common.loader.all" . }}
{{/* Make sure all variables are set properly */}}
{{- include "tc.v1.common.loader.init" . -}}
{{/* Disable [prefill] if requested */}}
{{- if not .Values.prefill.enabled -}}
{{- $_ := set .Values.workload.prefill "enabled" false -}}
{{- end -}}
{{/* Render the templates */}}
{{- include "tc.v1.common.loader.apply" . -}}

View File

@@ -2,6 +2,18 @@ image:
repository: tccr.io/truecharts/lancache-monolithic
pullPolicy: IfNotPresent
tag: latest@sha256:eb23244b951e999cd1f0731fb8cc8a3aaa21c929ed20b8d35f47b1ce0f2af995
prefillImage:
repository: tccr.io/truecharts/lancache-prefill
pullPolicy: IfNotPresent
tag: latest@sha256:b0d891ccb2584eb5270505ec1cfcaeb16320757386f5626bc89fa61173c6d395
securityContext:
container:
readOnlyRootFilesystem: false
runAsNonRoot: false
runAsUser: 0
runAsGroup: 0
service:
main:
ports:
@@ -17,22 +29,43 @@ service:
port: 10280
targetPort: 443
protocol: https
persistence:
config:
monolithic:
cache_domains_repo: "https://github.com/uklans/cache-domains.git"
cache_domains_branch: "master"
upstream_dns:
- 1.1.1.1
- 1.0.0.1
cache_disk_size: "1000000m"
cache_max_age: "3560d"
cache_index_size: 500m
no_fetch: false
prefill:
# sidecar
enabled: true
updates: true
# Prefill on every container start/restart
on_start: false
log_clean_up: true
default_cron: ""
# BattleNet
battlenet:
enabled: true
mountPath: "/data"
logs:
cron: "0 5 * * *"
# Epic
epic:
enabled: true
mountPath: "/data/logs"
portal:
open:
enabled: false
securityContext:
container:
readOnlyRootFilesystem: false
runAsNonRoot: false
runAsUser: 0
runAsGroup: 0
# https://tpill90.github.io/epic-lancache-prefill/Detailed-Command-Usage/#prefill
params: []
cron: "0 4 * * *"
# Steam
steam:
enabled: true
# https://tpill90.github.io/steam-lancache-prefill/detailed-command-usage/Prefill/#options
params: []
cron: "0 2 * * *"
workload:
main:
podSpec:
@@ -46,10 +79,63 @@ workload:
startup:
type: tcp
env:
CACHE_DOMAINS_REPO: "https://github.com/uklans/cache-domains.git"
CACHE_DOMAINS_BRANCH: "master"
UPSTREAM_DNS: "1.1.1.1 1.0.0.1"
CACHE_DISK_SIZE: "1000000m"
CACHE_MAX_AGE: "3560d"
CACHE_INDEX_SIZE: "500m"
NOFETCH: false
CACHE_DOMAINS_REPO: "{{ .Values.monolithic.cache_domains_repo }}"
CACHE_DOMAINS_BRANCH: "{{ .Values.monolithic.cache_domains_branch }}"
UPSTREAM_DNS: '{{ join " " .Values.monolithic.upstream_dns }}'
CACHE_DISK_SIZE: "{{ .Values.monolithic.cache_disk_size }}"
CACHE_MAX_AGE: "{{ .Values.monolithic.cache_max_age }}"
CACHE_INDEX_SIZE: "{{ .Values.monolithic.cache_index_size }}"
NOFETCH: "{{ .Values.monolithic.no_fetch }}"
prefill:
enabled: true
type: Deployment
podSpec:
containers:
prefill:
primary: true
enabled: true
imageSelector: prefillImage
tty: true
stdin: true
probes:
liveness:
enabled: false
readiness:
enabled: false
startup:
enabled: false
env:
DATA_DIR: "{{ .Values.persistence.prefill.mountPath }}"
UPDATES: "{{ .Values.prefill.updates }}"
PREFILL_ONSTARTUP: "{{ .Values.prefill.on_start }}"
LOGCLEANUP: "{{ .Values.prefill.log_clean_up }}"
CRON_SCHED_GLOBAL: "{{ .Values.prefill.default_cron }}"
# BattleNet
ENABLE_BN: "{{ .Values.prefill.battlenet.enabled }}"
CRON_SCHED_BN: "{{ .Values.prefill.battlenet.cron }}"
# Epic
ENABLE_EPIC: "{{ .Values.prefill.epic.enabled }}"
CRON_SCHED_EPIC: "{{ .Values.prefill.epic.cron }}"
PREFILL_PARAMS_EPIC: '{{ join " " .Values.prefill.epic.params }}'
# Steam
ENABLE_STEAM: "{{ .Values.prefill.steam.enabled }}"
PREFILL_PARAMS_STEAM: '{{ join " " .Values.prefill.steam.params }}'
CRON_SCHED_STEAM: "{{ .Values.prefill.steam.cron }}"
DATA_PERM: 770
USER: root
persistence:
config:
enabled: true
mountPath: "/data/cache"
logs:
enabled: true
mountPath: "/data/logs"
prefill:
enabled: true
mountPath: /data/prefill
targetSelectAll: true
portal:
open:
enabled: false