Pod Anti-Affinity: The podAntiAffinity rule prevents the ODF pods from being scheduled on the same node. This ensures high availability and fault tolerance by distributing the pods across different nodes.
Node Affinity: The nodeAffinity rule specifies that the ODF pods should only be scheduled on the specified nodes (worker-odf-01.acmhub2.narlabs.io, worker-odf-02.acmhub2.narlabs.io, worker-odf-03.acmhub2.narlabs.io). This guarantees that the ODF pods run only on these designated nodes, which may have specific configurations or resources required by the application.
Resource Requests and Limits: The resources requested and limited for the containers ensure that each pod has sufficient CPU and memory. Adjust these values based on actual workload requirements.
Persistent Volume and PVC: The configuration includes a sample PersistentVolume and PersistentVolumeClaim for storage. Customize these to fit the specific storage needs and infrastructure setup.
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: example-pv
spec:
capacity:
storage: 100Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: manual
hostPath:
path: "/mnt/data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: example-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: manual
resources:
requests:
storage: 10Gi
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: odf-statefulset
spec:
selector:
matchLabels:
app: odf
serviceName: "odf-service"
replicas: 3
template:
metadata:
labels:
app: odf
spec:
containers:
- name: odf-container
image: odf-image:latest
resources:
requests:
memory: "2Gi"
cpu: "1"
limits:
memory: "4Gi"
cpu: "2"
volumeMounts:
- name: data
mountPath: /data
volumes:
- name: data
persistentVolumeClaim:
claimName: example-pvc
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- odf
topologyKey: "kubernetes.io/hostname"
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- worker-odf-01.acmhub2.narlabs.io
- worker-odf-02.acmhub2.narlabs.io
- worker-odf-03.acmhub2.narlabs.io