ks generate

Use the specified prototype to generate a component manifest

Synopsis

The generate command (aliased from prototype use) generates Kubernetes-
compatible, Jsonnet manifests for components in your ksonnet app. Each component
corresponds to a single manifest in the components/ directory. This manifest
can define one or more Kubernetes resources, and is generated from a ksonnet
prototype (a customizable, reusable Kubernetes configuration snippet).

  1. The first argument, the prototype name, can either be fully qualified
    (e.g. io.ksonnet.pkg.single-port-service) or a partial match (e.g. service).
    If using a partial match, note that any ambiguity in resolving the name will
    result in an error.

  2. The second argument, the component name, determines the filename for the
    generated component manifest. For example, the following command will expand
    template io.ksonnet.pkg.single-port-deployment and place it in the
    file components/nginx-depl.jsonnet . Note that by default ksonnet will
    expand prototypes into Jsonnet files.

    1. ks prototype use io.ksonnet.pkg.single-port-deployment nginx-depl \
    2. --image=nginx

    If the optional --name tag is not specified, all Kubernetes API resources
    declared by this prototype use this argument as their own metadata.name

  3. Prototypes can be further customized by passing in parameters via additional
    command line flags, such as --image in the example above. Note that
    different prototypes support their own unique flags.

  • ks show — Show expanded manifests for a specific environment.
  • ks apply — Apply local Kubernetes manifests (components) to remote clusters
  • ks param set Change component or environment parameters (e.g. replica count, name)

Syntax

  1. ks generate <prototype-name> <component-name> [type] [parameter-flags] [flags]

Examples

  1. # Instantiate prototype 'io.ksonnet.pkg.single-port-deployment', using the
  2. # 'nginx' image. The expanded prototype is placed in
  3. # 'components/nginx-depl.jsonnet'.
  4. # The associated Deployment has metadata.name 'nginx-depl'.
  5. ks prototype use io.ksonnet.pkg.single-port-deployment nginx-depl \
  6. --image=nginx
  7. # Instantiate prototype 'io.ksonnet.pkg.single-port-deployment' using the
  8. # suffix, 'deployment'. (This works unless there is an ambiguity, e.g. another
  9. # prototype with 'deployment' in its name.) The expanded prototype is again
  10. # placed in 'components/nginx-depl.jsonnet'.
  11. # The associated Deployment has metadata.name 'nginx' instead of 'nginx-depl'
  12. # (due to --name).
  13. ks prototype use deployment nginx-depl \
  14. --name=nginx \
  15. --image=nginx
  16. # Instantiate prototype 'io.ksonnet.pkg.single-port-deployment' using the
  17. # 'nginx' image with values from 'ks-value'.
  18. ks prototype use single-port-deployment nginx-depl \
  19. --values-file=ks-value

Options

  1. -h, --help help for generate

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