Skip to content

Instantly share code, notes, and snippets.

@fenar
Last active July 30, 2024 14:46
Show Gist options
  • Select an option

  • Save fenar/ea98c9c41c5a834b504d4a29292f13f6 to your computer and use it in GitHub Desktop.

Select an option

Save fenar/ea98c9c41c5a834b504d4a29292f13f6 to your computer and use it in GitHub Desktop.

Key Points of the Configuration

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.

Additional Considerations

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment