Description
Following is my secret.
cat test.yaml
apiVersion: v1
kind: Secret
metadata:
name: mysecret
type: Opaque
data:
username: YWRtaW4=
password: ""
kubectl create -f test.yaml
secret/mysecret created
The yaml output is:
kubectl get secret mysecret -o yaml
apiVersion: v1
data:
password: ""
username: YWRtaW4=
kind: Secret
metadata:
creationTimestamp: "2019-07-30T02:30:27Z"
name: mysecret
namespace: default
resourceVersion: "5797380"
selfLink: /api/v1/namespaces/default/secrets/mysecret
uid: fdeb42a3-b271-11e9-adf5-fa163e7bbbb1
type: Opaque
The json output is:
kubectl get secret mysecret -o json
{
"apiVersion": "v1",
"data": {
"password": "",
"username": "YWRtaW4="
},
"kind": "Secret",
"metadata": {
"creationTimestamp": "2019-07-30T02:30:27Z",
"name": "mysecret",
"namespace": "default",
"resourceVersion": "5797380",
"selfLink": "/api/v1/namespaces/default/secrets/mysecret",
"uid": "fdeb42a3-b271-11e9-adf5-fa163e7bbbb1"
},
"type": "Opaque"
}
You can see that password is empty string("") and everything looks normal by "kubectl get"
But when using read_namespaced_secret
try:
api_response = api_instance.read_namespaced_secret(name, namespace, pretty=pretty, exact=exact, export=export)
print(api_response)
except ApiException as e:
print("Exception when calling CoreV1Api->read_namespaced_secret: %s\n" % e)
The output is:
{'api_version': 'v1',
'data': {u'password': None, u'username': 'YWRtaW4='},
'kind': 'Secret',
'metadata': {'annotations': None,
'cluster_name': None,
'creation_timestamp': None,
'deletion_grace_period_seconds': None,
'deletion_timestamp': None,
'finalizers': None,
'generate_name': None,
'generation': None,
'initializers': None,
'labels': None,
'name': 'mysecret',
'namespace': 'default',
'owner_references': None,
'resource_version': None,
'self_link': '/api/v1/namespaces/default/secrets/mysecret',
'uid': None},
'string_data': None,
'type': 'Opaque'}
It's None in the output which should be empty string("")