OC-CREATE-SECRET-GENERIC(1)

πŸ“¦
version 4.22.0 Β· 2 versions
, in nixpkgs unstable

πŸ’– OC CREATE SECRET(1) πŸ’–

okay bestie, welcome to the OpenShift CLI User Manuals ✨ this one's the oc create secret generic page and honestly it's kind of a baddie. it's from way back β€” June 2016 β€” but she's still serving.


🌸 NAME 🌸

oc create secret generic β€” create a secret from a local file, a directory, or a literal value πŸŽ€

πŸ¦‹ SYNOPSIS πŸ¦‹

oc create secret generic [OPTIONS]

πŸ’… DESCRIPTION πŸ’…

so basically you make a secret out of a file, a directory, or a literal value you just type in. no cap.

one single secret can totally package up one or more key/value pairs β€” she's an overachiever like that πŸ‘‘

when you're building a secret from a file, the key defaults to the basename of the file, and the value defaults to the file's contents. if that basename is an invalid key, or you're just feeling picky and want your own name, you can specify an alternate key. main character choice, honestly.

when you're building from a directory, every file in it whose basename is a valid key gets packaged into the secret. anything that isn't a regular file is ignored β€” subdirectories, symlinks, devices, pipes, all of it. sorry not sorry, they're not invited 🚫

✨ 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.
  • --append-hash=false β€” append a hash of the secret to its name.
  • --dry-run="none" β€” must be "none", "server", or "client". if client strategy, only print the object that would be sent, without sending it. if server strategy, submit the server-side request without persisting the resource.
  • --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 secret.
  • --from-file=[] β€” key files can be specified using their file path, in which case a default name will be given to them; or optionally with a name and file path, in which case the given name will be used. specifying a directory will iterate each named file in the directory that is a valid secret key.
  • --from-literal=[] β€” specify a key and literal value to insert in the secret (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 will be saved in its annotation. otherwise, the annotation will be unchanged. this flag is useful when you want to perform kubectl apply on this object in the future.
  • --show-managed-fields=false β€” if true, keep the managedFields when printing objects in JSON or YAML format.
  • --template="" β€” template string or path to 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].
  • --type="" β€” the type of secret to create.
  • --validate="ignore" β€” 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 invalid β€” it performs 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" will not perform any schema validation, silently dropping any unknown or duplicate fields. ⚠️ yeah, silently. she's just gonna toss those fields, so watch out.

🫢 OPTIONS INHERITED FROM PARENT COMMANDS 🫢

like hand-me-downs but make them kubeconfig

  • --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="/homeless-shelter/.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 β€” like, actually insecure, not cute-insecure.
  • --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.
  • --profile="none" β€” name of profile to capture. one of (none|cpu|heap|goroutine|threadcreate|block|mutex).
  • --profile-output="profile.pprof" β€” name of the file to write the profile to.
  • --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 is 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.
  • --warnings-as-errors=false β€” treat warnings received from the server as errors and exit with a non-zero exit code.

πŸ”₯ EXAMPLE πŸ”₯

the examples are literally the best part, look at her go:

# Create a new secret named my-secret with keys for each file in folder bar
oc create secret generic my-secret --from-file=path/to/bar

# Create a new secret named my-secret with specified keys instead of names on disk
oc create secret generic my-secret --from-file=ssh-privatekey=path/to/id_rsa --from-file=ssh-publickey=path/to/id_rsa.pub

# Create a new secret named my-secret with key1=supersecret and key2=topsecret
oc create secret generic my-secret --from-literal=key1=supersecret --from-literal=key2=topsecret

# Create a new secret named my-secret using a combination of a file and a literal
oc create secret generic my-secret --from-file=ssh-privatekey=path/to/id_rsa --from-literal=passphrase=topsecret

# Create a new secret named my-secret from env files
oc create secret generic my-secret --from-env-file=path/to/foo.env --from-env-file=path/to/bar.env

πŸ‘€ SEE ALSO πŸ‘€

🌈 HISTORY 🌈

June 2016 β€” ported from the Kubernetes man-doc generator. vintage πŸ’œ



and that's the whole page, bestie!! this gorgeous thing comes to you from Openshift β€” the Openshift CLI User Manuals, no less β€” dated June 2016 πŸŽ€ slay, go make some secrets, and remember: don't --insecure-skip-tls-verify, i'm begging 🫢✨

πŸ“¦ where this page comes from