Skip to content

Commit

Permalink
Merge pull request #22 from jkremser/data-retention
Browse files Browse the repository at this point in the history
Data retention; light theme; probes
  • Loading branch information
jkremser authored Jun 3, 2024
2 parents 3b46dcf + 8285e65 commit 948ffb2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 6 deletions.
27 changes: 27 additions & 0 deletions samples/stable-diffusion/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,30 @@ bash-5.1# cd /images
bash-5.1# ls
08d90897-1b75-4f10-bd79-7fd341c7b6f8-1.png 10a0f914-f6df-4481-9c91-519eb6357bb6-3.png ...
```

### Change Data Retention Policy

Minio's bucket can be configured to automatically delete old files which can be useful for this use-case.

First expose the minio's webui:

```
kubectl port-forward -n stable-diff svc/minio-console 9001
```

Log in using credentials obtained from the secret:

```
# copy the username to clipboard
kubectl get secrets -n stable-diff minio -o jsonpath={.data.rootUser} | base64 --decode | pbcopy
# copy the password to clipboard
kubectl get secrets -n stable-diff minio -o jsonpath={.data.rootPassword} | base64 --decode | pbcopy
# open http://localhost:9001
```

In the Web UI go to:
`buckets > images > Lifecycle > Add Lifecycle Rule`

Select 'Expiry' and set number of days after which the data will be deleted.
33 changes: 28 additions & 5 deletions samples/stable-diffusion/manifests/webapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 10
initialDelaySeconds: 60
initialDelaySeconds: 15
readinessProbe:
failureThreshold: 3
httpGet:
Expand All @@ -50,14 +50,14 @@ spec:
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 10
initialDelaySeconds: 30
initialDelaySeconds: 15
ports:
- name: http
containerPort: 3000
protocol: TCP
resources:
requests:
cpu: 1000m
cpu: 600m
memory: 512Mi
- image: minio/mc
name: minio-sidecar
Expand All @@ -78,8 +78,31 @@ spec:
mc alias set shared http://minio:9000 $MINIO_USERNAME $MINIO_PASSWORD
mc admin info shared
echo "Minio configured, starting sync.."
while true; do mc mirror --exclude working --overwrite shared/images /images; sleep 1; done
touch /var/run/minio
while mc mirror --exclude working --overwrite shared/images /images ; do sleep 2; done
rm /var/run/minio
readinessProbe:
failureThreshold: 1
exec:
command:
- sh
- -c
- test -f /var/run/minio
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 10
initialDelaySeconds: 30
livenessProbe:
failureThreshold: 1
exec:
command:
- sh
- -c
- test -f /var/run/minio
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 10
initialDelaySeconds: 15
volumeMounts:
- name: shared-images
mountPath: /images
Expand Down
2 changes: 1 addition & 1 deletion samples/stable-diffusion/webui/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Home = async () => {
return (
<>
<nav
className="relative flex w-full flex-wrap items-center justify-between bg-zinc-50 py-2 shadow-dark-mild dark:bg-neutral-800 lg:py-2">
className="relative flex w-full flex-wrap items-center justify-between bg-zinc-50 py-2 shadow-dark-mild bg-neutral-800 lg:py-2">
<div className="flex w-full flex-wrap items-center justify-between px-3">
<div className="ms-2">
<a className="text-xl text-sky-400 " href="https://github.com/kedify/examples/tree/main/samples/stable-diffusion" target="_blank">Stable Diffusion</a> <span className="sm:text-sky-200 hidden sm:inline-block">This AI Model is autoscaled using Kubernetes Event-Driven Austoscaling (KEDA) powered by Kedify</span>
Expand Down

0 comments on commit 948ffb2

Please sign in to comment.