-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
agents/calendar-api/templates/calendar-api-job-db-init.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: db-init-job | ||
spec: | ||
template: | ||
metadata: | ||
name: db-init-job | ||
spec: | ||
restartPolicy: OnFailure | ||
volumes: | ||
- name: calendar-db-volume | ||
persistentVolumeClaim: | ||
claimName: calendar-db-pvc | ||
containers: | ||
- name: init-container | ||
image: python:3.11-slim | ||
command: ["sh", "-c"] | ||
args: | ||
- | | ||
python3 - <<EOF | ||
import sqlite3 | ||
conn = sqlite3.connect('/data/CalendarDB.db') | ||
cursor = conn.cursor() | ||
cursor.execute(''' | ||
CREATE TABLE IF NOT EXISTS calendar ( | ||
sid TEXT PRIMARY KEY, | ||
name TEXT, | ||
content TEXT, | ||
category TEXT, | ||
level INTEGER, | ||
status REAL, | ||
creation_time TEXT, | ||
start_time TEXT, | ||
end_time TEXT | ||
) | ||
''') | ||
conn.commit() | ||
conn.close() | ||
EOF | ||
volumeMounts: | ||
- name: calendar-db-volume | ||
mountPath: /data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolume | ||
metadata: | ||
name: sqlite-pv | ||
name: calendar-db-pv | ||
spec: | ||
capacity: | ||
storage: 1Gi | ||
accessModes: | ||
- ReadWriteOnce | ||
persistentVolumeReclaimPolicy: Retain | ||
storageClassName: manual | ||
hostPath: | ||
path: "/data/sqlite" | ||
path: /data/CalendarDB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: sqlite-pvc | ||
name: calendar-db-pvc | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 1Gi | ||
storageClassName: manual |