如何在Kubernetes ConfigMap中存储二进制文件? [英] How can I store a binary file in a Kubernetes ConfigMap?

查看:1503
本文介绍了如何在Kubernetes ConfigMap中存储二进制文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以将二进制文件存储在 Kubernetes

从Kubernetes版本1.10.0开始,现在支持

二进制ConfigMap.自述文件中的注释:

ConfigMap对象现在通过新的binaryData字段支持二进制数据.使用kubectl create configmap --from-file时,包含非UTF8数据的文件将放置在此新字段中,以保留非UTF8数据.请注意,kubectl的--append-hash功能未考虑binaryData.使用此功能需要1.10+ apiserver和kubelet. (#57938,@ dims)

有关更多详细信息,请参见更改日志: https: //github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.10.md#apps

Can one store a binary file in a Kubernetes ConfigMap and then later read the same content from a volume that mounts this ConfigMap? For example, if directory /etc/mycompany/myapp/config contains binary file keystore.jks, will

kubectl create configmap myapp-config --from-file=/etc/mycompany/myapp/config

include file keystore.jks in ConfigMap myapp-config that can later be mapped to a volume, mounted into a container, and read as a binary file?

For example, given the following pod spec, should keystore.jks be available to myapp at /etc/mycompany/myapp/config/keystore.jks?

apiVersion: v1
kind: Pod
metadata:
  name: myapp
spec:
  containers:
  - name: myapp
    image: mycompany/myapp
    volumeMounts:
    - name: myapp-config
      mountPath: /etc/mycompany/myapp/config

  volumes:
  - name: myapp-config
    configMap:
      name: myapp-config

Kubernetes version details:

derek@derek-HP-EliteOne-800-G1-AiO:~/Documents/platinum/fix/brvm$ kubectl version
Client Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.6", GitCommit:"ae4550cc9c89a593bcda6678df201db1b208133b", GitTreeState:"clean", BuildDate:"2016-08-26T18:13:23Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.6+coreos.0", GitCommit:"f6f0055b8e503cbe5fb7b6f1a2ee37d0f160c1cd", GitTreeState:"clean", BuildDate:"2016-08-29T17:01:01Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"}

解决方案

Binary ConfigMaps are now supported since Kubernetes version 1.10.0. From the readme notes:

ConfigMap objects now support binary data via a new binaryData field. When using kubectl create configmap --from-file, files containing non-UTF8 data will be placed in this new field in order to preserve the non-UTF8 data. Note that kubectl's --append-hash feature doesn't take binaryData into account. Use of this feature requires 1.10+ apiserver and kubelets. (#57938, @dims)

See the changelog for more details: https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.10.md#apps

这篇关于如何在Kubernetes ConfigMap中存储二进制文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆