Last active
March 4, 2025 19:30
-
-
Save liggitt/9ffc096f10b543d8d42573f5c2236533 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DEBUG CREATED: | |
| { | |
| "metadata": { | |
| "name": "test", | |
| "namespace": "default", | |
| "uid": "1270bfa8-8a02-4e06-862d-08e9e0cca377", | |
| "resourceVersion": "2488", | |
| "generation": 1, | |
| "creationTimestamp": "2025-03-04T19:25:20Z", | |
| "managedFields": [ | |
| { | |
| "manager": "main", | |
| "operation": "Update", | |
| "apiVersion": "apps/v1", | |
| "time": "2025-03-04T19:25:20Z", | |
| "fieldsType": "FieldsV1", | |
| "fieldsV1": { | |
| "f:spec": { | |
| "f:persistentVolumeClaimRetentionPolicy": { | |
| ".": {}, | |
| "f:whenDeleted": {}, | |
| "f:whenScaled": {} | |
| }, | |
| "f:podManagementPolicy": {}, | |
| "f:replicas": {}, | |
| "f:revisionHistoryLimit": {}, | |
| "f:selector": {}, | |
| "f:template": { | |
| "f:metadata": { | |
| "f:labels": { | |
| ".": {}, | |
| "f:app": {} | |
| } | |
| }, | |
| "f:spec": { | |
| "f:containers": { | |
| "k:{\"name\":\"web\"}": { | |
| ".": {}, | |
| "f:image": {}, | |
| "f:imagePullPolicy": {}, | |
| "f:name": {}, | |
| "f:resources": {}, | |
| "f:terminationMessagePath": {}, | |
| "f:terminationMessagePolicy": {} | |
| } | |
| }, | |
| "f:dnsPolicy": {}, | |
| "f:restartPolicy": {}, | |
| "f:schedulerName": {}, | |
| "f:securityContext": {}, | |
| "f:terminationGracePeriodSeconds": {} | |
| } | |
| }, | |
| "f:updateStrategy": { | |
| "f:rollingUpdate": { | |
| ".": {}, | |
| "f:partition": {} | |
| }, | |
| "f:type": {} | |
| }, | |
| "f:volumeClaimTemplates": {} | |
| } | |
| } | |
| } | |
| ] | |
| }, | |
| "spec": { | |
| "replicas": 1, | |
| "selector": { | |
| "matchLabels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "template": { | |
| "metadata": { | |
| "creationTimestamp": null, | |
| "labels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "spec": { | |
| "containers": [ | |
| { | |
| "name": "web", | |
| "image": "nginx:1.12", | |
| "resources": {}, | |
| "terminationMessagePath": "/dev/termination-log", | |
| "terminationMessagePolicy": "File", | |
| "imagePullPolicy": "IfNotPresent" | |
| } | |
| ], | |
| "restartPolicy": "Always", | |
| "terminationGracePeriodSeconds": 30, | |
| "dnsPolicy": "ClusterFirst", | |
| "securityContext": {}, | |
| "schedulerName": "default-scheduler" | |
| } | |
| }, | |
| "volumeClaimTemplates": [ | |
| { | |
| "kind": "PersistentVolumeClaim", | |
| "apiVersion": "v1", | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| }, | |
| { | |
| "kind": "PersistentVolumeClaim", | |
| "apiVersion": "v1", | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| } | |
| ], | |
| "serviceName": "", | |
| "podManagementPolicy": "OrderedReady", | |
| "updateStrategy": { | |
| "type": "RollingUpdate", | |
| "rollingUpdate": { | |
| "partition": 0 | |
| } | |
| }, | |
| "revisionHistoryLimit": 10, | |
| "persistentVolumeClaimRetentionPolicy": { | |
| "whenDeleted": "Retain", | |
| "whenScaled": "Retain" | |
| } | |
| }, | |
| "status": { | |
| "replicas": 0, | |
| "availableReplicas": 0 | |
| } | |
| } | |
| DEBUG Get raw: | |
| { | |
| "kind": "StatefulSet", | |
| "apiVersion": "apps/v1", | |
| "metadata": { | |
| "name": "test", | |
| "namespace": "default", | |
| "uid": "1270bfa8-8a02-4e06-862d-08e9e0cca377", | |
| "resourceVersion": "2488", | |
| "generation": 1, | |
| "creationTimestamp": "2025-03-04T19:25:20Z", | |
| "managedFields": [ | |
| { | |
| "manager": "main", | |
| "operation": "Update", | |
| "apiVersion": "apps/v1", | |
| "time": "2025-03-04T19:25:20Z", | |
| "fieldsType": "FieldsV1", | |
| "fieldsV1": { | |
| "f:spec": { | |
| "f:persistentVolumeClaimRetentionPolicy": { | |
| ".": {}, | |
| "f:whenDeleted": {}, | |
| "f:whenScaled": {} | |
| }, | |
| "f:podManagementPolicy": {}, | |
| "f:replicas": {}, | |
| "f:revisionHistoryLimit": {}, | |
| "f:selector": {}, | |
| "f:template": { | |
| "f:metadata": { | |
| "f:labels": { | |
| ".": {}, | |
| "f:app": {} | |
| } | |
| }, | |
| "f:spec": { | |
| "f:containers": { | |
| "k:{\"name\":\"web\"}": { | |
| ".": {}, | |
| "f:image": {}, | |
| "f:imagePullPolicy": {}, | |
| "f:name": {}, | |
| "f:resources": {}, | |
| "f:terminationMessagePath": {}, | |
| "f:terminationMessagePolicy": {} | |
| } | |
| }, | |
| "f:dnsPolicy": {}, | |
| "f:restartPolicy": {}, | |
| "f:schedulerName": {}, | |
| "f:securityContext": {}, | |
| "f:terminationGracePeriodSeconds": {} | |
| } | |
| }, | |
| "f:updateStrategy": { | |
| "f:rollingUpdate": { | |
| ".": {}, | |
| "f:partition": {} | |
| }, | |
| "f:type": {} | |
| }, | |
| "f:volumeClaimTemplates": {} | |
| } | |
| } | |
| } | |
| ] | |
| }, | |
| "spec": { | |
| "replicas": 1, | |
| "selector": { | |
| "matchLabels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "template": { | |
| "metadata": { | |
| "creationTimestamp": null, | |
| "labels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "spec": { | |
| "containers": [ | |
| { | |
| "name": "web", | |
| "image": "nginx:1.12", | |
| "resources": {}, | |
| "terminationMessagePath": "/dev/termination-log", | |
| "terminationMessagePolicy": "File", | |
| "imagePullPolicy": "IfNotPresent" | |
| } | |
| ], | |
| "restartPolicy": "Always", | |
| "terminationGracePeriodSeconds": 30, | |
| "dnsPolicy": "ClusterFirst", | |
| "securityContext": {}, | |
| "schedulerName": "default-scheduler" | |
| } | |
| }, | |
| "volumeClaimTemplates": [ | |
| { | |
| "kind": "PersistentVolumeClaim", | |
| "apiVersion": "v1", | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| }, | |
| { | |
| "kind": "PersistentVolumeClaim", | |
| "apiVersion": "v1", | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| } | |
| ], | |
| "serviceName": "", | |
| "podManagementPolicy": "OrderedReady", | |
| "updateStrategy": { | |
| "type": "RollingUpdate", | |
| "rollingUpdate": { | |
| "partition": 0 | |
| } | |
| }, | |
| "revisionHistoryLimit": 10, | |
| "persistentVolumeClaimRetentionPolicy": { | |
| "whenDeleted": "Retain", | |
| "whenScaled": "Retain" | |
| } | |
| }, | |
| "status": { | |
| "replicas": 0, | |
| "availableReplicas": 0 | |
| } | |
| } | |
| DEBUG Get raw: | |
| { | |
| "metadata": { | |
| "name": "test", | |
| "namespace": "default", | |
| "uid": "1270bfa8-8a02-4e06-862d-08e9e0cca377", | |
| "resourceVersion": "2488", | |
| "generation": 1, | |
| "creationTimestamp": "2025-03-04T19:25:20Z", | |
| "managedFields": [ | |
| { | |
| "manager": "main", | |
| "operation": "Update", | |
| "apiVersion": "apps/v1", | |
| "time": "2025-03-04T19:25:20Z", | |
| "fieldsType": "FieldsV1", | |
| "fieldsV1": { | |
| "f:spec": { | |
| "f:persistentVolumeClaimRetentionPolicy": { | |
| ".": {}, | |
| "f:whenDeleted": {}, | |
| "f:whenScaled": {} | |
| }, | |
| "f:podManagementPolicy": {}, | |
| "f:replicas": {}, | |
| "f:revisionHistoryLimit": {}, | |
| "f:selector": {}, | |
| "f:template": { | |
| "f:metadata": { | |
| "f:labels": { | |
| ".": {}, | |
| "f:app": {} | |
| } | |
| }, | |
| "f:spec": { | |
| "f:containers": { | |
| "k:{\"name\":\"web\"}": { | |
| ".": {}, | |
| "f:image": {}, | |
| "f:imagePullPolicy": {}, | |
| "f:name": {}, | |
| "f:resources": {}, | |
| "f:terminationMessagePath": {}, | |
| "f:terminationMessagePolicy": {} | |
| } | |
| }, | |
| "f:dnsPolicy": {}, | |
| "f:restartPolicy": {}, | |
| "f:schedulerName": {}, | |
| "f:securityContext": {}, | |
| "f:terminationGracePeriodSeconds": {} | |
| } | |
| }, | |
| "f:updateStrategy": { | |
| "f:rollingUpdate": { | |
| ".": {}, | |
| "f:partition": {} | |
| }, | |
| "f:type": {} | |
| }, | |
| "f:volumeClaimTemplates": {} | |
| } | |
| } | |
| } | |
| ] | |
| }, | |
| "spec": { | |
| "replicas": 1, | |
| "selector": { | |
| "matchLabels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "template": { | |
| "metadata": { | |
| "creationTimestamp": null, | |
| "labels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "spec": { | |
| "containers": [ | |
| { | |
| "name": "web", | |
| "image": "nginx:1.12", | |
| "resources": {}, | |
| "terminationMessagePath": "/dev/termination-log", | |
| "terminationMessagePolicy": "File", | |
| "imagePullPolicy": "IfNotPresent" | |
| } | |
| ], | |
| "restartPolicy": "Always", | |
| "terminationGracePeriodSeconds": 30, | |
| "dnsPolicy": "ClusterFirst", | |
| "securityContext": {}, | |
| "schedulerName": "default-scheduler" | |
| } | |
| }, | |
| "volumeClaimTemplates": [ | |
| { | |
| "kind": "PersistentVolumeClaim", | |
| "apiVersion": "v1", | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| }, | |
| { | |
| "kind": "PersistentVolumeClaim", | |
| "apiVersion": "v1", | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| } | |
| ], | |
| "serviceName": "", | |
| "podManagementPolicy": "OrderedReady", | |
| "updateStrategy": { | |
| "type": "RollingUpdate", | |
| "rollingUpdate": { | |
| "partition": 0 | |
| } | |
| }, | |
| "revisionHistoryLimit": 10, | |
| "persistentVolumeClaimRetentionPolicy": { | |
| "whenDeleted": "Retain", | |
| "whenScaled": "Retain" | |
| } | |
| }, | |
| "status": { | |
| "replicas": 0, | |
| "availableReplicas": 0 | |
| } | |
| } | |
| DEBUG GET: | |
| { | |
| "metadata": { | |
| "name": "test", | |
| "namespace": "default", | |
| "uid": "1270bfa8-8a02-4e06-862d-08e9e0cca377", | |
| "resourceVersion": "2488", | |
| "generation": 1, | |
| "creationTimestamp": "2025-03-04T19:25:20Z", | |
| "managedFields": [ | |
| { | |
| "manager": "main", | |
| "operation": "Update", | |
| "apiVersion": "apps/v1", | |
| "time": "2025-03-04T19:25:20Z", | |
| "fieldsType": "FieldsV1", | |
| "fieldsV1": { | |
| "f:spec": { | |
| "f:persistentVolumeClaimRetentionPolicy": { | |
| ".": {}, | |
| "f:whenDeleted": {}, | |
| "f:whenScaled": {} | |
| }, | |
| "f:podManagementPolicy": {}, | |
| "f:replicas": {}, | |
| "f:revisionHistoryLimit": {}, | |
| "f:selector": {}, | |
| "f:template": { | |
| "f:metadata": { | |
| "f:labels": { | |
| ".": {}, | |
| "f:app": {} | |
| } | |
| }, | |
| "f:spec": { | |
| "f:containers": { | |
| "k:{\"name\":\"web\"}": { | |
| ".": {}, | |
| "f:image": {}, | |
| "f:imagePullPolicy": {}, | |
| "f:name": {}, | |
| "f:resources": {}, | |
| "f:terminationMessagePath": {}, | |
| "f:terminationMessagePolicy": {} | |
| } | |
| }, | |
| "f:dnsPolicy": {}, | |
| "f:restartPolicy": {}, | |
| "f:schedulerName": {}, | |
| "f:securityContext": {}, | |
| "f:terminationGracePeriodSeconds": {} | |
| } | |
| }, | |
| "f:updateStrategy": { | |
| "f:rollingUpdate": { | |
| ".": {}, | |
| "f:partition": {} | |
| }, | |
| "f:type": {} | |
| }, | |
| "f:volumeClaimTemplates": {} | |
| } | |
| } | |
| } | |
| ] | |
| }, | |
| "spec": { | |
| "replicas": 1, | |
| "selector": { | |
| "matchLabels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "template": { | |
| "metadata": { | |
| "creationTimestamp": null, | |
| "labels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "spec": { | |
| "containers": [ | |
| { | |
| "name": "web", | |
| "image": "nginx:1.12", | |
| "resources": {}, | |
| "terminationMessagePath": "/dev/termination-log", | |
| "terminationMessagePolicy": "File", | |
| "imagePullPolicy": "IfNotPresent" | |
| } | |
| ], | |
| "restartPolicy": "Always", | |
| "terminationGracePeriodSeconds": 30, | |
| "dnsPolicy": "ClusterFirst", | |
| "securityContext": {}, | |
| "schedulerName": "default-scheduler" | |
| } | |
| }, | |
| "volumeClaimTemplates": [ | |
| { | |
| "kind": "PersistentVolumeClaim", | |
| "apiVersion": "v1", | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| }, | |
| { | |
| "kind": "PersistentVolumeClaim", | |
| "apiVersion": "v1", | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| } | |
| ], | |
| "serviceName": "", | |
| "podManagementPolicy": "OrderedReady", | |
| "updateStrategy": { | |
| "type": "RollingUpdate", | |
| "rollingUpdate": { | |
| "partition": 0 | |
| } | |
| }, | |
| "revisionHistoryLimit": 10, | |
| "persistentVolumeClaimRetentionPolicy": { | |
| "whenDeleted": "Retain", | |
| "whenScaled": "Retain" | |
| } | |
| }, | |
| "status": { | |
| "replicas": 0, | |
| "availableReplicas": 0 | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DEBUG CREATED: | |
| { | |
| "metadata": { | |
| "name": "test", | |
| "namespace": "default", | |
| "uid": "f66c8243-2845-404d-b213-5764f17fa964", | |
| "resourceVersion": "2505", | |
| "generation": 1, | |
| "creationTimestamp": "2025-03-04T19:25:46Z", | |
| "managedFields": [ | |
| { | |
| "manager": "main", | |
| "operation": "Update", | |
| "apiVersion": "apps/v1", | |
| "time": "2025-03-04T19:25:46Z", | |
| "fieldsType": "FieldsV1", | |
| "fieldsV1": { | |
| "f:spec": { | |
| "f:persistentVolumeClaimRetentionPolicy": { | |
| ".": {}, | |
| "f:whenDeleted": {}, | |
| "f:whenScaled": {} | |
| }, | |
| "f:podManagementPolicy": {}, | |
| "f:replicas": {}, | |
| "f:revisionHistoryLimit": {}, | |
| "f:selector": {}, | |
| "f:template": { | |
| "f:metadata": { | |
| "f:labels": { | |
| ".": {}, | |
| "f:app": {} | |
| } | |
| }, | |
| "f:spec": { | |
| "f:containers": { | |
| "k:{\"name\":\"web\"}": { | |
| ".": {}, | |
| "f:image": {}, | |
| "f:imagePullPolicy": {}, | |
| "f:name": {}, | |
| "f:resources": {}, | |
| "f:terminationMessagePath": {}, | |
| "f:terminationMessagePolicy": {} | |
| } | |
| }, | |
| "f:dnsPolicy": {}, | |
| "f:restartPolicy": {}, | |
| "f:schedulerName": {}, | |
| "f:securityContext": {}, | |
| "f:terminationGracePeriodSeconds": {} | |
| } | |
| }, | |
| "f:updateStrategy": { | |
| "f:rollingUpdate": { | |
| ".": {}, | |
| "f:partition": {} | |
| }, | |
| "f:type": {} | |
| }, | |
| "f:volumeClaimTemplates": {} | |
| } | |
| } | |
| } | |
| ] | |
| }, | |
| "spec": { | |
| "replicas": 1, | |
| "selector": { | |
| "matchLabels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "template": { | |
| "metadata": { | |
| "creationTimestamp": null, | |
| "labels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "spec": { | |
| "containers": [ | |
| { | |
| "name": "web", | |
| "image": "nginx:1.12", | |
| "resources": {}, | |
| "terminationMessagePath": "/dev/termination-log", | |
| "terminationMessagePolicy": "File", | |
| "imagePullPolicy": "IfNotPresent" | |
| } | |
| ], | |
| "restartPolicy": "Always", | |
| "terminationGracePeriodSeconds": 30, | |
| "dnsPolicy": "ClusterFirst", | |
| "securityContext": {}, | |
| "schedulerName": "default-scheduler" | |
| } | |
| }, | |
| "volumeClaimTemplates": [ | |
| { | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| }, | |
| { | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| } | |
| ], | |
| "serviceName": "", | |
| "podManagementPolicy": "OrderedReady", | |
| "updateStrategy": { | |
| "type": "RollingUpdate", | |
| "rollingUpdate": { | |
| "partition": 0 | |
| } | |
| }, | |
| "revisionHistoryLimit": 10, | |
| "persistentVolumeClaimRetentionPolicy": { | |
| "whenDeleted": "Retain", | |
| "whenScaled": "Retain" | |
| } | |
| }, | |
| "status": { | |
| "replicas": 0, | |
| "availableReplicas": 0 | |
| } | |
| } | |
| DEBUG Get raw: | |
| { | |
| "kind": "StatefulSet", | |
| "apiVersion": "apps/v1", | |
| "metadata": { | |
| "name": "test", | |
| "namespace": "default", | |
| "uid": "f66c8243-2845-404d-b213-5764f17fa964", | |
| "resourceVersion": "2505", | |
| "generation": 1, | |
| "creationTimestamp": "2025-03-04T19:25:46Z", | |
| "managedFields": [ | |
| { | |
| "manager": "main", | |
| "operation": "Update", | |
| "apiVersion": "apps/v1", | |
| "time": "2025-03-04T19:25:46Z", | |
| "fieldsType": "FieldsV1", | |
| "fieldsV1": { | |
| "f:spec": { | |
| "f:persistentVolumeClaimRetentionPolicy": { | |
| ".": {}, | |
| "f:whenDeleted": {}, | |
| "f:whenScaled": {} | |
| }, | |
| "f:podManagementPolicy": {}, | |
| "f:replicas": {}, | |
| "f:revisionHistoryLimit": {}, | |
| "f:selector": {}, | |
| "f:template": { | |
| "f:metadata": { | |
| "f:labels": { | |
| ".": {}, | |
| "f:app": {} | |
| } | |
| }, | |
| "f:spec": { | |
| "f:containers": { | |
| "k:{\"name\":\"web\"}": { | |
| ".": {}, | |
| "f:image": {}, | |
| "f:imagePullPolicy": {}, | |
| "f:name": {}, | |
| "f:resources": {}, | |
| "f:terminationMessagePath": {}, | |
| "f:terminationMessagePolicy": {} | |
| } | |
| }, | |
| "f:dnsPolicy": {}, | |
| "f:restartPolicy": {}, | |
| "f:schedulerName": {}, | |
| "f:securityContext": {}, | |
| "f:terminationGracePeriodSeconds": {} | |
| } | |
| }, | |
| "f:updateStrategy": { | |
| "f:rollingUpdate": { | |
| ".": {}, | |
| "f:partition": {} | |
| }, | |
| "f:type": {} | |
| }, | |
| "f:volumeClaimTemplates": {} | |
| } | |
| } | |
| } | |
| ] | |
| }, | |
| "spec": { | |
| "replicas": 1, | |
| "selector": { | |
| "matchLabels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "template": { | |
| "metadata": { | |
| "creationTimestamp": null, | |
| "labels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "spec": { | |
| "containers": [ | |
| { | |
| "name": "web", | |
| "image": "nginx:1.12", | |
| "resources": {}, | |
| "terminationMessagePath": "/dev/termination-log", | |
| "terminationMessagePolicy": "File", | |
| "imagePullPolicy": "IfNotPresent" | |
| } | |
| ], | |
| "restartPolicy": "Always", | |
| "terminationGracePeriodSeconds": 30, | |
| "dnsPolicy": "ClusterFirst", | |
| "securityContext": {}, | |
| "schedulerName": "default-scheduler" | |
| } | |
| }, | |
| "volumeClaimTemplates": [ | |
| { | |
| "kind": "PersistentVolumeClaim", | |
| "apiVersion": "v1", | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| }, | |
| { | |
| "kind": "PersistentVolumeClaim", | |
| "apiVersion": "v1", | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| } | |
| ], | |
| "serviceName": "", | |
| "podManagementPolicy": "OrderedReady", | |
| "updateStrategy": { | |
| "type": "RollingUpdate", | |
| "rollingUpdate": { | |
| "partition": 0 | |
| } | |
| }, | |
| "revisionHistoryLimit": 10, | |
| "persistentVolumeClaimRetentionPolicy": { | |
| "whenDeleted": "Retain", | |
| "whenScaled": "Retain" | |
| } | |
| }, | |
| "status": { | |
| "replicas": 0, | |
| "availableReplicas": 0 | |
| } | |
| } | |
| DEBUG Get raw: | |
| { | |
| "metadata": { | |
| "name": "test", | |
| "namespace": "default", | |
| "uid": "f66c8243-2845-404d-b213-5764f17fa964", | |
| "resourceVersion": "2505", | |
| "generation": 1, | |
| "creationTimestamp": "2025-03-04T19:25:46Z", | |
| "managedFields": [ | |
| { | |
| "manager": "main", | |
| "operation": "Update", | |
| "apiVersion": "apps/v1", | |
| "time": "2025-03-04T19:25:46Z", | |
| "fieldsType": "FieldsV1", | |
| "fieldsV1": { | |
| "f:spec": { | |
| "f:persistentVolumeClaimRetentionPolicy": { | |
| ".": {}, | |
| "f:whenDeleted": {}, | |
| "f:whenScaled": {} | |
| }, | |
| "f:podManagementPolicy": {}, | |
| "f:replicas": {}, | |
| "f:revisionHistoryLimit": {}, | |
| "f:selector": {}, | |
| "f:template": { | |
| "f:metadata": { | |
| "f:labels": { | |
| ".": {}, | |
| "f:app": {} | |
| } | |
| }, | |
| "f:spec": { | |
| "f:containers": { | |
| "k:{\"name\":\"web\"}": { | |
| ".": {}, | |
| "f:image": {}, | |
| "f:imagePullPolicy": {}, | |
| "f:name": {}, | |
| "f:resources": {}, | |
| "f:terminationMessagePath": {}, | |
| "f:terminationMessagePolicy": {} | |
| } | |
| }, | |
| "f:dnsPolicy": {}, | |
| "f:restartPolicy": {}, | |
| "f:schedulerName": {}, | |
| "f:securityContext": {}, | |
| "f:terminationGracePeriodSeconds": {} | |
| } | |
| }, | |
| "f:updateStrategy": { | |
| "f:rollingUpdate": { | |
| ".": {}, | |
| "f:partition": {} | |
| }, | |
| "f:type": {} | |
| }, | |
| "f:volumeClaimTemplates": {} | |
| } | |
| } | |
| } | |
| ] | |
| }, | |
| "spec": { | |
| "replicas": 1, | |
| "selector": { | |
| "matchLabels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "template": { | |
| "metadata": { | |
| "creationTimestamp": null, | |
| "labels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "spec": { | |
| "containers": [ | |
| { | |
| "name": "web", | |
| "image": "nginx:1.12", | |
| "resources": {}, | |
| "terminationMessagePath": "/dev/termination-log", | |
| "terminationMessagePolicy": "File", | |
| "imagePullPolicy": "IfNotPresent" | |
| } | |
| ], | |
| "restartPolicy": "Always", | |
| "terminationGracePeriodSeconds": 30, | |
| "dnsPolicy": "ClusterFirst", | |
| "securityContext": {}, | |
| "schedulerName": "default-scheduler" | |
| } | |
| }, | |
| "volumeClaimTemplates": [ | |
| { | |
| "kind": "PersistentVolumeClaim", | |
| "apiVersion": "v1", | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| }, | |
| { | |
| "kind": "PersistentVolumeClaim", | |
| "apiVersion": "v1", | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| } | |
| ], | |
| "serviceName": "", | |
| "podManagementPolicy": "OrderedReady", | |
| "updateStrategy": { | |
| "type": "RollingUpdate", | |
| "rollingUpdate": { | |
| "partition": 0 | |
| } | |
| }, | |
| "revisionHistoryLimit": 10, | |
| "persistentVolumeClaimRetentionPolicy": { | |
| "whenDeleted": "Retain", | |
| "whenScaled": "Retain" | |
| } | |
| }, | |
| "status": { | |
| "replicas": 0, | |
| "availableReplicas": 0 | |
| } | |
| } | |
| DEBUG Get raw with protobuf: | |
| { | |
| "metadata": { | |
| "name": "test", | |
| "namespace": "default", | |
| "uid": "f66c8243-2845-404d-b213-5764f17fa964", | |
| "resourceVersion": "2508", | |
| "generation": 1, | |
| "creationTimestamp": "2025-03-04T19:25:46Z", | |
| "managedFields": [ | |
| { | |
| "manager": "kube-controller-manager", | |
| "operation": "Update", | |
| "apiVersion": "apps/v1", | |
| "time": "2025-03-04T19:25:46Z", | |
| "fieldsType": "FieldsV1", | |
| "fieldsV1": { | |
| "f:status": { | |
| "f:collisionCount": {}, | |
| "f:currentRevision": {}, | |
| "f:observedGeneration": {}, | |
| "f:updateRevision": {} | |
| } | |
| }, | |
| "subresource": "status" | |
| }, | |
| { | |
| "manager": "main", | |
| "operation": "Update", | |
| "apiVersion": "apps/v1", | |
| "time": "2025-03-04T19:25:46Z", | |
| "fieldsType": "FieldsV1", | |
| "fieldsV1": { | |
| "f:spec": { | |
| "f:persistentVolumeClaimRetentionPolicy": { | |
| ".": {}, | |
| "f:whenDeleted": {}, | |
| "f:whenScaled": {} | |
| }, | |
| "f:podManagementPolicy": {}, | |
| "f:replicas": {}, | |
| "f:revisionHistoryLimit": {}, | |
| "f:selector": {}, | |
| "f:template": { | |
| "f:metadata": { | |
| "f:labels": { | |
| ".": {}, | |
| "f:app": {} | |
| } | |
| }, | |
| "f:spec": { | |
| "f:containers": { | |
| "k:{\"name\":\"web\"}": { | |
| ".": {}, | |
| "f:image": {}, | |
| "f:imagePullPolicy": {}, | |
| "f:name": {}, | |
| "f:resources": {}, | |
| "f:terminationMessagePath": {}, | |
| "f:terminationMessagePolicy": {} | |
| } | |
| }, | |
| "f:dnsPolicy": {}, | |
| "f:restartPolicy": {}, | |
| "f:schedulerName": {}, | |
| "f:securityContext": {}, | |
| "f:terminationGracePeriodSeconds": {} | |
| } | |
| }, | |
| "f:updateStrategy": { | |
| "f:rollingUpdate": { | |
| ".": {}, | |
| "f:partition": {} | |
| }, | |
| "f:type": {} | |
| }, | |
| "f:volumeClaimTemplates": {} | |
| } | |
| } | |
| } | |
| ] | |
| }, | |
| "spec": { | |
| "replicas": 1, | |
| "selector": { | |
| "matchLabels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "template": { | |
| "metadata": { | |
| "creationTimestamp": null, | |
| "labels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "spec": { | |
| "containers": [ | |
| { | |
| "name": "web", | |
| "image": "nginx:1.12", | |
| "resources": {}, | |
| "terminationMessagePath": "/dev/termination-log", | |
| "terminationMessagePolicy": "File", | |
| "imagePullPolicy": "IfNotPresent" | |
| } | |
| ], | |
| "restartPolicy": "Always", | |
| "terminationGracePeriodSeconds": 30, | |
| "dnsPolicy": "ClusterFirst", | |
| "securityContext": {}, | |
| "schedulerName": "default-scheduler" | |
| } | |
| }, | |
| "volumeClaimTemplates": [ | |
| { | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| }, | |
| { | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| } | |
| ], | |
| "serviceName": "", | |
| "podManagementPolicy": "OrderedReady", | |
| "updateStrategy": { | |
| "type": "RollingUpdate", | |
| "rollingUpdate": { | |
| "partition": 0 | |
| } | |
| }, | |
| "revisionHistoryLimit": 10, | |
| "persistentVolumeClaimRetentionPolicy": { | |
| "whenDeleted": "Retain", | |
| "whenScaled": "Retain" | |
| } | |
| }, | |
| "status": { | |
| "observedGeneration": 1, | |
| "replicas": 0, | |
| "currentRevision": "test-6954d4f56b", | |
| "updateRevision": "test-6954d4f56b", | |
| "collisionCount": 0, | |
| "availableReplicas": 0 | |
| } | |
| } | |
| DEBUG Get raw without protobuf: | |
| { | |
| "metadata": { | |
| "name": "test", | |
| "namespace": "default", | |
| "uid": "f66c8243-2845-404d-b213-5764f17fa964", | |
| "resourceVersion": "2508", | |
| "generation": 1, | |
| "creationTimestamp": "2025-03-04T19:25:46Z", | |
| "managedFields": [ | |
| { | |
| "manager": "kube-controller-manager", | |
| "operation": "Update", | |
| "apiVersion": "apps/v1", | |
| "time": "2025-03-04T19:25:46Z", | |
| "fieldsType": "FieldsV1", | |
| "fieldsV1": { | |
| "f:status": { | |
| "f:collisionCount": {}, | |
| "f:currentRevision": {}, | |
| "f:observedGeneration": {}, | |
| "f:updateRevision": {} | |
| } | |
| }, | |
| "subresource": "status" | |
| }, | |
| { | |
| "manager": "main", | |
| "operation": "Update", | |
| "apiVersion": "apps/v1", | |
| "time": "2025-03-04T19:25:46Z", | |
| "fieldsType": "FieldsV1", | |
| "fieldsV1": { | |
| "f:spec": { | |
| "f:persistentVolumeClaimRetentionPolicy": { | |
| ".": {}, | |
| "f:whenDeleted": {}, | |
| "f:whenScaled": {} | |
| }, | |
| "f:podManagementPolicy": {}, | |
| "f:replicas": {}, | |
| "f:revisionHistoryLimit": {}, | |
| "f:selector": {}, | |
| "f:template": { | |
| "f:metadata": { | |
| "f:labels": { | |
| ".": {}, | |
| "f:app": {} | |
| } | |
| }, | |
| "f:spec": { | |
| "f:containers": { | |
| "k:{\"name\":\"web\"}": { | |
| ".": {}, | |
| "f:image": {}, | |
| "f:imagePullPolicy": {}, | |
| "f:name": {}, | |
| "f:resources": {}, | |
| "f:terminationMessagePath": {}, | |
| "f:terminationMessagePolicy": {} | |
| } | |
| }, | |
| "f:dnsPolicy": {}, | |
| "f:restartPolicy": {}, | |
| "f:schedulerName": {}, | |
| "f:securityContext": {}, | |
| "f:terminationGracePeriodSeconds": {} | |
| } | |
| }, | |
| "f:updateStrategy": { | |
| "f:rollingUpdate": { | |
| ".": {}, | |
| "f:partition": {} | |
| }, | |
| "f:type": {} | |
| }, | |
| "f:volumeClaimTemplates": {} | |
| } | |
| } | |
| } | |
| ] | |
| }, | |
| "spec": { | |
| "replicas": 1, | |
| "selector": { | |
| "matchLabels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "template": { | |
| "metadata": { | |
| "creationTimestamp": null, | |
| "labels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "spec": { | |
| "containers": [ | |
| { | |
| "name": "web", | |
| "image": "nginx:1.12", | |
| "resources": {}, | |
| "terminationMessagePath": "/dev/termination-log", | |
| "terminationMessagePolicy": "File", | |
| "imagePullPolicy": "IfNotPresent" | |
| } | |
| ], | |
| "restartPolicy": "Always", | |
| "terminationGracePeriodSeconds": 30, | |
| "dnsPolicy": "ClusterFirst", | |
| "securityContext": {}, | |
| "schedulerName": "default-scheduler" | |
| } | |
| }, | |
| "volumeClaimTemplates": [ | |
| { | |
| "kind": "PersistentVolumeClaim", | |
| "apiVersion": "v1", | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| }, | |
| { | |
| "kind": "PersistentVolumeClaim", | |
| "apiVersion": "v1", | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| } | |
| ], | |
| "serviceName": "", | |
| "podManagementPolicy": "OrderedReady", | |
| "updateStrategy": { | |
| "type": "RollingUpdate", | |
| "rollingUpdate": { | |
| "partition": 0 | |
| } | |
| }, | |
| "revisionHistoryLimit": 10, | |
| "persistentVolumeClaimRetentionPolicy": { | |
| "whenDeleted": "Retain", | |
| "whenScaled": "Retain" | |
| } | |
| }, | |
| "status": { | |
| "observedGeneration": 1, | |
| "replicas": 0, | |
| "currentRevision": "test-6954d4f56b", | |
| "updateRevision": "test-6954d4f56b", | |
| "collisionCount": 0, | |
| "availableReplicas": 0 | |
| } | |
| } | |
| DEBUG GET: | |
| { | |
| "metadata": { | |
| "name": "test", | |
| "namespace": "default", | |
| "uid": "f66c8243-2845-404d-b213-5764f17fa964", | |
| "resourceVersion": "2508", | |
| "generation": 1, | |
| "creationTimestamp": "2025-03-04T19:25:46Z", | |
| "managedFields": [ | |
| { | |
| "manager": "kube-controller-manager", | |
| "operation": "Update", | |
| "apiVersion": "apps/v1", | |
| "time": "2025-03-04T19:25:46Z", | |
| "fieldsType": "FieldsV1", | |
| "fieldsV1": { | |
| "f:status": { | |
| "f:collisionCount": {}, | |
| "f:currentRevision": {}, | |
| "f:observedGeneration": {}, | |
| "f:updateRevision": {} | |
| } | |
| }, | |
| "subresource": "status" | |
| }, | |
| { | |
| "manager": "main", | |
| "operation": "Update", | |
| "apiVersion": "apps/v1", | |
| "time": "2025-03-04T19:25:46Z", | |
| "fieldsType": "FieldsV1", | |
| "fieldsV1": { | |
| "f:spec": { | |
| "f:persistentVolumeClaimRetentionPolicy": { | |
| ".": {}, | |
| "f:whenDeleted": {}, | |
| "f:whenScaled": {} | |
| }, | |
| "f:podManagementPolicy": {}, | |
| "f:replicas": {}, | |
| "f:revisionHistoryLimit": {}, | |
| "f:selector": {}, | |
| "f:template": { | |
| "f:metadata": { | |
| "f:labels": { | |
| ".": {}, | |
| "f:app": {} | |
| } | |
| }, | |
| "f:spec": { | |
| "f:containers": { | |
| "k:{\"name\":\"web\"}": { | |
| ".": {}, | |
| "f:image": {}, | |
| "f:imagePullPolicy": {}, | |
| "f:name": {}, | |
| "f:resources": {}, | |
| "f:terminationMessagePath": {}, | |
| "f:terminationMessagePolicy": {} | |
| } | |
| }, | |
| "f:dnsPolicy": {}, | |
| "f:restartPolicy": {}, | |
| "f:schedulerName": {}, | |
| "f:securityContext": {}, | |
| "f:terminationGracePeriodSeconds": {} | |
| } | |
| }, | |
| "f:updateStrategy": { | |
| "f:rollingUpdate": { | |
| ".": {}, | |
| "f:partition": {} | |
| }, | |
| "f:type": {} | |
| }, | |
| "f:volumeClaimTemplates": {} | |
| } | |
| } | |
| } | |
| ] | |
| }, | |
| "spec": { | |
| "replicas": 1, | |
| "selector": { | |
| "matchLabels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "template": { | |
| "metadata": { | |
| "creationTimestamp": null, | |
| "labels": { | |
| "app": "demo" | |
| } | |
| }, | |
| "spec": { | |
| "containers": [ | |
| { | |
| "name": "web", | |
| "image": "nginx:1.12", | |
| "resources": {}, | |
| "terminationMessagePath": "/dev/termination-log", | |
| "terminationMessagePolicy": "File", | |
| "imagePullPolicy": "IfNotPresent" | |
| } | |
| ], | |
| "restartPolicy": "Always", | |
| "terminationGracePeriodSeconds": 30, | |
| "dnsPolicy": "ClusterFirst", | |
| "securityContext": {}, | |
| "schedulerName": "default-scheduler" | |
| } | |
| }, | |
| "volumeClaimTemplates": [ | |
| { | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| }, | |
| { | |
| "metadata": { | |
| "creationTimestamp": null | |
| }, | |
| "spec": { | |
| "resources": {}, | |
| "volumeMode": "Filesystem" | |
| }, | |
| "status": { | |
| "phase": "Pending" | |
| } | |
| } | |
| ], | |
| "serviceName": "", | |
| "podManagementPolicy": "OrderedReady", | |
| "updateStrategy": { | |
| "type": "RollingUpdate", | |
| "rollingUpdate": { | |
| "partition": 0 | |
| } | |
| }, | |
| "revisionHistoryLimit": 10, | |
| "persistentVolumeClaimRetentionPolicy": { | |
| "whenDeleted": "Retain", | |
| "whenScaled": "Retain" | |
| } | |
| }, | |
| "status": { | |
| "observedGeneration": 1, | |
| "replicas": 0, | |
| "currentRevision": "test-6954d4f56b", | |
| "updateRevision": "test-6954d4f56b", | |
| "collisionCount": 0, | |
| "availableReplicas": 0 | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Copyright 2017 The Kubernetes Authors. | |
| Licensed under the Apache License, Version 2.0 (the "License"); | |
| you may not use this file except in compliance with the License. | |
| You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software | |
| distributed under the License is distributed on an "AS IS" BASIS, | |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| See the License for the specific language governing permissions and | |
| limitations under the License. | |
| */ | |
| // Note: the example only works with the code within the same release/branch. | |
| package main | |
| import ( | |
| "bytes" | |
| "context" | |
| "encoding/json" | |
| "flag" | |
| "fmt" | |
| "os" | |
| "path/filepath" | |
| appsv1 "k8s.io/api/apps/v1" | |
| apiv1 "k8s.io/api/core/v1" | |
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | |
| "k8s.io/client-go/kubernetes" | |
| "k8s.io/client-go/tools/clientcmd" | |
| "k8s.io/client-go/util/homedir" | |
| ) | |
| func main() { | |
| var kubeconfig *string | |
| if home := homedir.HomeDir(); home != "" { | |
| kubeconfig = flag.String("kubeconfig", filepath.Join(home, ".kube", "config"), "(optional) absolute path to the kubeconfig file") | |
| } else { | |
| kubeconfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file") | |
| } | |
| flag.Parse() | |
| config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig) | |
| if err != nil { | |
| panic(err) | |
| } | |
| clientset, err := kubernetes.NewForConfig(config) | |
| if err != nil { | |
| panic(err) | |
| } | |
| c := clientset.AppsV1().StatefulSets(apiv1.NamespaceDefault) | |
| ss := &appsv1.StatefulSet{ | |
| ObjectMeta: metav1.ObjectMeta{Name: "test"}, | |
| Spec: appsv1.StatefulSetSpec{ | |
| Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"app": "demo"}}, | |
| VolumeClaimTemplates: []apiv1.PersistentVolumeClaim{ | |
| {TypeMeta: metav1.TypeMeta{APIVersion: "v1", Kind: "PersistentVolumeClaim"}}, | |
| {}, | |
| }, | |
| Template: apiv1.PodTemplateSpec{ | |
| ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{"app": "demo"}}, | |
| Spec: apiv1.PodSpec{Containers: []apiv1.Container{{Name: "web", Image: "nginx:1.12"}}}, | |
| }, | |
| }, | |
| } | |
| if result, err := c.Create(context.TODO(), ss, metav1.CreateOptions{}); err != nil { | |
| panic(err) | |
| } else { | |
| fmt.Fprintf(os.Stderr, "DEBUG CREATED:\n") | |
| fmt.Printf("%s\n\n", toJSON(result)) | |
| } | |
| defer func() { | |
| c.Delete(context.TODO(), ss.Name, metav1.DeleteOptions{}) | |
| }() | |
| if data, err := clientset.AppsV1().RESTClient().Get().Resource("statefulsets").Namespace("default").Name("test").DoRaw(context.TODO()); err != nil { | |
| panic(err) | |
| } else { | |
| fmt.Fprintf(os.Stderr, "DEBUG Get raw:\n") | |
| fmt.Printf("%s\n\n", indentJSON(data)) | |
| } | |
| var instance *appsv1.StatefulSet | |
| instance = &appsv1.StatefulSet{} | |
| if err := clientset.AppsV1().RESTClient().Get().Resource("statefulsets").Namespace("default").Name("test").Do(context.TODO()).Into(instance); err != nil { | |
| panic(err) | |
| } else { | |
| fmt.Fprintf(os.Stderr, "DEBUG Get raw:\n") | |
| fmt.Printf("%s\n\n", toJSON(instance)) | |
| } | |
| instance = &appsv1.StatefulSet{} | |
| if err := clientset.AppsV1().RESTClient().Get().UseProtobufAsDefaultIfPreferred(true).Resource("statefulsets").Namespace("default").Name("test").Do(context.TODO()).Into(instance); err != nil { | |
| panic(err) | |
| } else { | |
| fmt.Fprintf(os.Stderr, "DEBUG Get raw with protobuf:\n") | |
| fmt.Printf("%s\n\n", toJSON(instance)) | |
| } | |
| instance = &appsv1.StatefulSet{} | |
| if err := clientset.AppsV1().RESTClient().Get().UseProtobufAsDefaultIfPreferred(false).Resource("statefulsets").Namespace("default").Name("test").Do(context.TODO()).Into(instance); err != nil { | |
| panic(err) | |
| } else { | |
| fmt.Fprintf(os.Stderr, "DEBUG Get raw without protobuf:\n") | |
| fmt.Printf("%s\n\n", toJSON(instance)) | |
| } | |
| if result, err := c.Get(context.TODO(), "test", metav1.GetOptions{}); err != nil { | |
| panic(err) | |
| } else { | |
| fmt.Fprintf(os.Stderr, "DEBUG GET:\n") | |
| fmt.Printf("%s\n\n", toJSON(result)) | |
| } | |
| } | |
| func indentJSON(data []byte) string { | |
| buf := bytes.NewBuffer(nil) | |
| if err := json.Indent(buf, data, "", " "); err != nil { | |
| panic(err) | |
| } | |
| return buf.String() | |
| } | |
| func toJSON(o any) string { | |
| j, err := json.MarshalIndent(o, "", " ") | |
| if err != nil { | |
| panic(err) | |
| } | |
| return string(j) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment