Skip to content

Commit

Permalink
Add statefulset and daemonset samples
Browse files Browse the repository at this point in the history
Each sample has a:
- workload that can be used later for testing discovered apps
- subscription kustomization that can be used manual testing or with ramen basic-test
- dr kustomization that can be used manually (ramen basic-test generated
  its own drpc)

Unfinished:
- Not test yet
- Need to add dr samples for discovered apps

Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs committed Jun 4, 2024
1 parent c9c4928 commit 907ce15
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dr/daemonset-k8s-regional-rbd/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
namespace: daemonset-rbd
commonLabels:
app: daemonset-rbd
resources:
- ../base
6 changes: 6 additions & 0 deletions dr/statefulset-k8s-regional-rbd/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
namespace: statefulset-rbd
commonLabels:
app: statefulset-rbd
resources:
- ../base
15 changes: 15 additions & 0 deletions subscription/daemonset-k8s-regional-rbd/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
resources:
- ../base
namespace: daemonset-rbd
commonLabels:
app: daemonset-rbd
patches:
# Customize path to application.
- target:
kind: Subscription
name: subscription
patch: |-
- op: replace
path: /metadata/annotations/apps.open-cluster-management.io~1github-path
value: workloads/daemonset/k8s-regional-rbd
15 changes: 15 additions & 0 deletions subscription/statefulset-k8s-regional-rbd/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
resources:
- ../base
namespace: statefulset-rbd
commonLabels:
app: statefulset-rbd
patches:
# Customize path to application.
- target:
kind: Subscription
name: subscription
patch: |-
- op: replace
path: /metadata/annotations/apps.open-cluster-management.io~1github-path
value: workloads/statefulset/k8s-regional-rbd
47 changes: 47 additions & 0 deletions workloads/daemonset/base/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: busybox
spec:
selector:
matchLabels:
appname: busybox
template:
metadata:
labels:
appname: busybox
spec:
containers:
- name: logger
image: quay.io/nirsof/busybox:stable
imagePullPolicy: IfNotPresent
command:
- sh
- -c
- |
emit() {
echo "$(date) $1" | tee -a /var/log/ramen.log
sync
}
trap "emit STOP; exit" TERM
emit START
while true; do
sleep 10 & wait
emit UPDATE
done
volumeMounts:
- name: varlog
mountPath: /var/log
volumes:
- name: varlog
persistentVolumeClaim:
claimName: busybox-pvc
tolerations:
# Run also on control-plane and master nodes.
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
8 changes: 8 additions & 0 deletions workloads/daemonset/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
commonLabels:
appname: busybox
resources:
- pvc.yaml
- daemonset.yaml
13 changes: 13 additions & 0 deletions workloads/daemonset/base/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: busybox-pvc
spec:
accessModes:
- ReadWriteOnce
# Customize in your overlay.
storageClassName: STORAGE_CLASS_NAME
resources:
requests:
storage: 1Gi
11 changes: 11 additions & 0 deletions workloads/daemonset/k8s-regional-rbd/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
resources:
- ../base
patches:
- target:
kind: PersistentVolumeClaim
name: busybox-pvc
patch: |-
- op: replace
path: /spec/storageClassName
value: rook-ceph-block
7 changes: 7 additions & 0 deletions workloads/statefulset/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
commonLabels:
appname: busybox
resources:
- statefulset.yaml
55 changes: 55 additions & 0 deletions workloads/statefulset/base/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: busybox
spec:
# Required for proper clean up on failover and successful relocate. You
# must enable the StatefulSetAutoDeletePVC feature gate for this.
# https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention
persistentVolumeClaimRetentionPolicy:
whenDeleted: Delete
whenScaled: Retain
selector:
matchLabels:
appname: busybox
replicas: 2
template:
metadata:
labels:
appname: busybox
spec:
containers:
- name: logger
image: quay.io/nirsof/busybox:stable
imagePullPolicy: IfNotPresent
command:
- sh
- -c
- |
emit() {
echo "$(date) $1" | tee -a /var/log/ramen.log
sync
}
trap "emit STOP; exit" TERM
emit START
while true; do
sleep 10 & wait
emit UPDATE
done
volumeMounts:
- name: varlog
mountPath: /var/log
volumeClaimTemplates:
- metadata:
name: varlog
labels:
appname: busybox
spec:
accessModes:
- ReadWriteOnce
# Customize in your overlay.
storageClassName: STORAGE_CLASS_NAME
resources:
requests:
storage: 1Gi
11 changes: 11 additions & 0 deletions workloads/statefulset/k8s-regional-rbd/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
resources:
- ../base
patches:
- target:
kind: StatefulSet
name: busybox
patch: |-
- op: replace
path: /spec/volumeClaimTemplates/0/spec/storageClassName
value: rook-ceph-block

0 comments on commit 907ce15

Please sign in to comment.