Skip to content

Instantly share code, notes, and snippets.

@sanskarsharma
Last active October 3, 2023 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanskarsharma/f5647a3a082d3fe3f620dcdf9ba7cda0 to your computer and use it in GitHub Desktop.
Save sanskarsharma/f5647a3a082d3fe3f620dcdf9ba7cda0 to your computer and use it in GitHub Desktop.
Example stateful application on kubernetes: my-stateful-app
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-stateful-app-pvc
labels:
app: my-stateful-app
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-stateful-app
labels:
app: my-stateful-app
spec:
replicas: 1
strategy:
type: RollingUpdate
selector:
matchLabels:
app: my-stateful-app
template:
metadata:
labels:
app: my-stateful-app
spec:
containers:
- name: my-stateful-app
image: busybox
command: [ "/bin/sh", "-c", "--" ]
args: [ 'touch /data/file1.txt; while true; do echo "Hellu"; sleep 2; done;' ]
resources:
requests:
memory: 100Mi
limits:
memory: 100Mi
env:
- name: DUMMY
value: '1'
volumeMounts:
- name: my-stateful-app-vol
mountPath: /data
volumes:
- name: my-stateful-app-vol
persistentVolumeClaim:
claimName: my-stateful-app-pvc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment