Merge pull request #162 from nanos/k8-example
Update k8s example [#159]
This commit is contained in:
commit
cb3c980a94
3 changed files with 72 additions and 48 deletions
|
|
@ -102,7 +102,7 @@ FediFetcher is also available in a pre-packaged container, [FediFetcher](https:/
|
||||||
|
|
||||||
Persistent files are stored in `/app/artifacts` within the container, so you may want to map this to a local folder on your system.
|
Persistent files are stored in `/app/artifacts` within the container, so you may want to map this to a local folder on your system.
|
||||||
|
|
||||||
An [example Kubernetes CronJob](./examples/k8s-cronjob.yaml) for running the container is included in the `examples` folder.
|
An [example Kubernetes CronJob](./examples/k8s-cronjob.md) for running the container is included in the `examples` folder.
|
||||||
|
|
||||||
An [example Docker Compose Script](./examples/docker-compose.yaml) for running the container periodically is included in the `examples` folder.
|
An [example Docker Compose Script](./examples/docker-compose.yaml) for running the container periodically is included in the `examples` folder.
|
||||||
|
|
||||||
|
|
|
||||||
71
examples/k8s-cronjob.md
Normal file
71
examples/k8s-cronjob.md
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
# Running FediFetcher using a Kubernetes cronjob
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
>
|
||||||
|
> The below are not step-by-step instructions. We assume that you mostly know what you are doing.
|
||||||
|
|
||||||
|
You should first create a k8s secret, in order to then expose the token as an environment variable (this also avoids anything which might log the command line from including the sensitive value):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl create secret generic fedifetcher \
|
||||||
|
--from-literal=server_domain=example.com \
|
||||||
|
--from-literal=token="<token>"
|
||||||
|
```
|
||||||
|
|
||||||
|
Now define the cronjob, and don't forget to define your PVCs:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: CronJob
|
||||||
|
metadata:
|
||||||
|
name: fedifetcher
|
||||||
|
spec:
|
||||||
|
schedule: "*/15 * * * *"
|
||||||
|
failedJobsHistoryLimit: 5
|
||||||
|
successfulJobsHistoryLimit: 5
|
||||||
|
concurrencyPolicy: Forbid
|
||||||
|
jobTemplate:
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
restartPolicy: Never
|
||||||
|
containers:
|
||||||
|
- name: fedifetcher
|
||||||
|
image: ghcr.io/nanos/fedifetcher:latest
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
env:
|
||||||
|
- name: FF_HOME_TIMELINE_LENGTH
|
||||||
|
value: "200"
|
||||||
|
- name: FF_MAX_FOLLOWERS
|
||||||
|
value: "10"
|
||||||
|
|
||||||
|
# Add any other options below as described in in the README.md file
|
||||||
|
|
||||||
|
# If you don't want to use a PVC you may comment the next two lines, but that will significantly
|
||||||
|
# affect performance, and is NOT recommended
|
||||||
|
- name: FF_STATE_DIR
|
||||||
|
value: "/data/"
|
||||||
|
- name: FF_SERVER
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: fedifetcher
|
||||||
|
key: server_domain
|
||||||
|
optional: false
|
||||||
|
- name: FF_ACCESS_TOKEN
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: fedifetcher
|
||||||
|
key: token
|
||||||
|
optional: false
|
||||||
|
# Comment the lines below if you do not use a PVC, but that will significantly
|
||||||
|
# affect performance and is NOT recommended
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /data
|
||||||
|
name: fedifetcher
|
||||||
|
readOnly: false
|
||||||
|
volumes:
|
||||||
|
- name: fedifetcher
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: fedifetcher
|
||||||
|
```
|
||||||
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: PersistentVolumeClaim
|
|
||||||
metadata:
|
|
||||||
name: fedifetcher-pvc
|
|
||||||
spec:
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
volumeMode: Filesystem
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: 100Mi
|
|
||||||
---
|
|
||||||
apiVersion: batch/v1
|
|
||||||
kind: CronJob
|
|
||||||
metadata:
|
|
||||||
name: fedifetcher
|
|
||||||
spec:
|
|
||||||
# Run every 2 hours
|
|
||||||
schedule: "0 */2 * * *"
|
|
||||||
successfulJobsHistoryLimit: 1
|
|
||||||
failedJobsHistoryLimit: 1
|
|
||||||
concurrencyPolicy: Forbid
|
|
||||||
jobTemplate:
|
|
||||||
spec:
|
|
||||||
template:
|
|
||||||
spec:
|
|
||||||
volumes:
|
|
||||||
- name: artifacts
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: fedifetcher-pvc
|
|
||||||
containers:
|
|
||||||
- name: fedifetcher
|
|
||||||
image: ghcr.io/nanos/fedifetcher:latest
|
|
||||||
args:
|
|
||||||
- --server=your.server.social
|
|
||||||
- --access-token=TOKEN
|
|
||||||
- --home-timeline-length
|
|
||||||
- "200"
|
|
||||||
- --max-followings
|
|
||||||
- "80"
|
|
||||||
- --from-notification
|
|
||||||
- "4"
|
|
||||||
volumeMounts:
|
|
||||||
- name: artifacts
|
|
||||||
mountPath: /app/artifacts
|
|
||||||
restartPolicy: Never
|
|
||||||
Loading…
Reference in a new issue