ks apply

Apply local Kubernetes manifests (components) to remote clusters

Synopsis

The applycommand uses local manifest(s) to update (and optionally create)
Kubernetes resources on a remote cluster. This cluster is determined by the
mandatory <env-name> argument.

The manifests themselves correspond to the components of your app, and reside
in your app’s components/ directory. When applied, the manifests are fully
expanded using the parameters of the specified environment.

By default, all component manifests are applied. To apply a subset of components,
use the --component flag, as seen in the examples below.

Note that this command needs to be run within a ksonnet app directory.

  • ks diff — Compare manifests, based on environment or location (local or remote)
  • ks delete — Remove component-specified Kubernetes resources from remote clusters

Syntax

  1. ks apply <env-name> [-c <component-name>] [--dry-run] [flags]

Examples

  1. # Create or update all resources described in the ksonnet application, specifically
  2. # the ones running in the 'dev' environment. This command works in any subdirectory
  3. # of the app.
  4. #
  5. # This essentially deploys all components in the 'components/' directory.
  6. ks apply dev
  7. # Similar to the previous command, but does not immediately execute. Use this to
  8. # see a preview of the cluster-changing actions.
  9. ks apply dev --dry-run
  10. # Create or update the single 'guestbook-ui' component of a ksonnet app, specifically
  11. # the instance running in the 'dev' environment.
  12. #
  13. # This essentially deploys 'components/guestbook-ui.jsonnet'.
  14. ks apply dev -c guestbook-ui
  15. # Create or update multiple components in a ksonnet application (e.g. 'guestbook-ui'
  16. # and 'nginx-depl') for the 'dev' environment. Does not create resources that are
  17. # not already present on the cluster.
  18. #
  19. # This essentially deploys 'components/guestbook-ui.jsonnet' and
  20. # 'components/nginx-depl.jsonnet'.
  21. ks apply dev -c guestbook-ui -c nginx-depl --create false

Options

  1. --as string Username to impersonate for the operation
  2. --as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
  3. --certificate-authority string Path to a cert file for the certificate authority
  4. --client-certificate string Path to a client certificate file for TLS
  5. --client-key string Path to a client key file for TLS
  6. --cluster string The name of the kubeconfig cluster to use
  7. -c, --component strings Name of a specific component (multiple -c flags accepted, allows YAML, JSON, and Jsonnet)
  8. --context string The name of the kubeconfig context to use
  9. --create Option to create resources if they do not already exist on the cluster (default true)
  10. --dry-run Option to preview the list of operations without changing the cluster state
  11. -V, --ext-str strings Values of external variables
  12. --ext-str-file strings Read external variable from a file
  13. --gc-tag string A tag that's (1) added to all updated objects (2) used to garbage collect existing objects that are no longer in the manifest
  14. -h, --help help for apply
  15. --insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
  16. -J, --jpath strings Additional jsonnet library search path
  17. --kubeconfig string Path to a kubeconfig file. Alternative to env var $KUBECONFIG.
  18. -n, --namespace string If present, the namespace scope for this CLI request
  19. --password string Password for basic authentication to the API server
  20. --request-timeout string 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. (default "0")
  21. --server string The address and port of the Kubernetes API server
  22. --skip-gc Option to skip garbage collection, even with --gc-tag specified
  23. -A, --tla-str strings Values of top level arguments
  24. --tla-str-file strings Read top level argument from a file
  25. --token string Bearer token for authentication to the API server
  26. --user string The name of the kubeconfig user to use
  27. --username string Username for basic authentication to the API server

Options inherited from parent commands

  1. --dir string Ksonnet application root to use; Defaults to CWD
  2. --tls-skip-verify Skip verification of TLS server certificates
  3. -v, --verbose count Increase verbosity. May be given multiple times.

SEE ALSO

  • ks - Configure your application to deploy to a Kubernetes cluster