KUBERNETES(1)(kubernetes)

πŸ’– KUBERNETES(1)(kubernetes) πŸ’–

okay bestie, sit down, hydrate, and let me tell you about kubectl create configmap β€” it's a page from the kubernetes manual (the kubectl family of manuals, you know the vibe), and honestly it's giving "I just need my config in one place" energy. Also shoutout to Eric Paris, Jan 2015, who is listed right up there in the header of this thing β€” we'll get to the whole origin story at the end, no spoilers. πŸŽ€


✨ NAME ✨

kubectl create configmap β€” make a config map out of a local file, a directory, or a literal value you just type in. slay. πŸ¦‹


🌸 SYNOPSIS 🌸

kubectl create configmap [OPTIONS]

πŸ’… DESCRIPTION πŸ’…

So here's the tea: you're creating a config map based on a file, a directory, or a literal value you specify. That's it, that's the whole job.

A single config map can package up one or more key/value pairs. like, go off, multi-task. πŸ‘‘

When you're building a config map from a file, the key defaults to the basename of the file, and the value defaults to the file's content. and if that basename is an invalid key? no big deal, you're allowed to specify an alternate key. we love a flexible queen. ✨

When you're building one from a directory, every file in that directory whose basename is a valid key gets packaged into the config map. And listen β€” any directory entries that aren't regular files get ignored, ok? That means subdirectories, symlinks, devices, pipes, etc. β€” not invited to the party. πŸ™ˆ


πŸ”₯ OPTIONS πŸ”₯

  • --allow-missing-template-keys=true β€” if true, ignore any errors in templates when a field or map key is missing from the template. Only applies to golang and jsonpath output formats, iykyk.
  • --append-hash=false β€” append a hash of the configmap to its name. little fingerprint moment. 🫢
  • --dry-run="none" β€” must be "none", "server", or "client". If you pick the client strategy, it just prints the object that would be sent, without actually sending it. If you pick server strategy, it submits a server-side request without persisting the resource. manifesting without committing, basically. ✨
  • --field-manager="kubectl-create" β€” name of the manager used to track field ownership.
  • --from-env-file=[] β€” specify the path to a file to read lines of key=val pairs to create a configmap.
  • --from-file=[] β€” a key file can be specified using its file path, in which case the file basename is used as the configmap key, or optionally with a key and a file path, in which case the given key is used. Specifying a directory will iterate each named file in the directory whose basename is a valid configmap key.
  • --from-literal=[] β€” specify a key and literal value to insert in the configmap (i.e. mykey=somevalue).
  • -o, --output="" β€” output format. One of: (json, yaml, kyaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file).
  • --save-config=false β€” if true, the configuration of the current object gets saved in its annotation. Otherwise the annotation stays unchanged. This flag is useful when you want to run kubectl apply on this object later. future-proofing, we love her. πŸ’œ
  • --show-managed-fields=false β€” if true, keep the managedFields when printing objects in JSON or YAML format.
  • --template="" β€” template string or path to a template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
  • --validate="strict" β€” must be one of: strict (or true), warn, ignore (or false). "true" or "strict" will use a schema to validate the input and fail the request if it's invalid. It'll perform server-side validation if ServerSideFieldValidation is enabled on the api-server, but falls back to less reliable client-side validation if not. "warn" will warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled on the API server, and behaves as "ignore" otherwise. "false" or "ignore" performs no schema validation at all and silently drops any unknown or duplicate fields.

🌈 OPTIONS INHERITED FROM PARENT COMMANDS 🌈

(these are the family traits, bestie β€” passed down from the parent commands πŸ’–)

  • --as="" β€” username to impersonate for the operation. User could be a regular user or a service account in a namespace.
  • --as-group=[] β€” group to impersonate for the operation; this flag can be repeated to specify multiple groups.
  • --as-uid="" β€” UID to impersonate for the operation.
  • --as-user-extra=[] β€” user extras to impersonate for the operation; this flag can be repeated to specify multiple values for the same key.
  • --cache-dir="/home/username/.kube/cache" β€” default cache directory.
  • --certificate-authority="" β€” path to a cert file for the certificate authority.
  • --client-certificate="" β€” path to a client certificate file for TLS.
  • --client-key="" β€” path to a client key file for TLS.
  • --cluster="" β€” the name of the kubeconfig cluster to use.
  • --context="" β€” the name of the kubeconfig context to use.
  • --disable-compression=false β€” if true, opt out of response compression for all requests to the server.
  • --insecure-skip-tls-verify=false β€” if true, the server's certificate will not be checked for validity. > ⚠️ this will make your HTTPS connections insecure. not cute, be careful. 😭
  • --kubeconfig="" β€” path to the kubeconfig file to use for CLI requests.
  • --kuberc="" β€” path to the kuberc file to use for preferences. This can be disabled by exporting the KUBECTL_KUBERC=false feature gate or turning off the feature KUBERC=off.
  • --match-server-version=false β€” require server version to match client version.
  • -n, --namespace="" β€” if present, the namespace scope for this CLI request.
  • --password="" β€” password for basic authentication to the API server.
  • --profile="none" β€” name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace).
  • --profile-output="profile.pprof" β€” name of the file to write the profile to.
  • --proxy-url="" β€” proxy URL to use for requests to the API server.
  • --request-timeout="0" β€” the length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests.
  • -s, --server="" β€” the address and port of the Kubernetes API server.
  • --tls-server-name="" β€” server name to use for server certificate validation. If it's not provided, the hostname used to contact the server is used.
  • --token="" β€” bearer token for authentication to the API server.
  • --user="" β€” the name of the kubeconfig user to use.
  • --username="" β€” username for basic authentication to the API server.
  • --version=false β€” --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version.
  • --warnings-as-errors=false β€” treat warnings received from the server as errors and exit with a non-zero exit code.

🧚 EXAMPLE 🧚

# Create a new config map named my-config based on folder bar
kubectl create configmap my-config --from-file=path/to/bar

# Create a new config map named my-config with specified keys instead of file basenames on disk
kubectl create configmap my-config --from-file=key1=/path/to/bar/file1.txt --from-file=key2=/path/to/bar/file2.txt

# Create a new config map named my-config with key1=config1 and key2=config2
kubectl create configmap my-config --from-literal=key1=config1 --from-literal=key2=config2

# Create a new config map named my-config with key=value pairs from an env file
kubectl create configmap my-config --from-env-file=path/to/bar.env

πŸ“ SEE ALSO πŸ“


πŸ‘‘ HISTORY πŸ‘‘

January 2015, originally compiled by Eric Paris (eparis at redhat dot com) based on the kubernetes source material β€” but hopefully they've been automatically generated since! iconic origin story, honestly. ✨


and that's the whole page bestie!! 🫢 this came from the kubernetes manual, User section, dated Jan 2015 β€” go forth and configmap responsibly. periodt. πŸ’…πŸ’–πŸŒˆ

πŸ“¦ where this page comes from