Note: if you are running CloudGraph locally you can view the interactive, automatically generated documentation in either GraphQL Playground or Altair by clicking the docs button on the right-hand side of the screen. After reading the below information we highly suggest you use one of these tools to test your queries as they will autocomplete fields for you and let you know if your queries are valid before you even submit them.
You can currently query the following attributes and connections on a k8s Persistent Volume:
type k8sPersistentVolume {
id: String!
context: String!
apiVersion: String
kind: String
metadata {
id: String
annotations {
id: String!
key: String
value: String
}
clusterName: String
creationTimestamp: String
deletionGracePeriodSeconds: Int
deletionTimestamp: String
finalizers: [String]
generateName: String
generation: Int
labels {
id: String!
key: String
value: String
}
ownerReferences {
id: String!
apiVersion: String
blockOwnerDeletion: Boolean
controller: Boolean
kind: String
name: String
}
name: String
namespace: String
resourceVersion: String
selfLink: String
}
spec {
accessModes: [String]
awsElasticBlockStore {
fsType: String
partition: Int
readOnly: Boolean
volumeId: String
}
azureDisk {
cachingMode: String
diskName: String
diskUri: String
fsType: String
kind: String
readOnly: Boolean
}
azureFile {
readOnly: Boolean
secretName: String
shareName: String
}
capacity {
id: String
key: String
value: String
}
cephfs {
monitors: [String]
path: String
readOnly: Boolean
secretFile: String
user: String
secretRef {
name: String
}
}
cinder {
fsType: String
readOnly: Boolean
secretRef {
name: String
}
volumeId: String
}
claimRef {
id: String
apiVersion: String
fieldPath: String
kind: String
name: String
namespace: String
resourceVersion: String
}
csi {
volumeAttributes {
id: String
key: String
value: String
}
controllerExpandSecretRef {
name: String
}
controllerPublishSecretRef {
name: String
}
driver: String
fsType: String
readOnly: Boolean
volumeHandle: String
}
flexVolume {
driver: String
readOnly: Boolean
fsType: String
secretRef {
name: String
}
options {
id: String
key: String
value: String
}
}
flocker {
datasetName: String
datasetUuid: String
}
fc {
fsType: String
lun: Int
readOnly: Boolean
targetWWNs: [String]
wwids: [String]
}
gcePersistentDisk {
fsType: String
partition: Int
pdName: String
readOnly: Boolean
}
glusterfs {
endpoints: String
path: String
readOnly: Boolean
}
hostPath {
path: String
type: String
}
iscsi {
chapAuthDiscovery: Boolean
chapAuthSession: Boolean
fsType: String
initiatorName: String
iqn: String
iscsiInterface: String
lun: Int
portals: [String]
readOnly: Boolean
secretRef {
name: String
}
targetPortal: String
}
local {
fsType: String
path: String
}
nfs {
path: String
readOnly: Boolean
server: String
}
mountOptions: [String]
nodeAffinity {
required {
nodeSelectorTerms {
id: String
matchExpressions {
id: String
key: String
operator: String
values: [String]
}
matchFields {
id: String
key: String
operator: String
values: [String]
}
}
}
}
persistentVolumeReclaimPolicy: String
photonPersistentDisk {
fsType: String
pdId: String
}
portworxVolume {
fsType: String
readOnly: Boolean
volumeId: String
}
quobyte {
group: String
readOnly: Boolean
registry: String
tenant: String
user: String
volume: String
}
rbd {
fsType: String
image: String
keyring: String
monitors: [String]
pool: String
readOnly: Boolean
secretRef {
name: String
}
user: String
}
scaleIo {
fsType: String
gateway: String
protectionDomain: String
readOnly: Boolean
secretRef {
name: String
}
sslEnabled: Boolean
storageMode: String
storagePool: String
system: String
volumeName: String
}
storageClassName: String
storageos {
fsType: String
readOnly: Boolean
secretRef {
name: String
}
volumeName: String
volumeNamespace: String
}
volumeMode: String
vsphereVolume {
fsType: String
storagePolicyId: String
storagePolicyName: String
volumePath: String
}
}
status: {
phase: String
reason: String
message: String
}
namespace {
id
}
}
Get data for a single persistent volume that you know the id for:
query {
getk8sPersistentVolume(id: "12345") {
id
}
}
Get data for all of the persistent volumes in a certain k8s Context:
query {
queryk8sPersistentVolume(filter: { context: { eq: "my-context-name" } }) {
id
}
}
Get data for all of the persistent volumes NOT in a certain k8s Context:
query {
queryk8sPersistentVolume(filter: { not: { context: { eq: "my-context-name" } } }) {
id
}
}
Get data for all of the persistent volumes that have a namespace:
query {
queryk8sPersistentVolume(filter: { has: namespace }) {
id
}
}
Use multiple filter selectors, (i.e. has, and, not, or) to get data for all of the persistent volumes that have a namespace AND status OR that do not have a spec. Note that you can use has, and, not, or completely independently of each other:
query {
queryk8sPersistentVolume(
filter: {
has: namespace
and: { has: status }
or: { not: { has: spec } }
}
) {
id
}
}
You may also filter using a regex when filtering on a string field like, context if you want to look for a value that matches say, some-value (case insensitive):
query {
queryk8sPersistentVolume(
filter: { context: { regexp: "/.*some-value*./i" } }
) {
id
}
}
You can order the results you get back either asc or desc depending on your preference:
query {
queryk8sPersistentVolume(order: { desc: apiVersion }) {
apiVersion
}
}
Only select and return the first two persistent volumes that are found:
query {
queryk8sPersistentVolume(first: 2, order: { desc: context }) {
context
}
}
Only select and return the first two persistent volumes that are found, but offset by one so persistent volumes two & three are returned:
query {
queryk8sPersistentVolume(first: 2, order: { desc: context }, offset: 1) {
context
}
}
Count the number of persistent volumes across all scanned K8s contexts:
query {
aggregatek8sPersistentVolume {
count
}
}
Count the number of persistent volumes in a single context. Note that you can apply all of the same filters that are listed above to aggregate queries:
query {
aggregatek8sPersistentVolume(filter: { context: { eq: "my-context-name" } }) {
count
}
}
Putting it all together; get all data for all persistent volumes across all k8s contexts in a single query. For the purposes of this example we will only get direct children of the persistent volume but if you want to it's easy to go from say, persistentVolume -> namespace -> job ...etc:
query {
queryk8sPersistentVolume {
id
context
apiVersion
kind
metadata {
id
annotations {
id
key
value
}
clusterName
creationTimestamp
deletionGracePeriodSeconds
deletionTimestamp
finalizers
generateName
generation
labels {
id
key
value
}
ownerReferences {
id
apiVersion
blockOwnerDeletion
controller
kind
name
}
name
namespace
resourceVersion
selfLink
}
spec {
accessModes
awsElasticBlockStore {
fsType
partition
readOnly
volumeId
}
azureDisk {
cachingMode
diskName
diskUri
fsType
kind
readOnly
}
azureFile {
readOnly
secretName
shareName
}
capacity {
id
key
value
}
cephfs {
monitors
path
readOnly
secretFile
user
secretRef {
name
}
}
cinder {
fsType
readOnly
secretRef {
name
}
volumeId
}
claimRef {
id
apiVersion
fieldPath
kind
name
namespace
resourceVersion
}
csi {
volumeAttributes {
id
key
value
}
controllerExpandSecretRef {
name
}
controllerPublishSecretRef {
name
}
driver
fsType
readOnly
volumeHandle
}
flexVolume {
driver
readOnly
fsType
secretRef {
name
}
options {
id
key
value
}
}
flocker {
datasetName
datasetUuid
}
fc {
fsType
lun
readOnly
targetWWNs
wwids
}
gcePersistentDisk {
fsType
partition
pdName
readOnly
}
glusterfs {
endpoints
path
readOnly
}
hostPath {
path
type
}
iscsi {
chapAuthDiscovery
chapAuthSession
fsType
initiatorName
iqn
iscsiInterface
lun
portals
readOnly
secretRef {
name
}
targetPortal
}
local {
fsType
path
}
nfs {
path
readOnly
server
}
mountOptions
nodeAffinity {
required {
nodeSelectorTerms {
id
matchExpressions {
id
key
operator
values
}
matchFields {
id
key
operator
values
}
}
}
}
persistentVolumeReclaimPolicy
photonPersistentDisk {
fsType
pdId
}
portworxVolume {
fsType
readOnly
volumeId
}
quobyte {
group
readOnly
registry
tenant
user
volume
}
rbd {
fsType
image
keyring
monitors
pool
readOnly
secretRef {
name
}
user
}
scaleIo {
fsType
gateway
protectionDomain
readOnly
secretRef {
name
}
sslEnabled
storageMode
storagePool
system
volumeName
}
storageClassName
storageos {
fsType
readOnly
secretRef {
name
}
volumeName
volumeNamespace
}
volumeMode
vsphereVolume {
fsType
storagePolicyId
storagePolicyName
volumePath
}
}
status {
phase
reason
message
}
namespace {
id
context
apiVersion
kind
metadata {
id
annotations {
id
key
value
}
clusterName
creationTimestamp
deletionGracePeriodSeconds
deletionTimestamp
finalizers
generateName
generation
labels {
id
key
value
}
ownerReferences {
id
apiVersion
blockOwnerDeletion
controller
kind
name
}
name
namespace
resourceVersion
selfLink
}
spec {
finalizers
}
status {
phase
conditions {
id
lastHeartbeatTime
lastTransitionTime
message
reason
status
type
}
}
networkPolicies {
id
}
nodes {
id
}
pods {
id
}
deployments {
id
}
ingresses {
id
}
secrets {
id
}
services {
id
}
serviceAccounts {
id
}
storageClasses {
id
}
persistentVolumes {
id
}
persistentVolumeClaims {
id
}
roles {
id
}
jobs {
id
}
cronJobs {
id
}
}
}
}