Kubernetes(k8s)的ConfigMap以明文方式存储数据

1.用--from-env-file来创建ConfigMap,需要创建一个env.txt(文件)来存储数据

# cat << EOF > env.txt
> username=admin
> password=123456
> EOF

2.创建ConfigMap

# kubectl create configmap  myconfigmap --from-env-file=env.txt
configmap/myconfigmap created

3.查看ConfigMap

# kubectl get configmap
NAME          DATA   AGE
myconfigmap   2      52s

4.查看myconfigmap详细信息

# kubectl describe configmap myconfigmap
Name:         myconfigmap
Namespace:    default
Labels:       
Annotations:  

Data
====
password:
----
123456
username:
----
admin
Events:  

5.查看编辑myconfigmap

# kubectl edit configmap myconfigmap

# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
data:
  password: "123456"
  username: admin
kind: ConfigMap
metadata:
  creationTimestamp: "2020-04-12T09:59:02Z"
  name: myconfigmap
  namespace: default
  resourceVersion: "63360"
  selfLink: /api/v1/namespaces/default/configmaps/myconfigmap
  uid: fde39edf-0f3f-42b0-9533-975862540b0f

 

你可能感兴趣的:(Kubernetes的学习)