Skip to content

Instantly share code, notes, and snippets.

@haani-niyaz
Last active March 26, 2018 00:39
Show Gist options
  • Save haani-niyaz/5c441a294af6592c9796ce389f4ae088 to your computer and use it in GitHub Desktop.
Save haani-niyaz/5c441a294af6592c9796ce389f4ae088 to your computer and use it in GitHub Desktop.
Random kubernetes code snippets

How to use hostPath pv with a volumeClaimTemplate in StatefulSets

hostPath PV

---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: task-pv-volume
  namespace: proteus
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data"

Claim the PV via Template:

  volumeClaimTemplates:
  - metadata:
      name: logs 
    spec:    
      storageClassName: manual
      resources:                     
        requests:                    
          storage: 10Gi             
      accessModes:                   
      - ReadWriteOnce     

Find Nodes that have Pods

kubectl get pods -o wide --sort-by="{.spec.nodeName}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment