Skip to content

Instantly share code, notes, and snippets.

@fleeto
Created October 12, 2017 06:19
Show Gist options
  • Save fleeto/10bda96d2a0e1d3325d40996c29ddc19 to your computer and use it in GitHub Desktop.
Save fleeto/10bda96d2a0e1d3325d40996c29ddc19 to your computer and use it in GitHub Desktop.
GlusterFS as default storage class of Kubernetes, Usage: pvc2gluster.py [pvc name]
#!/usr/bin/python
import json
import subprocess
import sys
pvc_json = subprocess.check_output(
["kubectl", "get", "pvc", sys.argv[1], "-o", "json", "--all-namespaces"])
pvc_obj = json.loads(pvc_json)
pv_name = pvc_obj["spec"]["volumeName"]
pv_json = subprocess.check_output(
["kubectl", "get", "pv", pv_name, "-o", "json"])
pv_obj = json.loads(pv_json)
gluster_name = pv_obj["spec"]["glusterfs"]["path"]
print gluster_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment