Kubetcl create configmap with --from-file flag, inconsistent behavior

11/24/2021

When I'm executing create config command such as:

kubectl create configmap config-map-example --from-file=conf1.js=./conf-files/conf1.js --from-file=conf2.js=./conf-files/conf2.js --from-file=conf3.js=./conf-files/conf3.js --dry-run -o yaml

The content of each config file is either imported as string, or as block scalar, e.g:

kind: ConfigMap
metadata:
  name: config-map-example
apiVersion: v1
data:
  conf1.js: |-
    // conf1.js content

  conf2.js: "// conf2.js content as string with \n line breaks"

  conf3.js: |-
    // conf3.js content

Why is this happening?

-- eitann
kubectl
kubernetes

0 Answers