Skip to content

Instantly share code, notes, and snippets.

@ihcsim
Last active February 13, 2023 18:55
Show Gist options
  • Save ihcsim/7c3d175f06fbc08cd66dcbf77aace537 to your computer and use it in GitHub Desktop.
Save ihcsim/7c3d175f06fbc08cd66dcbf77aace537 to your computer and use it in GitHub Desktop.
SQLite StatefulSet YAML
apiVersion: v1
kind: Pod
metadata
name: curl
spec:
containers:
- name: curl
image: curlimages/curl:7.87.0
command: ["sleep", "infinity"]
apiVersion: v1
kind: Pod
metadata:
name: data-mover
labels:
app.kubernetes.io/name: sqlite3-data-mover
spec:
containers:
- name: data-mover
image: keinos/sqlite3:3.40.0
command:
- sh
- -c
- |
sleep infinity
volumeMounts:
- name: data
mountPath: /run/sqlite3
volumes:
- name: data
persistentVolumeClaim:
claimName: data-sqlite3-0
readOnly: true
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: sqlite3
labels:
app.kubernetes.io/name: sqlite3
spec:
replicas: 1
podManagementPolicy: Parallel
serviceName: sqlite3
selector:
matchLabels:
app.kubernetes.io/name: sqlite3
template:
metadata:
labels:
app.kubernetes.io/name: sqlite3
spec:
securityContext:
fsGroup: 101 # gid=101(sqlite)
fsGroupChangePolicy: OnRootMismatch
initContainers:
- name: initdb
image: keinos/sqlite3:3.40.0
command:
- sh
- -c
- |
if [ ! -f /run/sqlite3/demo.db ]
then
echo "creating test DB"
sqlite3 /run/sqlite3/demo.db <<HEREDOC
create table demo(timestamp text, description text);
insert into demo values(datetime("now"),"First sample data. Hoo");
insert into demo values(datetime("now"),"Second sample data. Bar");
HEREDOC
fi
volumeMounts:
- name: data
mountPath: /run/sqlite3
containers:
- name: sqlite3
image: keinos/sqlite3:3.40.0
command:
- sh
- -c
- |
sqlite3 /run/sqlite3/demo.db -header -column 'SELECT rowid, * FROM demo;'
sleep 4h
resources:
requests:
cpu: 500m
memory: 1Gi
limits:
cpu: "2"
memory: 2Gi
volumeMounts:
- name: data
mountPath: /run/sqlite3
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 5Gi
storageClassName: <sc-name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment